-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document how to access the "state" parameter #40
Comments
Working out some of the details of how this works but, in the meantime, I figure I would provide some information for anyone looking. The You can access the value that Passport generates in the config callback by using var auth0Strategy = new Auth0Strategy(
{
domain: process.env.AUTH0_DOMAIN,
clientID: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
callbackURL: process.env.AUTH0_CALLBACK_URL,
passReqToCallback: true
},
function (req, accessToken, refreshToken, extraParams, profile, done) {
//
// State value is in req.query.state ...
//
return done(null, profile);
}
);
passport.use(auth0Strategy); ... or in the auth callback route with no changes to the config callback: router.get(
'/auth/callback',
function (req, res, next) {
//
// State value is in req.query.state ...
//
passport.authenticate('auth0', function (err, user, info) {
// ...
})(req, res, next);
}
); Passport itself allows for a custom value to be passed to the authorize endpoint if you set router.get('/login', (req, res, next) => {
const authenticator = passport.authenticate('auth0', { scope: 'openid email profile', state: 'custom' })
authenticator(req, res, next)
}); Big thanks to this issue for explanation on how this works. The problem here is that So, as it stands, to use a custom state, you need to store it before redirecting to the authorize endpoint and then check it in the auth callback route. Marking this as closed for now, will update the README if anything useful comes out of the issue linked above. |
Basically using
passReqToCallback
or providing an explicit option for that, the user might not be aware of the inheritance on the lib.The text was updated successfully, but these errors were encountered: