成功login后,Azureauthentication返回到login页面 – node.js

我有一个node.js应用程序,并将其上传到Azure。 我已经将Active Directory支持包括在我们的应用程序中。 使用高级选项,我已经设置客户端ID和所需的细节到应用程序。

在Node.js应用程序中,我使用passport-azure-ad来validation用户。 我已经configuration了客户端ID,秘密,返回url等,我用下面的get方法来调用蔚蓝authentication。

app.get('/login', passport.authenticate('azuread-openidconnect', { failureRedirect: '/hello' }), function(req, res){ res.sendFile(path.join(__dirname+'/views/index.html')); }); 

当我部署代码并在Azure中运行它时,它首先将我带到azure色的login页面,一旦input正确的电子邮件和密码,它就会再次将我redirect到login页面。 它也没有抛出任何错误。

请帮忙避免这个redirect到login页面的循环过程。 提前致谢。

请检查您在configuration和Azure AD应用程序的configuration中设置了returnURL Url。 完成身份validation后,它将返回此端点。

例如

你设置returnURLhttp://localhost:3000/auth/openid/return ,你需要检查路由/auth/openid/return就好,

 app.get('/auth/openid/return', passport.authenticate('azuread-openidconnect', { failureRedirect: '/login' }), function(req, res) { log.info('We received a return from AzureAD.'); res.redirect('/'); }); 

在你的应用程序。 无论是redirect到login页面,还是authentication失败。