2
votes

I have set up azureAD login with passport in my Express-server. I would like to access the req object in the passport.authenticate middleware, is this possible somehow?

this.router.post(
    'login/azure/return',
    passport.authenticate('azuread-openidconnect', {
        session: false,
        failureRedirect: '' // I would like access to the req object HERE
    }),
    (req, res) => {
        ...
    }
1
did you figure out how to do it? If yes then please share - Himanshu Walimbe

1 Answers

0
votes

You can't use the req object because these are default options provided based on the authentication or the configuration you want to provide to a user. For sample you can check this:

passport.authenticate('azuread-openidconnect', { failureRedirect: '/', session: false, customState: 'my_state', resourceURL: 'https://graph.microsoft.com/mail.send'}, (req, res, next) => {
    log.info('Login was called in the Sample');
    res.redirect('/');
});

For more information, you can check the details here.