apolloconfig / apolloconfig/apollo

使用oauth2登录时,username 是openid

Abierto
#4,746 3 comentarios 3 reacciones 0 asignados Ver en GitHub
area/portal help wanted need investigation
Lenguaje dominante
Java
Estrellas
29.8k
Forks
10.2k
Merge medio
4 d 7 h
PR fusionados (30 d)
4

Descripción

- [x] 我已经检查过[discussions](https://github.com/ctripcorp/apollo/discussions)
- [x] 我已经搜索过[issues](https://github.com/ctripcorp/apollo/issues)
- [x] 我已经仔细检查过[FAQ](https://www.apolloconfig.com/#/zh/faq/common-issues-in-deployment-and-development-phase)

**描述bug**

使用oauth2登录时,username 是openid,在授权的页面展示也是openid,对用户不友好
![image](https://user-images.githubusercontent.com/17396943/221466277-a8b11655-9434-4f05-8e3f-da86b174ce0b.png)

**复现**

```
application-oidc.yaml: |
server:
forward-headers-strategy: framework
spring:
security:
oidc:
user-display-name-claim-name: "username"
jwt-user-display-name-claim-name: "username"
oauth2:
client:
provider:
# provider-name 是 oidc 提供者的名称, 任意字符均可, registration 的配置需要用到这个名称
authing:
# 必须是 https, oidc 的 issuer-uri, 和 jwt 的 issuer-uri 一致的话直接引用即可, 也可以单独设置
issuer-uri: https://xxx.com/oidc
registration:
# registration-name 是 oidc 客户端的名称, 任意字符均可, oidc 登录必须配置一个 authorization_code 类型的 registration
authing:
# oidc 登录必须配置一个 authorization_code 类型的 registration
authorization-grant-type: authorization_code
client-authentication-method: basic
# client-id 是在 oidc 提供者处配置的客户端ID, 用于登录 provider
client-id:
# provider 的名称, 需要和上面配置的 provider 名称保持一致
provider: authing
# openid 为 oidc 登录的必须 scope, 此处可以添加其它自定义的 scope
scope:
- openid
- Username
- preferred_username
- profile
- email
# client-secret 是在 oidc 提供者处配置的客户端密码, 用于登录 provider
# 从安全角度考虑更推荐使用环境变量来配置, 环境变量的命名规则为: 将配置项的 key 当中的 点(.)、横杠(-)替换为下划线(_), 然后将所有字母改为大写, spring boot 会自动处理符合此规则的环境变量
# 例如 spring.security.oauth2.client.registration.registration-name.client-secret -> SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_NAME_VDISK_CLIENT_SECRET (REGISTRATION_NAME 可以替换为自定义的 oidc 客户端的名称)
client-secret:
```

**期望**

可以自定义claim-name 作为username的对应字段

**截图**

如果可以,附上截图来描述你的问题

### 额外的细节和日志

- 版本:2.1.0
- 错误日志
- 配置:
- 平台和操作系统

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.