node.js - Passport-azure-ad, token 验证

标签 node.js azure oauth-2.0 passport-azure-ad

这个问题与 passport-azure-ad, does it parse & validate token?

我尝试掌握使用 Passport-azure-ad 模块。我使用 OpenID Connect 成功登录我的用户,获取 access_token 并直接使用我的 REST API,该 API 由 app.get('myapi',passport.authenticate('oath-bearer', {失败重定向:'/'}), 函数(req,res){});

但是,如果我尝试从 OpenID connect 创建的 session 中注销, token 仍然有效,直到过期(通常为 3600 秒)。

我使用 access_token 来保护我的端点不托管在 Microsoft 的 API 网关后面,因此我猜想撤销 access_token 并不简单。

有什么方法可以检查 access_token 是否已使用 Passport-azure-ad 撤销?最佳实践是什么?

最佳答案

根据Azure Document上的描述:

While directing the user to the end_session_endpoint will clear some of the user's single sign-on state with Azure AD B2C, it will not sign the user out of the user's social identity provider (IDP) session. If the user selects the same IDP during a subsequent sign-in, they will be reauthenticated, without entering their credentials. If a user wants to sign out of your B2C application, it does not necessarily mean they want to sign out of their Facebook account entirely. However, in the case of local accounts, the user's session will be ended properly.

因此您可以直接使用end_session_endpoint。您可以在 b2c_1_sign_in 策略端点的元数据文档中找到它,例如:

https://login.microsoftonline.com/fabrikamb2c.onmicrosoft.com/v2.0/.well-known/openid-configuration?p=b2c_1_sign_in

就像您在 v1 中使用常见的 Azure AD 应用程序一样,您还可以在元数据文档中找到 end_session_endpoint,例如:

https://login.microsoftonline.com/fabrikamb2c.onmicrosoft.com/.well-known/openid-configuration

您可以引用Azure Active Directory B2C: Web sign-in with OpenID Connect了解更多信息。

如有任何进一步的疑问,请随时告诉我。

关于node.js - Passport-azure-ad, token 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41182170/

相关文章:

c++ - 如何更新 Node.js native 插件以使用新的 API?

node.js - 退出自定义 Sails 1 和 Actions 2

node.js - azure 函数应用程序在长时间运行的协调器期间停止运行

css - 字体在 azure 上不起作用

android - YouTube API 3上传视频-无效的凭据-Android

ruby - 使用 Ruby HTTParty 的 RingCentral OAuth 服务器专用密码流

oauth - 无法在oauth2中验证电子邮件地址吗?

php - Node.js 相当于 PHPlivedocx?

node.js - 如何在 sailsjs 中验证模型

azure - 使用 Azure 云应用程序中的 blob 租赁功能