ericmakesapps / graphql-passport

Strategy and utilities to use passport.js with GraphQL server
MIT License
152 stars 16 forks source link

feat: Support other strategies #39

Open DarkLite1 opened 4 years ago

DarkLite1 commented 4 years ago

Does graphql-passport also supports other strategies like say passport-azure-ad with its BearerStrategy?`

The documentation only mentions GraphQLLocalStrategy, that's why it's unclear to me.

gforge commented 4 years ago

This should be doable but I've never worked with the more advanced strategies. The GraphQLLocalStrategy is implemented but it would be awesome if all of the strategies passport provides could be available.

DarkLite1 commented 4 years ago

Indeed, that would really be cool! So users can just use the standard available passport strategies and you don't need to replicate them and in turn avoid code duplication.

For the moment I'm following your guide to try and implement the passport-azure-ad strategie. The plan is to manually add the passport login and authenticate methods to the context just like your logout example in the guide.

I'm a bit of a newbee to web development, so fingers crossed :)

PacomeRivier commented 3 years ago

Hello, I'm trying to do the exact same thing, any update on how you managed to implement it @DarkLite1 ?

DarkLite1 commented 3 years ago

I couldn't wait for graphql-passport to support this feature so I used the standard passport to set up authentication with Azure AD.

jkettmann commented 3 years ago

Hey @DarkLite1, @PacomeRivier. Sorry for keeping you wait. The biggest pain that graphql-passport solves is local authentication with email and password. That's what the GraphQLLocalStrategy is for. Other strategies can be used in the normal way with passport.

If you're looking for an example you can see this blog post. Here is the final repository that combines the Facebook Strategy with local email/password.

If you don't use local email/password to authenticate the only thing you might use from this package is the buildContext function as you can see here. This basically just copies some of the passport functions like authenticate, login, logout and so on into the GraphQL context. So you might not necessarily need to use this package if you don't use local email/password.