From a5a382b8b16e0ac822640dcadfebf5254b15b511 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 19 Jan 2017 11:48:27 -0800 Subject: [PATCH] Set AccessTokenConverter if available Fixes gh-7091 --- .../OAuth2AuthorizationServerConfiguration.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java index 3ac33cdce81..7ddd2b219c9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/authserver/OAuth2AuthorizationServerConfiguration.java @@ -46,6 +46,7 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.E import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; import org.springframework.security.oauth2.provider.client.BaseClientDetails; +import org.springframework.security.oauth2.provider.token.AccessTokenConverter; import org.springframework.security.oauth2.provider.token.TokenStore; /** @@ -74,15 +75,19 @@ public class OAuth2AuthorizationServerConfiguration private final TokenStore tokenStore; + private final AccessTokenConverter tokenConverter; + private final AuthorizationServerProperties properties; public OAuth2AuthorizationServerConfiguration(BaseClientDetails details, AuthenticationManager authenticationManager, ObjectProvider tokenStore, + ObjectProvider tokenConverter, AuthorizationServerProperties properties) { this.details = details; this.authenticationManager = authenticationManager; this.tokenStore = tokenStore.getIfAvailable(); + this.tokenConverter = tokenConverter.getIfAvailable(); this.properties = properties; } @@ -120,6 +125,9 @@ public class OAuth2AuthorizationServerConfiguration @Override public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { + if (this.tokenConverter != null) { + endpoints.accessTokenConverter(this.tokenConverter); + } if (this.tokenStore != null) { endpoints.tokenStore(this.tokenStore); }