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
fc4340c5
Commit
fc4340c5
authored
Aug 23, 2018
by
Madhura Bhave
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename OAuth2 resource server properties
Closes gh-14165
parent
26353a8f
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
27 additions
and
41 deletions
+27
-41
OAuth2ResourceServerProperties.java
...urity/oauth2/resource/OAuth2ResourceServerProperties.java
+6
-16
ReactiveOAuth2ResourceServerJwkConfiguration.java
...eactive/ReactiveOAuth2ResourceServerJwkConfiguration.java
+2
-3
OAuth2ResourceServerJwkConfiguration.java
...esource/servlet/OAuth2ResourceServerJwkConfiguration.java
+2
-3
ReactiveOAuth2ResourceServerAutoConfigurationTests.java
...e/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
+4
-4
OAuth2ResourceServerAutoConfigurationTests.java
...e/servlet/OAuth2ResourceServerAutoConfigurationTests.java
+3
-3
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-1
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+1
-1
application.yml
...oauth2-resource-server/src/main/resources/application.yml
+2
-3
SampleOauth2ResourceServerApplicationTests.java
.../resource/SampleOauth2ResourceServerApplicationTests.java
+2
-2
application.yml
...oauth2-resource-server/src/main/resources/application.yml
+2
-3
SampleReactiveOAuth2ResourceServerApplicationTests.java
...e/SampleReactiveOAuth2ResourceServerApplicationTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java
View file @
fc4340c5
...
@@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
...
@@ -23,7 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
* @author Madhura Bhave
* @author Madhura Bhave
* @since 2.1.0
* @since 2.1.0
*/
*/
@ConfigurationProperties
(
prefix
=
"spring.security.oauth2.resource"
)
@ConfigurationProperties
(
prefix
=
"spring.security.oauth2.resource
server
"
)
public
class
OAuth2ResourceServerProperties
{
public
class
OAuth2ResourceServerProperties
{
private
final
Jwt
jwt
=
new
Jwt
();
private
final
Jwt
jwt
=
new
Jwt
();
...
@@ -34,27 +34,17 @@ public class OAuth2ResourceServerProperties {
...
@@ -34,27 +34,17 @@ public class OAuth2ResourceServerProperties {
public
static
class
Jwt
{
public
static
class
Jwt
{
private
final
Jwk
jwk
=
new
Jwk
();
public
Jwk
getJwk
()
{
return
this
.
jwk
;
}
}
public
static
class
Jwk
{
/**
/**
* JSON Web Key URI to use to verify the JWT token.
* JSON Web Key URI to use to verify the JWT token.
*/
*/
private
String
s
etUri
;
private
String
jwkS
etUri
;
public
String
getSetUri
()
{
public
String
get
Jwk
SetUri
()
{
return
this
.
s
etUri
;
return
this
.
jwkS
etUri
;
}
}
public
void
set
SetUri
(
String
s
etUri
)
{
public
void
set
JwkSetUri
(
String
jwkS
etUri
)
{
this
.
setUri
=
s
etUri
;
this
.
jwkSetUri
=
jwkS
etUri
;
}
}
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerJwkConfiguration.java
View file @
fc4340c5
...
@@ -39,11 +39,10 @@ class ReactiveOAuth2ResourceServerJwkConfiguration {
...
@@ -39,11 +39,10 @@ class ReactiveOAuth2ResourceServerJwkConfiguration {
}
}
@Bean
@Bean
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
)
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
)
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
ReactiveJwtDecoder
jwtDecoder
()
{
public
ReactiveJwtDecoder
jwtDecoder
()
{
return
new
NimbusReactiveJwtDecoder
(
return
new
NimbusReactiveJwtDecoder
(
this
.
properties
.
getJwt
().
getJwkSetUri
());
this
.
properties
.
getJwt
().
getJwk
().
getSetUri
());
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwkConfiguration.java
View file @
fc4340c5
...
@@ -38,11 +38,10 @@ class OAuth2ResourceServerJwkConfiguration {
...
@@ -38,11 +38,10 @@ class OAuth2ResourceServerJwkConfiguration {
}
}
@Bean
@Bean
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
)
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
)
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
JwtDecoder
jwtDecoder
()
{
public
JwtDecoder
jwtDecoder
()
{
return
new
NimbusJwtDecoderJwkSupport
(
return
new
NimbusJwtDecoderJwkSupport
(
this
.
properties
.
getJwt
().
getJwkSetUri
());
this
.
properties
.
getJwt
().
getJwk
().
getSetUri
());
}
}
}
}
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
View file @
fc4340c5
...
@@ -58,7 +58,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
...
@@ -58,7 +58,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
autoConfigurationShouldConfigureResourceServer
()
{
public
void
autoConfigurationShouldConfigureResourceServer
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
.
getBean
(
ReactiveJwtDecoder
.
class
))
assertThat
(
context
.
getBean
(
ReactiveJwtDecoder
.
class
))
.
isInstanceOf
(
NimbusReactiveJwtDecoder
.
class
);
.
isInstanceOf
(
NimbusReactiveJwtDecoder
.
class
);
...
@@ -75,7 +75,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
...
@@ -75,7 +75,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
jwtDecoderBeanIsConditionalOnMissingBean
()
{
public
void
jwtDecoderBeanIsConditionalOnMissingBean
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
run
((
this
::
assertFilterConfiguredWithJwtAuthenticationManager
));
.
run
((
this
::
assertFilterConfiguredWithJwtAuthenticationManager
));
}
}
...
@@ -83,7 +83,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
...
@@ -83,7 +83,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
autoConfigurationShouldBeConditionalOnBearerTokenAuthenticationTokenClass
()
{
public
void
autoConfigurationShouldBeConditionalOnBearerTokenAuthenticationTokenClass
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withClassLoader
(
.
withClassLoader
(
new
FilteredClassLoader
(
BearerTokenAuthenticationToken
.
class
))
new
FilteredClassLoader
(
BearerTokenAuthenticationToken
.
class
))
...
@@ -94,7 +94,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
...
@@ -94,7 +94,7 @@ public class ReactiveOAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
autoConfigurationWhenSecurityWebFilterChainConfigPresentShouldNotAddOne
()
{
public
void
autoConfigurationWhenSecurityWebFilterChainConfigPresentShouldNotAddOne
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
withUserConfiguration
(
SecurityWebFilterChainConfig
.
class
)
.
withUserConfiguration
(
SecurityWebFilterChainConfig
.
class
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
SecurityWebFilterChain
.
class
);
assertThat
(
context
).
hasSingleBean
(
SecurityWebFilterChain
.
class
);
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
View file @
fc4340c5
...
@@ -55,7 +55,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -55,7 +55,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
autoConfigurationShouldConfigureResourceServer
()
{
public
void
autoConfigurationShouldConfigureResourceServer
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
.
getBean
(
JwtDecoder
.
class
))
assertThat
(
context
.
getBean
(
JwtDecoder
.
class
))
.
isInstanceOf
(
NimbusJwtDecoderJwkSupport
.
class
);
.
isInstanceOf
(
NimbusJwtDecoderJwkSupport
.
class
);
...
@@ -72,7 +72,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -72,7 +72,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
jwtDecoderBeanIsConditionalOnMissingBean
()
{
public
void
jwtDecoderBeanIsConditionalOnMissingBean
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
run
((
context
)
->
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
());
.
run
((
context
)
->
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
());
}
}
...
@@ -80,7 +80,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -80,7 +80,7 @@ public class OAuth2ResourceServerAutoConfigurationTests {
@Test
@Test
public
void
autoConfigurationShouldBeConditionalOnJwtAuthenticationTokenClass
()
{
public
void
autoConfigurationShouldBeConditionalOnJwtAuthenticationTokenClass
()
{
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri=http://jwk-set-uri.com"
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withUserConfiguration
(
JwtDecoderConfig
.
class
)
.
withClassLoader
(
new
FilteredClassLoader
(
JwtAuthenticationToken
.
class
))
.
withClassLoader
(
new
FilteredClassLoader
(
JwtAuthenticationToken
.
class
))
.
run
((
context
)
->
assertThat
(
getBearerTokenFilter
(
context
)).
isNull
());
.
run
((
context
)
->
assertThat
(
getBearerTokenFilter
(
context
)).
isNull
());
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
fc4340c5
...
@@ -538,7 +538,7 @@ content into your application. Rather, pick only the properties that you need.
...
@@ -538,7 +538,7 @@ content into your application. Rather, pick only the properties that you need.
spring.security.oauth2.client.registration.*= # OAuth client registrations.
spring.security.oauth2.client.registration.*= # OAuth client registrations.
# SECURITY OAUTH2 RESOURCE SERVER ({sc-spring-boot-autoconfigure}/security/oauth2/resource/OAuth2ResourceServerProperties.{sc-ext}[OAuth2ResourceServerProperties])
# SECURITY OAUTH2 RESOURCE SERVER ({sc-spring-boot-autoconfigure}/security/oauth2/resource/OAuth2ResourceServerProperties.{sc-ext}[OAuth2ResourceServerProperties])
spring.security.oauth2.resource
.jwt.jwk.
set-uri= # JSON Web Key URI to use to verify the JWT token.
spring.security.oauth2.resource
server.jwt.jwk-
set-uri= # JSON Web Key URI to use to verify the JWT token.
# ----------------------------------------
# ----------------------------------------
# DATA PROPERTIES
# DATA PROPERTIES
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
fc4340c5
...
@@ -3324,7 +3324,7 @@ following example:
...
@@ -3324,7 +3324,7 @@ following example:
[source,properties,indent=0]
[source,properties,indent=0]
----
----
spring.security.oauth2.resource
.jwt.jwk.
set-uri=https://example.com/oauth2/default/v1/keys
spring.security.oauth2.resource
server.jwt.jwk-
set-uri=https://example.com/oauth2/default/v1/keys
----
----
The same properties are applicable for both servlet and reactive applications.
The same properties are applicable for both servlet and reactive applications.
...
...
spring-boot-samples/spring-boot-sample-oauth2-resource-server/src/main/resources/application.yml
View file @
fc4340c5
...
@@ -3,6 +3,5 @@ spring:
...
@@ -3,6 +3,5 @@ spring:
oauth2
:
oauth2
:
resource
:
resource
:
jwt
:
jwt
:
jwk
:
# To run the application, replace this with a valid JWK Set URI
# To run the application, replace this with a valid JWK Set URI
jwk-set-uri
:
https://example.com/oauth2/default/v1/keys
set-uri
:
https://example.com/oauth2/default/v1/keys
\ No newline at end of file
\ No newline at end of file
spring-boot-samples/spring-boot-sample-oauth2-resource-server/src/test/java/sample/oauth2/resource/SampleOauth2ResourceServerApplicationTests.java
View file @
fc4340c5
...
@@ -57,13 +57,13 @@ public class SampleOauth2ResourceServerApplicationTests {
...
@@ -57,13 +57,13 @@ public class SampleOauth2ResourceServerApplicationTests {
server
.
start
();
server
.
start
();
String
url
=
server
.
url
(
"/.well-known/jwks.json"
).
toString
();
String
url
=
server
.
url
(
"/.well-known/jwks.json"
).
toString
();
server
.
enqueue
(
mockResponse
());
server
.
enqueue
(
mockResponse
());
System
.
setProperty
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
,
url
);
System
.
setProperty
(
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
,
url
);
}
}
@AfterClass
@AfterClass
public
static
void
shutdown
()
throws
IOException
{
public
static
void
shutdown
()
throws
IOException
{
server
.
shutdown
();
server
.
shutdown
();
System
.
clearProperty
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
);
System
.
clearProperty
(
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
);
}
}
@Test
@Test
...
...
spring-boot-samples/spring-boot-sample-reactive-oauth2-resource-server/src/main/resources/application.yml
View file @
fc4340c5
spring
:
spring
:
security
:
security
:
oauth2
:
oauth2
:
resource
:
resource
server
:
jwt
:
jwt
:
jwk
:
# To run the application, replace this with a valid JWK Set URI
# To run the application, replace this with a valid JWK Set URI
set-uri
:
https://example.com/oauth2/default/v1/keys
jwk-set-uri
:
https://example.com/oauth2/default/v1/keys
\ No newline at end of file
\ No newline at end of file
spring-boot-samples/spring-boot-sample-reactive-oauth2-resource-server/src/test/java/sample/oauth2/resource/SampleReactiveOAuth2ResourceServerApplicationTests.java
View file @
fc4340c5
...
@@ -50,13 +50,13 @@ public class SampleReactiveOAuth2ResourceServerApplicationTests {
...
@@ -50,13 +50,13 @@ public class SampleReactiveOAuth2ResourceServerApplicationTests {
server
.
start
();
server
.
start
();
String
url
=
server
.
url
(
"/.well-known/jwks.json"
).
toString
();
String
url
=
server
.
url
(
"/.well-known/jwks.json"
).
toString
();
server
.
enqueue
(
mockResponse
());
server
.
enqueue
(
mockResponse
());
System
.
setProperty
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
,
url
);
System
.
setProperty
(
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
,
url
);
}
}
@AfterClass
@AfterClass
public
static
void
shutdown
()
throws
Exception
{
public
static
void
shutdown
()
throws
Exception
{
server
.
shutdown
();
server
.
shutdown
();
System
.
clearProperty
(
"spring.security.oauth2.resource
.jwt.jwk.
set-uri"
);
System
.
clearProperty
(
"spring.security.oauth2.resource
server.jwt.jwk-
set-uri"
);
}
}
@Test
@Test
...
...
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