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
460fdaf5
Commit
460fdaf5
authored
Nov 10, 2018
by
artsiom
Committed by
Stephane Nicoll
Dec 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add configurable property for JWK encryption algorithm
See gh-15145
parent
5674a53d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
3 deletions
+37
-3
OAuth2ResourceServerProperties.java
...urity/oauth2/resource/OAuth2ResourceServerProperties.java
+13
-0
OAuth2ResourceServerJwkConfiguration.java
...esource/servlet/OAuth2ResourceServerJwkConfiguration.java
+2
-1
OAuth2ResourceServerAutoConfigurationTests.java
...e/servlet/OAuth2ResourceServerAutoConfigurationTests.java
+21
-2
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/OAuth2ResourceServerProperties.java
View file @
460fdaf5
...
@@ -40,6 +40,11 @@ public class OAuth2ResourceServerProperties {
...
@@ -40,6 +40,11 @@ public class OAuth2ResourceServerProperties {
*/
*/
private
String
jwkSetUri
;
private
String
jwkSetUri
;
/**
* JSON Web Algorithm used for verifying the digital signatures.
*/
private
String
jwsAlgorithm
=
"RS256"
;
/**
/**
* URI that an OpenID Connect Provider asserts as its Issuer Identifier.
* URI that an OpenID Connect Provider asserts as its Issuer Identifier.
*/
*/
...
@@ -53,6 +58,14 @@ public class OAuth2ResourceServerProperties {
...
@@ -53,6 +58,14 @@ public class OAuth2ResourceServerProperties {
this
.
jwkSetUri
=
jwkSetUri
;
this
.
jwkSetUri
=
jwkSetUri
;
}
}
public
String
getJwsAlgorithm
()
{
return
this
.
jwsAlgorithm
;
}
public
void
setJwsAlgorithm
(
String
jwsAlgorithm
)
{
this
.
jwsAlgorithm
=
jwsAlgorithm
;
}
public
String
getIssuerUri
()
{
public
String
getIssuerUri
()
{
return
this
.
issuerUri
;
return
this
.
issuerUri
;
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwkConfiguration.java
View file @
460fdaf5
...
@@ -46,7 +46,8 @@ class OAuth2ResourceServerJwkConfiguration {
...
@@ -46,7 +46,8 @@ class OAuth2ResourceServerJwkConfiguration {
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri"
)
@ConditionalOnProperty
(
name
=
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri"
)
@ConditionalOnMissingBean
@ConditionalOnMissingBean
public
JwtDecoder
jwtDecoderByJwkKeySetUri
()
{
public
JwtDecoder
jwtDecoderByJwkKeySetUri
()
{
return
new
NimbusJwtDecoderJwkSupport
(
this
.
properties
.
getJwt
().
getJwkSetUri
());
return
new
NimbusJwtDecoderJwkSupport
(
this
.
properties
.
getJwt
().
getJwkSetUri
(),
this
.
properties
.
getJwt
().
getJwsAlgorithm
());
}
}
@Bean
@Bean
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
View file @
460fdaf5
...
@@ -22,6 +22,7 @@ import java.util.Map;
...
@@ -22,6 +22,7 @@ import java.util.Map;
import
javax.servlet.Filter
;
import
javax.servlet.Filter
;
import
com.nimbusds.jose.JWSAlgorithm
;
import
okhttp3.mockwebserver.MockResponse
;
import
okhttp3.mockwebserver.MockResponse
;
import
okhttp3.mockwebserver.MockWebServer
;
import
okhttp3.mockwebserver.MockWebServer
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -78,8 +79,26 @@ public class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -78,8 +79,26 @@ public class OAuth2ResourceServerAutoConfigurationTests {
this
.
contextRunner
.
withPropertyValues
(
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://jwk-set-uri.com"
)
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://jwk-set-uri.com"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
assertThat
(
context
.
getBean
(
JwtDecoder
.
class
))
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
.
isInstanceOf
(
NimbusJwtDecoderJwkSupport
.
class
);
assertThat
(
jwtDecoder
).
isInstanceOf
(
NimbusJwtDecoderJwkSupport
.
class
);
NimbusJwtDecoderJwkSupport
decoder
=
(
NimbusJwtDecoderJwkSupport
)
jwtDecoder
;
assertThat
(
decoder
).
hasFieldOrPropertyWithValue
(
"jwsAlgorithm"
,
JWSAlgorithm
.
RS256
);
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
();
});
}
@Test
public
void
autoConfigurationShouldConfigureResourceServerWithJwsAlgotihms
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://jwk-set-uri.com"
,
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=HS512"
)
.
run
((
context
)
->
{
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
assertThat
(
jwtDecoder
).
isInstanceOf
(
NimbusJwtDecoderJwkSupport
.
class
);
NimbusJwtDecoderJwkSupport
decoder
=
(
NimbusJwtDecoderJwkSupport
)
jwtDecoder
;
assertThat
(
decoder
).
hasFieldOrPropertyWithValue
(
"jwsAlgorithm"
,
JWSAlgorithm
.
HS512
);
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
();
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
();
});
});
}
}
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
460fdaf5
...
@@ -547,6 +547,7 @@ content into your application. Rather, pick only the properties that you need.
...
@@ -547,6 +547,7 @@ content into your application. Rather, pick only the properties that you need.
# 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.resourceserver.jwt.jwk-set-uri= # JSON Web Key URI to use to verify the JWT token.
spring.security.oauth2.resourceserver.jwt.jwk-set-uri= # JSON Web Key URI to use to verify the JWT token.
spring.security.oauth2.resourceserver.jwt.jws-algorithm= # JSON Web Algorithm used for verifying the digital signatures.
spring.security.oauth2.resourceserver.jwt.issuer-uri= # URI that an OpenID Connect Provider asserts as its Issuer Identifier.
spring.security.oauth2.resourceserver.jwt.issuer-uri= # URI that an OpenID Connect Provider asserts as its Issuer Identifier.
# ----------------------------------------
# ----------------------------------------
...
...
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