9.4. 社交身份提供程序


社交身份提供程序可以将身份验证委托给信任的社交媒体帐户。红帽 Keycloak 构建包括对社交网络的支持,如 Google、Facebook、Twitter、GitHub、LinkedIn、Microsoft 和 Stack Overflow。

9.4.1. Bitbucket

要使用 Bitbucket 登录,请执行以下步骤。

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Bitbucket

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,在 Bitbucket 云进程上执行 OAuth。当您点 Add Consumer:

    1. Redirect URI 的值粘贴到 Callback URL 字段中。
    2. 确保您在 帐户 部分中选择 EmailRead,以允许您的应用程序读取电子邮件。
  5. 请注意,创建消费者时会显示 KeySecret 值 Bitbucket。
  6. 在 Red Hat build of Keycloak 中,将 Key 的值粘贴到 Client ID 字段中。
  7. 在 Red Hat build of Keycloak 中,将 Secret 的值粘贴到 Client Secret 字段中。
  8. 点击 Add

9.4.2. Facebook

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Facebook

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,打开 Developers 的 Meta

    1. 单击 My Apps
    2. 选择 Create App

      添加用例

      Add a use case

    3. 选择 其他

      选择应用程序类型

      Select an app type

    4. 选择 Consumer

      创建应用程序

      Create an app

    5. 填写所有必填字段。
    6. Create app。然后 meta 会进入仪表板。

      添加产品

      Add Product

    7. Facebook Login 框中点 Set Up
    8. 选择 Web
    9. Site URL 字段中输入 Redirect URI 的值,然后单击 Save
    10. 在导航面板中,选择 App settings - Basic
    11. App Secret 字段中的 Show
    12. 请注意 App IDApp Secret
  5. 在 Red Hat build of Keycloak 的 Client ID and Client Secret 字段中输入bookbook app 的 App IDApp Secret值。
  6. 添加
  7. Default Scopes 字段中输入所需的范围。默认情况下,红帽构建的 Keycloak 使用 电子邮件 范围。有关 Facebook 范围的更多信息,请参阅 Graph API

Red Hat build of Keycloak 将配置集请求发送到 graph.facebook.com/me?fields=id,name,email,first_name,last_name。响应仅包含 id、name、mail、first_name 和 last_name 字段。要从Facebook 配置集中获取其他字段,请添加对应的范围,并在 Additional user 的 profile 项 中添加字段名称。

9.4.3. GitHub

要使用 GitHub 登录,请执行以下步骤。

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Github

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,创建一个 OAUTH 应用程序

    1. 在创建应用程序时,在 Authorization 回调 URL 字段中输入 Redirect URI 的值。
    2. 请注意 OAUTH 应用程序的管理页面中的客户端 ID 和客户端 secret
  5. 在 Red Hat build of Keycloak 中,将 Client ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Client secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.4. GitLab

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 GitLab

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,添加新的 GitLab 应用

    1. 使用剪贴板中的 Redirect URI 作为 Redirect URI
    2. 在保存应用程序时,请注意 Application IDSecret
  5. 在 Red Hat build of Keycloak 中,将 Application ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.5. Google

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Google

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,打开 Google Cloud Platform 控制台
  5. 在 Google 应用的 Google 仪表板中,在左侧的 Navigation 菜单中将鼠标悬停在 API & Services 上,然后点击 OAuth consent 屏幕 选项。创建同意屏幕,确保同意屏幕的用户类型是 External
  6. 在 Google 仪表板中:

    1. Credentials 菜单。
    2. 单击 CREATE CREDENTIALS - OAuth Client ID
    3. Application type 列表中,选择 Web application
    4. 使用剪贴板中的 Redirect URI 作为 Authorized 重定向 URI
    5. Create
    6. 记录 您的客户端 ID您的客户端 secret
  7. 在 Red Hat build of Keycloak 中,将您的 客户端 ID 的值粘贴到 Client ID 字段中。
  8. 在 Red Hat build of Keycloak 中,将您的 Client secret 的值粘贴到 Client Secret 字段中。
  9. 添加
  10. Default Scopes 字段中输入所需的范围。默认情况下,Red Hat build of Keycloak 使用以下范围: openid profile email。有关 Google 范围列表,请参阅 OAuth Playground
  11. 要限制对 GSuite 机构成员的访问,请在 Hosted Domain 字段中输入 G Suite 域。
  12. 点击 Save

