【问题标题】:SpringBoot 1 vs 2 and Spring Oauth2- Password Grant and Client SecretSpringBoot 1 vs 2 和 Spring Oauth2- 密码授予和客户端密码
【发布时间】:2019-08-05 16:41:54
【问题描述】:

有人知道 SpringBoot 和 Spring Oauth2 中的版本控制是如何工作的吗? 当我更改 SpringBoot 和 Spring Oauth2 的版本时,我从获取有效访问和刷新令牌变为“未经授权”错误。我正在使用 spring-boot-starter-parent。 我进行了一些测试,它是 Spring Boot 版本;当我将版本从 1.. 更改为 2.. “/oauth/token” 将不再受到打击。 这是授权服务器的配置:

@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends 
AuthorizationServerConfigurerAdapter {
@Override
public void configure(ClientDetailsServiceConfigurer configurer) throws 
Exception {
configurer
    .inMemory()
    .withClient(CLIENT_ID)
    //.secret("secret")
    .authorizedGrantTypes(GRANT_TYPE_PASSWORD, REFRESH_TOKEN)
    .redirectUris("http://localhost:8080/")
    .scopes(SCOPE_READ)
    .accessTokenValiditySeconds(ACCESS_TOKEN_VALIDITY_SECONDS).
    refreshTokenValiditySeconds(REFRESH_TOKEN_VALIDITY_SECONDS);
    }
    ...
   }

【问题讨论】:

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


    【解决方案1】:

    当你从 SpringBoot 1 转到 2 时,

    • 您必须添加客户端密码才能使授权服务器正常工作。这就是 Spring Boot 的工作原理。
    • 如果您在 Spring Boot 1 中使用客户端密码,则不需要传递哈希,但在 Spring Boot 2 中您需要这样做:

      inMemory()
      .withClient(CLIENT_ID)
      .secret(passwordEncoder.encode("secret"))
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-11
      • 2017-10-08
      • 2015-05-20
      • 2017-01-04
      • 2016-06-17
      • 2015-11-09
      • 2015-06-25
      • 2013-08-24
      相关资源
      最近更新 更多