【问题标题】:Spring Security and OIDC IllegalArgumentException: Missing attribute when attribute is in id tokenSpring Security 和 OIDC IllegalArgumentException:属性在 id 令牌中时缺少属性
【发布时间】:2021-07-26 22:23:25
【问题描述】:

我正在尝试使用 Azure AD 配置 Spring Security (5.4.5) OIDC 身份验证 我想使用 preferred_username 作为用户名属性 我将 profileopenid 设置为范围

目前它失败了:

原因:java.lang.IllegalArgumentException:缺少属性 'preferred_username' 在属性中 org.springframework.security.oauth2.core.user.DefaultOAuth2User.(DefaultOAuth2User.java:72) 在 org.springframework.security.oauth2.client.userinfo.DefaultOAuth2UserService.loadUser(DefaultOAuth2UserService.java:116) 在 org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService.loadUser(OidcUserService.java:109)

preferred_username 在 id 令牌属性中。调试代码失败,因为首选用户名不在 userInfo 端点返回的属性中,但这个失败对我来说似乎是错误的。如果我设法通过 DefaultOAuth2User 实例化(通过在 userInfo 中提供一个属性),我稍后会在代码中看到 org.springframework.security.oauth2.client.oidc.userinfo.OidcUserService 返回的 org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser 正在查看 id 令牌和 userInfo 属性,所以prefered_username 会在那里成功。

对我来说这似乎是一个弹簧安全漏洞,我是对还是错?

【问题讨论】:

    标签: spring-security spring-security-oauth2


    【解决方案1】:

    更深入地查看代码,它肯定看起来像一个错误,所以我提出了https://github.com/spring-projects/spring-security/issues/9722

    【讨论】:

      猜你喜欢
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 2021-01-17
      • 2011-04-13
      • 2019-08-05
      • 2018-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多