9.4.6. Instagram

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Instagram

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,打开 Developers 的 Meta

    1. 单击 My Apps
    2. 选择 Create App

      添加用例

      Add a use case

    3. 选择 其他

      选择应用程序类型

      Select an app type

    4. 选择 Consumer

      创建应用程序

      Create an app

    5. 填写所有必填字段。
    6. Create app。然后 meta 会进入仪表板。
    7. 在导航面板中,选择 App settings - Basic
    8. 在页面底部选择 + Add Platform
    9. 单击 [Website]
    10. 输入您的站点的 URL。

      添加产品

      Add Product

    11. 从菜单中选择 Dashboard
    12. Instagram Basic Display 框中点 Set Up
    13. 单击 Create New App

      创建新的 Instagram 应用程序 ID

      Create a New Instagram App ID

    14. Display name 字段中输入值。

      设置应用程序

      Setup the App

    15. 将红帽构建的 Keycloak 中的 重定向 URL 粘贴到 Valid OAuth Redirect URIs 字段中。
    16. 将红帽构建的 Keycloak 中的 Redirect URL 粘贴到 Deauthorize Callback URL 字段中。
    17. 将红帽构建的 Keycloak 中的 重定向 URL 粘贴到 Data Deletion Request URL 字段中。
    18. Instagram App Secret 字段中的 Show
    19. 请注意 Instagram App IDInstagram App Secret
    20. App Review - Requests
    21. 按照屏幕上的说明进行操作。
  5. 在 Red Hat build of Keycloak 中,将 Instagram App ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Instagram App Secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.7. LinkedIn

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 LinkedIn

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在一个单独的浏览器选项卡中,在 LinkedIn 开发人员门户中创建应用程序。https://developer.linkedin.com

    1. 创建应用程序后,点 Auth 选项卡。
    2. Authorized redirect URLs for your app 字段中输入 Redirect URI 的值。
    3. 记录 您的客户端 ID您的客户端 Secret
    4. 单击 Products 选项卡,以及对 带有 OpenID Connect 产品的 LinkedIn 的 Sign In 的 Request 访问权限
  5. 在 Red Hat build of Keycloak 中,将 Client ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Client Secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.8. Microsoft

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Microsoft

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,在 Microsoft Azure 上注册应用程序

    1. 在 Redirect URI 部分中,选择 Web 作为平台,并将 Redirect URI 的值粘贴到字段中。
    2. App registrations 下找到应用程序,并在 Certificates & secrets 部分添加新的客户端 secret。
    3. 请注意所创建的 secret 的 Value
    4. 请注意 Overview 部分中的 应用程序(客户端)ID
  5. 在 Red Hat build of Keycloak 中,将 Application (client) ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.9. OpenShift 3

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Openshift v3

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 使用 oc 命令行工具注册您的客户端。

    $ oc create -f <(echo '
    kind: OAuthClient
    apiVersion: v1
    metadata:
     name: kc-client 
    1
    
    secret: "..." 
    2
    
    redirectURIs:
     - "http://www.example.com/" 
    3
    
    grantMethod: prompt 
    4
    
    ')
    Copy to Clipboard Toggle word wrap
1
OAuth 客户端 的名称。在向 <openshift_master> /oauth/ authorize 和 <openshift_master> / oauth/ token 发出请求时,传递为 client_ id request 参数。
2
用于 client_ secret 请求参数的 Keycloak 的 secret Red Hat 构建。
3
对 < openshift_master>/oauth/authorize 和 < openshift_master>/oauth/token 的请求中指定的 redirect_uri 参数必须等于 redirectURIs 中的一个 URI (或以前缀为前缀)。您可以从身份提供程序屏幕中的 Redirect URI 字段获取它
4
Keycloak 的 grantMethod 红帽构建用来决定当此客户端请求令牌,但没有授予用户访问权限时的操作。
  1. 在 Red Hat build of Keycloak 中,将 Client ID 的值粘贴到 Client ID 字段中。
  2. 在 Red Hat build of Keycloak 中,将 Client Secret 的值粘贴到 Client Secret 字段中。
  3. 点击 Add

9.4.10. OpenShift 4

先决条件

  1. 存储在红帽构建的 Keycloak Truststore 中的 OpenShift 4 实例的证书。
  2. 配置了 Keycloak 服务器的红帽构建以使用信任存储。如需更多信息 ,请参阅配置信任存储章节

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Openshift v4
  3. 输入 Client IDClient Secret,然后在 Base URL 字段中输入 OpenShift 4 实例的 API URL。另外,您可以将 Redirect URI 复制到您的剪贴板。

    添加身份提供程序

    Add Identity Provider

  4. 通过 OpenShift 4 Console (Home API Explorer OAuth Client Instances)注册您的客户端,或使用 oc 命令行工具注册您的客户端。

    $ oc create -f <(echo '
    kind: OAuthClient
    apiVersion: oauth.openshift.io/v1
    metadata:
     name: kc-client 
    1
    
    secret: "..." 
    2
    
    redirectURIs:
     - "<here you can paste the Redirect URI that you copied in the previous step>" 
    3
    
    grantMethod: prompt 
    4
    
    ')
    Copy to Clipboard Toggle word wrap
1
OAuth 客户端 的名称。在向 <openshift_master> /oauth/ authorize 和 <openshift_master> / oauth/ token 发出请求时,传递为 client_ id request 参数。name 参数在 OAuthClient 对象中必须相同,红帽构建的 Keycloak 配置。
2
Keycloak 的 secret Red Hat build 使用作为 client_secret 请求参数。
3
对 < openshift_master>/oauth/authorize 和 < openshift_master>/oauth/token 的请求中指定的 redirect_uri 参数必须等于 redirectURIs 中的一个 URI (或以前缀为前缀)。正确配置它的最简单方法是,将其从 Keycloak OpenShift 4 身份提供程序配置页面(Redirect URI 字段)的 Red Hat build 中复制。
4
Keycloak 的 grantMethod 红帽构建用来决定当此客户端请求令牌,但没有授予用户访问权限时的操作。

在最后,您应该在红帽构建的 Keycloak 实例的登录页面上看到 OpenShift 4 身份提供程序。点击它后,您应该重定向到 OpenShift 4 登录页面。

结果

Result

如需更多信息,请参阅官方 OpenShift 文档

9.4.11. PayPal

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 PayPal

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,打开 PayPal Developer 应用程序区域

    1. Create App 创建 PayPal 应用程序。
    2. 请注意 客户端 ID 和客户端 Secret。单击 Show 链接,以查看该机密。
    3. 确保选中 带有 PayPal 的 Log in
    4. 在 Log in with PayPal 下,单击 Advanced Settings
    5. 将 returned URL 字段的值设置为 来自红帽构建的 Keycloak 的 Redirect URI 的值。请注意,URL 不包含 localhost。如果要在本地使用红帽构建的 Keycloak,请将 返回 URL 中的 localhost 替换为 127.0.0.1,然后在浏览器中使用 127.0.0.1 访问 Red Hat build of Keycloak,而不是 localhost
    6. 确保选中 Full NameEmail 字段。
    7. 单击 Save,然后 Save Changes
  5. 在 Red Hat build of Keycloak 中,将 Client ID 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Secret key 1 的值粘贴到 Client Secret 字段中。
  7. 点击 Add

9.4.12. 堆栈溢出

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 Stack Overflow

    添加身份提供程序

    Add Identity Provider

  3. 在单独的浏览器选项卡中,在 Stack Apps 上登录注册您的应用程序

    注册应用程序

    Register Application

    1. Application Name 字段中输入应用程序名称。
    2. OAuth Domain 字段中输入 OAuth 域。
    3. Register your Application

      设置

      Settings

  4. 注意 Client IdClient SecretKey
  5. 在 Red Hat build of Keycloak 中,将 Client Id 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 Client Secret 的值粘贴到 Client Secret 字段中。
  7. 在 Red Hat build of Keycloak 中,将 Key 的值粘贴到 Key 字段中。
  8. 点击 Add

9.4.13. Twitter

先决条件

  1. OBC 开发人员帐户。

流程

  1. 在菜单中,单击 Identity Providers
  2. Add provider 列表中,选择 OBC

    添加身份提供程序

    Add Identity Provider

  3. Redirect URI 的值复制到您的剪贴板中。
  4. 在单独的浏览器选项卡中,在 1/1 Application Management 中创建一个应用程序

    1. 输入 App name 并点 Next
    2. 请注意 API KeyAPI Key Secret 的值,然后点 App settings
    3. User authentication settings 部分中,点 Set up 按钮。
    4. 选择 Web App 作为 App 的 Type
    5. Redirect URL 的值粘贴到 Callback URI / Redirect URL 字段中。
    6. Website URL 的值可以是除 localhost 外的任何有效 URL。
    7. 单击 Save,然后单击 Done
  5. 在 Red Hat build of Keycloak 中,将 API Key 的值粘贴到 Client ID 字段中。
  6. 在 Red Hat build of Keycloak 中,将 API Key Secret 的值粘贴到 Client Secret 字段中。
  7. 点击 Add
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat