【问题标题】:How can I get the azure AD roles in my Backend?如何在我的后端获得 azure AD 角色?
【发布时间】:2022-02-28 18:56:40
【问题描述】:

我正在 node express 中开发一个后端,我使用 passport-azure-ad 库来保护我的 api 的路由,有没有办法访问 Azure Ad 中为应用程序定义的角色并在路由中验证它们?

【问题讨论】:

    标签: node.js azure passport.js roles passport-azure-ad


    【解决方案1】:

    要达到上述要求,您可能需要遵循以下解决方法。

    我们可以使用MS GRAPH Programmatically获取我们的 Azure AD 日志详细信息

    示例代码:-

    const options = {
        authProvider,
    };
    
    const client = Client.init(options);
    
    let directoryAudit = await client.api('/auditLogs/directoryAudits/{id}')
        .get();
    

    您还可以通过在代码中使用下面的MS GRAPH query 来获取已在 Azure AD 中分配的角色。

    GET /users/{id | userPrincipalName}/appRoleAssignments
    

    完整设置请参考以下链接:

    【讨论】:

      猜你喜欢
      • 2015-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多