护照验证对请求的访问

时间:2021-05-03 08:55:56

标签: node.js express passport.js

我已经在我的 Express 服务器中设置了带护照的 azureAD 登录。我想访问passport.authenticate中间件中的req对象,这有可能吗?

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 个答案:

答案 0 :(得分:0)

您不能使用 req 对象,因为这些是根据您要提供给用户的身份验证或配置提供的默认选项。对于示例,您可以检查:

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('/');
});

有关详细信息,您可以查看详情here