【问题标题】:Spring boot 2.0.0.M6 OAuth2 web application client. No @EnableOauth2Sso anymore; how to replace?Spring Boot 2.0.0.M6 OAuth2 Web 应用程序客户端。不再有@EnableOauth2Sso;如何更换?
【发布时间】:2018-04-25 01:45:42
【问题描述】:

我已经在 Spring 5 和 Spring boot 2.0.0.M3 中构建了一个身份验证服务和 Web 应用程序,我现在正在尝试将其移植到 Spring boot 2.0.0.M6

我注意到@EnableOauth2Ssospring-boot-autoconfigure 中不再可用;我曾使用此注释以spring boot 2.0.0.M3 方式配置我的Web 应用程序。我已经查看了Spring 上的示例,用于使用@EnableOAuth2Client 配置Oauth2 Client,但在UserInfoTokenServices 等示例中使用的配置对象似乎也不再存在。

如何为OAuth2 in spring boot versions >= 2.0.0.M6 配置我的客户端网络应用程序?

【问题讨论】:

  • 我现在将 Spring-boot 2.0.0.M6 应用程序配置为具有 spring.security.oauth2.client.registration.[client-id] 和 spring.security.oauth2.client.provider。 [provider-id] 在它的应用程序 yaml 中声明了一个 @EnableOAuth2Client。 Web 应用程序现在重定向到授权服务,用户能够在授权服务器上进行身份验证,并再次重定向到 Web 应用程序。但是客户端的授权仍然失败,因为客户端提供者配置中的 userNameAttribute 没有被拾取。
  • 在 ClientRegistration 中为提供者操作 userNameAttribute 时,授权似乎已超过但在返回时再次通过过滤器链时仍然失败。
  • 在 OAuth2ClientPropertiesRegistrationAdapter#getBuilder(Builder builder, Provider provider) 我没有看到 userNameAttributeName 属性集!? private static Builder getBuilder(Builder builder, Provider provider) { copyIfNotNull(provider::getAuthorizationUri, builder::authorizationUri); copyIfNotNull(provider::getTokenUri, builder::tokenUri); copyIfNotNull(provider::getUserInfoUri, builder::userInfoUri); copyIfNotNull(provider::getJwkSetUri, builder::jwkSetUri); return builder; }

标签: spring spring-boot spring-security-oauth2


【解决方案1】:

The existing GitHub issue on spring boot,已经详细说明了,我最终被引导到了 2.0.0 版本中的注释位置。它已被移至一个对 2.0.0 版本工件全新的项目。

要解决此问题并迁移您的项目,请将工件 org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure 添加到您的依赖项管理配置中:

<dependency>
  <groupId>org.springframework.security.oauth.boot</groupId>
  <artifactId>spring-security-oauth2-autoconfigure</artifactId>
  <version>2.0.0.RELEASE</version>
</dependency>

【讨论】:

  • 在建议之前,我无法在原始 GitHub 讨论位置澄清这一点或以其他方式提供此答案,因为项目维护者选择在回答问题后立即锁定对话
【解决方案2】:

此问题现已在 GitHub 中进行跟踪,并在 2.0.0 SNAPSHOT 中可用,并针对 RC1 版本。

在此处查看问题:https://github.com/spring-projects/spring-boot/pull/10672

【讨论】:

    【解决方案3】:

    看起来@EnableOauth2Sso 注释已移至此处:

    compile group: 'org.springframework.security.oauth.boot', name: 'spring-security-oauth2-autoconfigure', version: 2.0.0.RELEASE

    【讨论】:

      猜你喜欢
      • 2018-05-07
      • 2018-04-22
      • 2018-08-13
      • 2016-09-28
      • 2018-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-11
      相关资源
      最近更新 更多