{{< details >}}
- Tier: 基础版,专业版,旗舰版
- Offering: 私有化部署
{{< /details >}}
要启用 JWT OmniAuth 提供者,您必须使用 JWT 注册您的应用。JWT 为您提供了一个秘密密钥供您使用。
-
在您的极狐GitLab 服务器上,打开配置文件。
对于 Linux 软件包安装:
sudo editor /etc/gitlab/gitlab.rb
对于自编译安装:
cd /home/git/gitlab sudo -u git -H editor config/gitlab.yml
- 配置常见设置,添加
jwt
作为单点登录提供者。这为没有现有极狐GitLab 账户的用户启用即时账户配置。 -
添加提供者配置。
对于 Linux 软件包安装:
gitlab_rails['omniauth_providers'] = [ { name: "jwt", label: "Provider name", # optional label for login button, defaults to "Jwt" args: { secret: "YOUR_APP_SECRET", algorithm: "HS256", # Supported algorithms: "RS256", "RS384", "RS512", "ES256", "ES384", "ES512", "HS256", "HS384", "HS512" uid_claim: "email", required_claims: ["name", "email"], info_map: { name: "name", email: "email" }, auth_url: "https://example.com/", valid_within: 3600 # 1 hour } } ]
对于自编译安装:
- { name: 'jwt', label: 'Provider name', # optional label for login button, defaults to "Jwt" args: { secret: 'YOUR_APP_SECRET', algorithm: 'HS256', # Supported algorithms: 'RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512', 'HS256', 'HS384', 'HS512' uid_claim: 'email', required_claims: ['name', 'email'], info_map: { name: 'name', email: 'email' }, auth_url: 'https://example.com/', valid_within: 3600 # 1 hour } }
{{< alert type=”note” >}}
有关每个配置选项的更多信息,请参阅OmniAuth JWT 使用文档。
{{< /alert >}}
{{< alert type=”warning” >}}
错误地配置这些设置可能导致实例不安全。
{{< /alert >}}
- 将
YOUR_APP_SECRET
更改为客户端密钥,并将auth_url
设置为您的重定向 URL。 - 保存配置文件。
- 为了使更改生效,如果您:
- 使用 Linux 软件包安装极狐GitLab,重新配置极狐GitLab。
- 自编译安装极狐GitLab,重启极狐GitLab。
在登录页面下方,应该现在有一个 JWT 图标在常规登录表单下方。选择图标以开始认证过程。JWT 询问用户登录并授权极狐GitLab 应用程序。如果一切顺利,用户将被重定向到极狐GitLab 并登录。