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
3735771f
Commit
3735771f
authored
Mar 23, 2020
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.2.x'
Closes gh-20612
parents
535e782d
ef1f9b95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
OAuth2ResourceServerJwtConfiguration.java
...esource/servlet/OAuth2ResourceServerJwtConfiguration.java
+3
-2
OAuth2ResourceServerAutoConfigurationTests.java
...e/servlet/OAuth2ResourceServerAutoConfigurationTests.java
+11
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerJwtConfiguration.java
View file @
3735771f
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -78,7 +78,8 @@ class OAuth2ResourceServerJwtConfiguration {
...
@@ -78,7 +78,8 @@ class OAuth2ResourceServerJwtConfiguration {
JwtDecoder
jwtDecoderByPublicKeyValue
()
throws
Exception
{
JwtDecoder
jwtDecoderByPublicKeyValue
()
throws
Exception
{
RSAPublicKey
publicKey
=
(
RSAPublicKey
)
KeyFactory
.
getInstance
(
"RSA"
)
RSAPublicKey
publicKey
=
(
RSAPublicKey
)
KeyFactory
.
getInstance
(
"RSA"
)
.
generatePublic
(
new
X509EncodedKeySpec
(
getKeySpec
(
this
.
properties
.
readPublicKey
())));
.
generatePublic
(
new
X509EncodedKeySpec
(
getKeySpec
(
this
.
properties
.
readPublicKey
())));
return
NimbusJwtDecoder
.
withPublicKey
(
publicKey
).
build
();
return
NimbusJwtDecoder
.
withPublicKey
(
publicKey
)
.
signatureAlgorithm
(
SignatureAlgorithm
.
from
(
this
.
properties
.
getJwsAlgorithm
())).
build
();
}
}
private
byte
[]
getKeySpec
(
String
keyValue
)
{
private
byte
[]
getKeySpec
(
String
keyValue
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
View file @
3735771f
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -190,6 +190,16 @@ class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -190,6 +190,16 @@ class OAuth2ResourceServerAutoConfigurationTests {
.
hasMessageContaining
(
"Public key location does not exist"
));
.
hasMessageContaining
(
"Public key location does not exist"
));
}
}
@Test
void
autoConfigurationShouldFailIfAlgorithmIsInvalid
()
{
this
.
contextRunner
.
withPropertyValues
(
"spring.security.oauth2.resourceserver.jwt.public-key-location=classpath:public-key-location"
,
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=NOT_VALID"
)
.
run
((
context
)
->
assertThat
(
context
).
hasFailed
().
getFailure
()
.
hasMessageContaining
(
"signatureAlgorithm cannot be null"
));
}
@Test
@Test
void
autoConfigurationWhenSetUriKeyLocationAndIssuerUriPresentShouldUseSetUri
()
{
void
autoConfigurationWhenSetUriKeyLocationAndIssuerUriPresentShouldUseSetUri
()
{
this
.
contextRunner
this
.
contextRunner
...
...
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