5.3. 使用 Microsoft Azure Active Directory 配置 Apicurio Registry 身份验证和授权


本节介绍如何为 Apicurio Registry 和 Microsoft Azure Active Directory (Azure AD)手动配置身份验证和授权选项。

Apicurio Registry web 控制台和核心 REST API 支持基于 OpenID Connect (OIDC)和 OAuth 授权代码流的 Azure AD 中的身份验证。Apicurio Registry 为默认的 admin、write 和 read-only 用户角色提供基于角色的授权。Apicurio Registry 身份验证和授权设置默认禁用。

要使用 Azure AD 保护 Apicurio Registry,您需要在带有特定配置的 Azure AD 中具有有效目录。这包括在 Azure AD 门户中注册 Apicurio Registry 应用程序,并使用推荐的设置并在 Apicurio Registry 中配置环境变量。

先决条件

流程

  1. 使用您的电子邮件地址或 GitHub 帐户登录到 Azure AD 门户。
  2. 在导航菜单中,选择 Manage > App registrations > New registration,并完成以下设置:

    • 名称 :输入应用程序名称。例如: apicurio-registry-example
    • 支持的帐户类型 :单击 任何组织目录中的 Accounts
    • 重定向 URI :从列表中选择 Single-page 应用程序,并输入 Apicurio Registry web 控制台应用程序主机。例如: https://test-registry.com/ui/

      重要

      您必须将 Apicurio Registry 应用程序主机注册为 Redirect URI。登录时,用户会从 Apicurio Registry 重定向到 Azure AD 以进行身份验证,并且您想要稍后将其发送回您的应用程序。Azure AD 不允许任何未注册的重定向 URL。

  3. Register。您可以通过选择 Manage > App registrations > apicurio-registry-example 来查看应用程序注册详情。
  4. 选择 Manage > Authentication,并确保应用程序配置了重定向 URL 和令牌,如下所示:

    • 重定向 URI :例如: https://test-registry.com/ui/
    • 隐式授权和混合流程 :单击 ID 令牌(用于隐式和混合流)
  5. 选择 Azure AD > Admin > App registrations > your app > Application (client) ID。例如: 123456a7-b8c9-012d-e3f4-5fg67h8i901
  6. 选择 Azure AD > Admin > App registrations > your app > Directory (tenant) ID。例如: https://login.microsoftonline.com/1a2bc34d-567e-89f1-g0hi-1j2kl3m4no56/v2.0
  7. 在 Apicurio Registry 中,使用 Azure AD 设置配置以下环境变量:

    表 5.6. 在 Apicurio Registry 中为 Azure AD 设置配置
    环境变量描述设置

    KEYCLOAK_API_CLIENT_ID

    Apicurio Registry REST API 的客户端应用程序 ID

    在第 5 步中获取的 Azure AD 应用程序(客户端)ID。例如: 123456a7-b8c9-012d-e3f4-5fg67h8i901

    REGISTRY_OIDC_UI_CLIENT_ID

    Apicurio Registry web 控制台的客户端应用程序 ID。

    在第 5 步中获取的 Azure AD 应用程序(客户端)ID。例如: 123456a7-b8c9-012d-e3f4-5fg67h8i901

    REGISTRY_AUTH_URL_CONFIGURED

    Azure AD 中用于身份验证的 URL。

    在第 6 步中获取的 Azure AD 应用程序(租户)ID。例如: https://login.microsoftonline.com/1a2bc34d-567e-89f1-g0hi-1j2kl3m4no56/v2.0

  8. 在 Apicurio Registry 中,为特定于 Apicurio Registry 的设置配置以下环境变量:

    表 5.7. 特定于 Apicurio Registry 的设置配置
    环境变量描述设置

    REGISTRY_AUTH_ENABLED

    为 Apicurio Registry 启用身份验证。

    true

    REGISTRY_UI_AUTH_TYPE

    Apicurio Registry 身份验证类型。

    oidc

    CORS_ALLOWED_ORIGINS

    Apicurio Registry 部署的主机,用于跨原始资源共享(CORS)。

    例如: https://test-registry.com

    REGISTRY_OIDC_UI_REDIRECT_URL

    Apicurio Registry web 控制台的主机。

    例如: https://test-registry.com/ui

    ROLE_BASED_AUTHZ_ENABLED

    在 Apicurio Registry 中启用基于角色的授权。

    true

    QUARKUS_OIDC_ROLES_ROLE_CLAIM_PATH

    Azure AD 存储角色的声明的名称。

    roles

    注意

    当您在 Apicurio Registry 中启用角色时,还必须在 Azure AD 中创建与应用程序角色相同的角色。Apicurio Registry 期望的默认角色为 sr-adminsr-developersr-readonly

其他资源

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat, Inc.