Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
39ec335d
Commit
39ec335d
authored
Jul 17, 2017
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
eb4fc16e
6381b887
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
4 deletions
+50
-4
ResourceServerTokenServicesConfiguration.java
...h2/resource/ResourceServerTokenServicesConfiguration.java
+6
-4
ResourceServerTokenServicesConfigurationTests.java
...source/ResourceServerTokenServicesConfigurationTests.java
+44
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfiguration.java
View file @
39ec335d
...
@@ -222,13 +222,14 @@ public class ResourceServerTokenServicesConfiguration {
...
@@ -222,13 +222,14 @@ public class ResourceServerTokenServicesConfiguration {
@Bean
@Bean
@ConditionalOnMissingBean
(
ResourceServerTokenServices
.
class
)
@ConditionalOnMissingBean
(
ResourceServerTokenServices
.
class
)
public
DefaultTokenServices
jwkTokenServices
()
{
public
DefaultTokenServices
jwkTokenServices
(
TokenStore
jwkTokenStore
)
{
DefaultTokenServices
services
=
new
DefaultTokenServices
();
DefaultTokenServices
services
=
new
DefaultTokenServices
();
services
.
setTokenStore
(
jwkTokenStore
()
);
services
.
setTokenStore
(
jwkTokenStore
);
return
services
;
return
services
;
}
}
@Bean
@Bean
@ConditionalOnMissingBean
(
TokenStore
.
class
)
public
TokenStore
jwkTokenStore
()
{
public
TokenStore
jwkTokenStore
()
{
return
new
JwkTokenStore
(
this
.
resource
.
getJwk
().
getKeySetUri
());
return
new
JwkTokenStore
(
this
.
resource
.
getJwk
().
getKeySetUri
());
}
}
...
@@ -254,13 +255,14 @@ public class ResourceServerTokenServicesConfiguration {
...
@@ -254,13 +255,14 @@ public class ResourceServerTokenServicesConfiguration {
@Bean
@Bean
@ConditionalOnMissingBean
(
ResourceServerTokenServices
.
class
)
@ConditionalOnMissingBean
(
ResourceServerTokenServices
.
class
)
public
DefaultTokenServices
jwtTokenServices
()
{
public
DefaultTokenServices
jwtTokenServices
(
TokenStore
jwtTokenStore
)
{
DefaultTokenServices
services
=
new
DefaultTokenServices
();
DefaultTokenServices
services
=
new
DefaultTokenServices
();
services
.
setTokenStore
(
jwtTokenStore
()
);
services
.
setTokenStore
(
jwtTokenStore
);
return
services
;
return
services
;
}
}
@Bean
@Bean
@ConditionalOnMissingBean
(
TokenStore
.
class
)
public
TokenStore
jwtTokenStore
()
{
public
TokenStore
jwtTokenStore
()
{
return
new
JwtTokenStore
(
jwtTokenEnhancer
());
return
new
JwtTokenStore
(
jwtTokenEnhancer
());
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/ResourceServerTokenServicesConfigurationTests.java
View file @
39ec335d
...
@@ -58,7 +58,10 @@ import org.springframework.security.oauth2.client.OAuth2RestTemplate;
...
@@ -58,7 +58,10 @@ import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import
org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails
;
import
org.springframework.security.oauth2.client.token.grant.code.AuthorizationCodeResourceDetails
;
import
org.springframework.security.oauth2.provider.token.DefaultTokenServices
;
import
org.springframework.security.oauth2.provider.token.DefaultTokenServices
;
import
org.springframework.security.oauth2.provider.token.RemoteTokenServices
;
import
org.springframework.security.oauth2.provider.token.RemoteTokenServices
;
import
org.springframework.security.oauth2.provider.token.TokenStore
;
import
org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter
;
import
org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter
;
import
org.springframework.security.oauth2.provider.token.store.JwtTokenStore
;
import
org.springframework.security.oauth2.provider.token.store.jwk.JwkTokenStore
;
import
org.springframework.social.connect.ConnectionFactoryLocator
;
import
org.springframework.social.connect.ConnectionFactoryLocator
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
...
@@ -261,6 +264,27 @@ public class ResourceServerTokenServicesConfigurationTests {
...
@@ -261,6 +264,27 @@ public class ResourceServerTokenServicesConfigurationTests {
assertThat
(
this
.
context
.
getBeansOfType
(
JwtAccessTokenConverter
.
class
)).
hasSize
(
1
);
assertThat
(
this
.
context
.
getBeansOfType
(
JwtAccessTokenConverter
.
class
)).
hasSize
(
1
);
}
}
@Test
public
void
jwkTokenStoreShouldBeConditionalOnMissingBean
()
throws
Exception
{
TestPropertyValues
.
of
(
"security.oauth2.resource.jwk.key-set-uri=http://my-auth-server/token_keys"
)
.
applyTo
(
this
.
environment
);
this
.
context
=
new
SpringApplicationBuilder
(
JwkTokenStoreConfiguration
.
class
,
ResourceConfiguration
.
class
)
.
environment
(
this
.
environment
).
web
(
false
).
run
();
assertThat
(
this
.
context
.
getBeansOfType
(
JwkTokenStore
.
class
)).
hasSize
(
1
);
}
@Test
public
void
jwtTokenStoreShouldBeConditionalOnMissingBean
()
throws
Exception
{
TestPropertyValues
.
of
(
"security.oauth2.resource.jwt.keyValue="
+
PUBLIC_KEY
)
.
applyTo
(
this
.
environment
);
this
.
context
=
new
SpringApplicationBuilder
(
JwtTokenStoreConfiguration
.
class
,
ResourceConfiguration
.
class
)
.
environment
(
this
.
environment
).
web
(
false
).
run
();
assertThat
(
this
.
context
.
getBeansOfType
(
JwtTokenStore
.
class
)).
hasSize
(
1
);
}
@Configuration
@Configuration
@Import
({
ResourceServerTokenServicesConfiguration
.
class
,
@Import
({
ResourceServerTokenServicesConfiguration
.
class
,
ResourceServerPropertiesConfiguration
.
class
,
ResourceServerPropertiesConfiguration
.
class
,
...
@@ -385,6 +409,26 @@ public class ResourceServerTokenServicesConfigurationTests {
...
@@ -385,6 +409,26 @@ public class ResourceServerTokenServicesConfigurationTests {
}
}
@Configuration
static
class
JwtTokenStoreConfiguration
{
@Bean
public
TokenStore
tokenStore
(
JwtAccessTokenConverter
jwtTokenEnhancer
)
{
return
new
JwtTokenStore
(
jwtTokenEnhancer
);
}
}
@Configuration
static
class
JwkTokenStoreConfiguration
{
@Bean
public
TokenStore
tokenStore
()
{
return
new
JwkTokenStore
(
"http://my.key-set.uri"
);
}
}
private
static
class
MockRestCallCustomizer
private
static
class
MockRestCallCustomizer
implements
JwtAccessTokenConverterRestTemplateCustomizer
{
implements
JwtAccessTokenConverterRestTemplateCustomizer
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment