加载中

使用 Microsoft Entra ID 设置 SAML

本指南详细介绍了如何将 Microsoft Entra ID(原名 Azure Active Directory)配置为 SAML 单点登录 (SSO) 身份验证的身份提供商,用于访问 Kibana。

有关 SAML 配置的更多信息,请参阅

按照以下步骤配置使用 Microsoft Entra ID 作为身份提供商的 SAML,以访问 Kibana。

  1. 配置 Entra 身份提供商

    1. 登录到 Azure 门户并导航到 Entra(原名 Azure Active Directory)。

    2. 点击 企业应用程序,然后点击 新应用程序 以注册新应用程序。

    3. 点击 创建您自己的应用程序,提供一个名称,并选择 集成你在库中找不到的任何其他应用程序 选项。

      The Azure Create your own application flyout
    4. 导航到新应用程序,点击 用户和组,并添加所有必要的用户和组。只有在此处添加的用户和组才具有对 Elastic Stack 的 SSO 访问权限。

      The Entra User and groups page
    5. 导航到 单点登录 并编辑基本 SAML 配置,添加以下信息

      • Identifier (Entity ID) - 唯一标识 SAML 服务提供商的字符串。我们建议使用您的 Kibana URL,但您可以使用任何标识符。

        例如,https://saml-azure.kb.northeurope.azure.elastic-cloud.com:443

      • Reply URL - 这是附加了 /api/security/saml/callback 的 Kibana URL。

        例如,https://saml-azure.kb.northeurope.azure.elastic-cloud.com:443/api/security/saml/callback

      • Logout URL - 这是附加了 /logout 的 Kibana URL。

        例如,https://saml-azure.kb.northeurope.azure.elastic-cloud.com:443/logout

        The Entra SAML configuration page with Kibana settings
    6. 导航到 基于 SAML 的单点登录,打开 用户属性和声明 (User Attributes & Claims) 配置,并根据需要更新字段。这些设置控制在 SSO 期间将 Microsoft Entra ID 中的哪些信息提供给 Elastic Stack。此信息可用于在 Elastic Stack 中标识用户和/或为 Elastic Stack 中的用户分配不同的角色。我们建议为唯一标识用户且不易更改的 Unique User Identifier (Name ID) 声明配置适当的值。

      The Entra ID User Attributes & Claims page
    7. 在 SAML 配置页面中,记下 App Federation Metadata URL

  2. 为 SAML 配置 Elasticsearch 和 Kibana

    1. 更新您的 Elasticsearch 设置并使用以下配置

      xpack.security.authc.realms.saml.kibana-realm:
        order: 2
        attributes.principal: nameid
        attributes.groups: "http://schemas.microsoft.com/ws/2008/06/identity/claims/groups"
        idp.metadata.path: "https://login.microsoftonline.com/<Tenant ID>/federationmetadata/2007-06/federationmetadata.xml?appid=<Application_ID>"
        idp.entity_id: "https://sts.windows.net/<Tenant_ID>/"
        sp.entity_id: "<Kibana_Endpoint_URL>"
        sp.acs: "<Kibana_Endpoint_URL>/api/security/saml/callback"
        sp.logout: "<Kibana_Endpoint_URL>/logout"
      		

      其中

      • <Application_ID> 是您的应用程序 ID,可在 Azure 的应用程序详细信息中找到。

      • <Tenant_ID> 是您的租户 ID,可在 Azure 的租户概览页面中找到。

      • <Kibana_Endpoint_URL> 是您的 Kibana 实例的基本 URL。确保该值与您在先前的 Microsoft Entra ID 配置步骤中为 Identifier (Entity ID) 设置的值相同。

      • 对于 idp.metadata.path,我们展示了构建 URL 的格式。该值应与您在上一步中记下的 App Federation Metadata URL 设置完全相同。

      对于拥有大量组成员身份的组织

      如果您配置 attributes.groups 从 SAML 断言中读取 Azure AD 组列表,请注意,属于许多组的用户可能会超出 Azure AD 对 SAML 令牌的大小限制。在这种情况下,将省略 groups 属性。

      为了避免这种情况,请在 Azure Entra 中启用 分配给应用程序的组 选项(应用注册 > 令牌配置 > 编辑组声明)。此设置将 SAML 断言中的 groups 属性限制为仅分配给应用程序的那些组。

      替代方法:如果无法将组限制为应用程序分配的组,请使用 用于 Elasticsearch 的 Microsoft Graph Authz 插件。它在授权期间通过 Microsoft Graph 查找组成员身份,因此即使由于超出大小限制而省略了 groups 属性,它也能继续正常工作。

      有关更多信息,请参阅 Microsoft 安全文档中的 组超量

    2. 接下来,配置 Kibana 以启用 SAML 身份验证

      1. 更新您的 Kibana 设置并使用以下配置

        xpack.security.authc.providers:
          saml.kibana-realm:
            order: 0
            realm: kibana-realm
            description: "Log in with Microsoft Entra ID"
        		

        上述示例中使用的配置值为

        xpack.security.authc.providers
        添加 saml 提供商以指示 Kibana 使用 SAML SSO 作为身份验证方法。
        xpack.security.authc.providers.saml.<provider-name>.realm

        将其设置为您在 Elasticsearch 领域配置中使用的 SAML 领域的名称。对于此示例,使用您在上一步中配置的领域名称:kibana-realm

      2. 创建一个角色映射。

        以下用于 SAML SSO 的角色映射基于 attributes.principal 电子邮件地址将访问权限限制为特定用户 (email)。这可防止同一域上的其他用户访问您的部署。您可以根据需要删除该规则或进行调整。

        POST /_security/role_mapping/SAML_kibana
        {
            "enabled": true,
            "roles": [ "superuser" ],
            "rules" : {
              "all" : [
                {
                  "field" : {
                    "realm.name" : "kibana-realm"
                  }
                },
                {
                  "field" : {
                    "username" : [
                      "<firstname.lastname>"
                    ]
                  }
                }
              ]
            },
            "metadata": { "version": 1 }
        }
        		

        有关更多信息,请参阅 Elasticsearch SAML 文档中的 配置角色映射

至此,您应该已成功配置使用 Microsoft Entra ID 作为身份提供商的 Kibana SSO 访问权限。

© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.