GitLab OpenID id_token 缺少用户配置文件声明

问题描述 投票:0回答:1

我正在尝试使用 GitLab(自托管 CE 版)作为 OpenID 身份验证提供商。我正在关注 https://docs.gitlab.com/ee/integration/openid_connect_provider.html#enabling-openid-connect-for-oauth-applicationshttps://docs.gitlab.com/ce/api/ oauth2.html#gitlab-as-an-oauth2-provider 手动验证流程。

我已经创建了 GitLab 应用程序来生成客户端 ID 和密钥。我也可以通过点击

https://gitlab.example.com/oauth/authorize?client_id=APP_ID&redirect_uri=REDIRECT_URI&response_type=code&state=YOUR_UNIQUE_STATE_HASH&scope=openid

成功获取授权码

我还可以通过调用 POST 来检索 id_token(JWT)

https://gitlab.example.com/oauth/token?client_id=ID&client_secret=SECRET&code=CODE&grant_type=authorization_code&redirect_uri=http://localhost

但是当我在 jwt.io 上解码

id_token
时,我无法看到文档链接上提到的所有用户配置文件声明。以下是我得到的 JWT 有效负载示例

{
  "iss": "https://gitlab.example.com",
  “子”:“768d4eeae122ca6655c9127487d9c4cd85b079796d35d33753b3c15b93486044”,
  “aud”:“c3be56f955c74f0601683654df61ed3f74774902e2fb6da7ce05415b8a30e1d7”,
  “经验”:1521463699,
  “iat”:1521463579,
  “验证时间”:1521456265
}

任何人都可以帮助我如何在

claims
中获取各种用户个人资料属性,例如电子邮件、姓名等?

我使用的是 GitLab 社区版 10.5.0 34d5766

oauth gitlab openid claims
1个回答
0
投票

此用例不再适用于 GitLab 16.4(2023 年 9 月):

全局设置id_token并消除单个作业的配置

在 GitLab 15.9 中,我们宣布弃用旧版本的 JSON Web 令牌,转而使用

id_token

不幸的是,工作必须单独修改以适应这种变化。

为了能够平滑过渡到

id_token
,从 GitLab 16.4 开始,您可以在
id_tokens
中将
.gitlab-ci.yml
设置为全局默认值。
此功能会自动为每个作业设置
id_token
配置。
使用 OpenID Connect (OIDC) 身份验证的作业不再需要您设置单独的
id_token

使用

id_token
和 OIDC 向第三方服务进行身份验证
所需的
aud
子关键字用于配置 JWT 的
aud
声明。

请参阅文档问题

© www.soinside.com 2019 - 2024. All rights reserved.