【问题标题】:Passport authenticate access to reqPassport 验证对 req 的访问
【发布时间】:2021-07-25 16:43:15
【问题描述】:

我已经在我的 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) => {
        ...
    }

【问题讨论】:

  • 你知道怎么做吗?如果是,请分享

标签: node.js express passport.js


【解决方案1】:

您不能使用 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    • 2021-12-13
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多