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
3354e0f0
Commit
3354e0f0
authored
Aug 04, 2020
by
Brian Clozel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade to Spring Security 5.4.0-SNAPSHOT
See gh-22668
parent
94148e9b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
34 deletions
+32
-34
Saml2RelyingPartyRegistrationConfiguration.java
...ity/saml2/Saml2RelyingPartyRegistrationConfiguration.java
+17
-23
ReactiveOAuth2ResourceServerAutoConfigurationTests.java
...e/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
+1
-1
OAuth2ResourceServerAutoConfigurationTests.java
...e/servlet/OAuth2ResourceServerAutoConfigurationTests.java
+4
-2
Saml2RelyingPartyAutoConfigurationTests.java
...curity/saml2/Saml2RelyingPartyAutoConfigurationTests.java
+9
-7
build.gradle
spring-boot-project/spring-boot-dependencies/build.gradle
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyRegistrationConfiguration.java
View file @
3354e0f0
...
@@ -20,7 +20,6 @@ import java.io.InputStream;
...
@@ -20,7 +20,6 @@ import java.io.InputStream;
import
java.security.cert.CertificateFactory
;
import
java.security.cert.CertificateFactory
;
import
java.security.cert.X509Certificate
;
import
java.security.cert.X509Certificate
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -34,8 +33,7 @@ import org.springframework.context.annotation.Conditional;
...
@@ -34,8 +33,7 @@ import org.springframework.context.annotation.Conditional;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.security.converter.RsaKeyConverters
;
import
org.springframework.security.converter.RsaKeyConverters
;
import
org.springframework.security.saml2.credentials.Saml2X509Credential
;
import
org.springframework.security.saml2.core.Saml2X509Credential
;
import
org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType
;
import
org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository
;
import
org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository
;
import
org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration
;
import
org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration
;
import
org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository
;
import
org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistrationRepository
;
...
@@ -69,15 +67,19 @@ class Saml2RelyingPartyRegistrationConfiguration {
...
@@ -69,15 +67,19 @@ class Saml2RelyingPartyRegistrationConfiguration {
boolean
signRequest
=
properties
.
getIdentityprovider
().
getSinglesignon
().
isSignRequest
();
boolean
signRequest
=
properties
.
getIdentityprovider
().
getSinglesignon
().
isSignRequest
();
validateSigningCredentials
(
properties
,
signRequest
);
validateSigningCredentials
(
properties
,
signRequest
);
RelyingPartyRegistration
.
Builder
builder
=
RelyingPartyRegistration
.
withRegistrationId
(
id
);
RelyingPartyRegistration
.
Builder
builder
=
RelyingPartyRegistration
.
withRegistrationId
(
id
);
builder
.
assertionConsumerService
UrlTemplate
(
builder
.
assertionConsumerService
Location
(
"{baseUrl}"
+
Saml2WebSsoAuthenticationFilter
.
DEFAULT_FILTER_PROCESSES_URI
);
"{baseUrl}"
+
Saml2WebSsoAuthenticationFilter
.
DEFAULT_FILTER_PROCESSES_URI
);
builder
.
providerDetails
(
builder
.
assertingPartyDetails
((
details
)
->
{
(
details
)
->
details
.
webSsoUrl
(
properties
.
getIdentityprovider
().
getSinglesignon
().
getUrl
()));
details
.
singleSignOnServiceLocation
(
properties
.
getIdentityprovider
().
getSinglesignon
().
getUrl
());
builder
.
providerDetails
((
details
)
->
details
.
entityId
(
properties
.
getIdentityprovider
().
getEntityId
()));
details
.
entityId
(
properties
.
getIdentityprovider
().
getEntityId
());
builder
.
providerDetails
(
details
.
singleSignOnServiceBinding
(
properties
.
getIdentityprovider
().
getSinglesignon
().
getBinding
());
(
details
)
->
details
.
binding
(
properties
.
getIdentityprovider
().
getSinglesignon
().
getBinding
()));
details
.
wantAuthnRequestsSigned
(
signRequest
);
builder
.
providerDetails
((
details
)
->
details
.
signAuthNRequest
(
signRequest
));
});
builder
.
credentials
((
credentials
)
->
credentials
.
addAll
(
asCredentials
(
properties
)));
builder
.
signingX509Credentials
((
credentials
)
->
properties
.
getSigning
().
getCredentials
().
stream
()
.
map
(
this
::
asSigningCredential
).
forEach
(
credentials:
:
add
));
builder
.
assertingPartyDetails
((
details
)
->
details
.
verificationX509Credentials
((
credentials
)
->
properties
.
getIdentityprovider
().
getVerification
()
.
getCredentials
().
stream
().
map
(
this
::
asVerificationCredential
).
forEach
(
credentials:
:
add
)));
return
builder
.
build
();
return
builder
.
build
();
}
}
...
@@ -88,25 +90,17 @@ class Saml2RelyingPartyRegistrationConfiguration {
...
@@ -88,25 +90,17 @@ class Saml2RelyingPartyRegistrationConfiguration {
}
}
}
}
private
List
<
Saml2X509Credential
>
asCredentials
(
Registration
properties
)
{
List
<
Saml2X509Credential
>
credentials
=
new
ArrayList
<>();
properties
.
getSigning
().
getCredentials
().
stream
().
map
(
this
::
asSigningCredential
).
forEach
(
credentials:
:
add
);
properties
.
getIdentityprovider
().
getVerification
().
getCredentials
().
stream
().
map
(
this
::
asVerificationCredential
)
.
forEach
(
credentials:
:
add
);
return
credentials
;
}
private
Saml2X509Credential
asSigningCredential
(
Signing
.
Credential
properties
)
{
private
Saml2X509Credential
asSigningCredential
(
Signing
.
Credential
properties
)
{
RSAPrivateKey
privateKey
=
readPrivateKey
(
properties
.
getPrivateKeyLocation
());
RSAPrivateKey
privateKey
=
readPrivateKey
(
properties
.
getPrivateKeyLocation
());
X509Certificate
certificate
=
readCertificate
(
properties
.
getCertificateLocation
());
X509Certificate
certificate
=
readCertificate
(
properties
.
getCertificateLocation
());
return
new
Saml2X509Credential
(
privateKey
,
certificate
,
Saml2X509CredentialType
.
SIGNING
,
return
new
Saml2X509Credential
(
privateKey
,
certificate
,
Saml2X509Credential
.
Saml2X509Credential
Type
.
SIGNING
,
Saml2X509CredentialType
.
DECRYPTION
);
Saml2X509Credential
.
Saml2X509Credential
Type
.
DECRYPTION
);
}
}
private
Saml2X509Credential
asVerificationCredential
(
Verification
.
Credential
properties
)
{
private
Saml2X509Credential
asVerificationCredential
(
Verification
.
Credential
properties
)
{
X509Certificate
certificate
=
readCertificate
(
properties
.
getCertificateLocation
());
X509Certificate
certificate
=
readCertificate
(
properties
.
getCertificateLocation
());
return
new
Saml2X509Credential
(
certificate
,
Saml2X509CredentialType
.
ENCRYPTION
,
return
new
Saml2X509Credential
(
certificate
,
Saml2X509Credential
.
Saml2X509Credential
Type
.
ENCRYPTION
,
Saml2X509CredentialType
.
VERIFICATION
);
Saml2X509Credential
.
Saml2X509Credential
Type
.
VERIFICATION
);
}
}
private
RSAPrivateKey
readPrivateKey
(
Resource
location
)
{
private
RSAPrivateKey
readPrivateKey
(
Resource
location
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/reactive/ReactiveOAuth2ResourceServerAutoConfigurationTests.java
View file @
3354e0f0
...
@@ -105,7 +105,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
...
@@ -105,7 +105,7 @@ class ReactiveOAuth2ResourceServerAutoConfigurationTests {
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS512"
)
"spring.security.oauth2.resourceserver.jwt.jws-algorithm=RS512"
)
.
run
((
context
)
->
{
.
run
((
context
)
->
{
NimbusReactiveJwtDecoder
nimbusReactiveJwtDecoder
=
context
.
getBean
(
NimbusReactiveJwtDecoder
.
class
);
NimbusReactiveJwtDecoder
nimbusReactiveJwtDecoder
=
context
.
getBean
(
NimbusReactiveJwtDecoder
.
class
);
assertThat
(
nimbusReactiveJwtDecoder
).
extracting
(
"jwtProcessor.arg$2"
)
assertThat
(
nimbusReactiveJwtDecoder
).
extracting
(
"jwtProcessor.arg$2
.arg$1.jwsAlgs
"
)
.
matches
((
algorithms
)
->
((
Set
<
JWSAlgorithm
>)
algorithms
).
contains
(
JWSAlgorithm
.
RS512
));
.
matches
((
algorithms
)
->
((
Set
<
JWSAlgorithm
>)
algorithms
).
contains
(
JWSAlgorithm
.
RS512
));
});
});
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java
View file @
3354e0f0
...
@@ -98,7 +98,8 @@ class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -98,7 +98,8 @@ class OAuth2ResourceServerAutoConfigurationTests {
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
Object
processor
=
ReflectionTestUtils
.
getField
(
jwtDecoder
,
"jwtProcessor"
);
Object
processor
=
ReflectionTestUtils
.
getField
(
jwtDecoder
,
"jwtProcessor"
);
Object
keySelector
=
ReflectionTestUtils
.
getField
(
processor
,
"jwsKeySelector"
);
Object
keySelector
=
ReflectionTestUtils
.
getField
(
processor
,
"jwsKeySelector"
);
assertThat
(
keySelector
).
hasFieldOrPropertyWithValue
(
"jwsAlg"
,
JWSAlgorithm
.
RS256
);
assertThat
(
keySelector
).
hasFieldOrPropertyWithValue
(
"jwsAlgs"
,
Collections
.
singleton
(
JWSAlgorithm
.
RS256
));
});
});
}
}
...
@@ -111,7 +112,8 @@ class OAuth2ResourceServerAutoConfigurationTests {
...
@@ -111,7 +112,8 @@ class OAuth2ResourceServerAutoConfigurationTests {
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
JwtDecoder
jwtDecoder
=
context
.
getBean
(
JwtDecoder
.
class
);
Object
processor
=
ReflectionTestUtils
.
getField
(
jwtDecoder
,
"jwtProcessor"
);
Object
processor
=
ReflectionTestUtils
.
getField
(
jwtDecoder
,
"jwtProcessor"
);
Object
keySelector
=
ReflectionTestUtils
.
getField
(
processor
,
"jwsKeySelector"
);
Object
keySelector
=
ReflectionTestUtils
.
getField
(
processor
,
"jwsKeySelector"
);
assertThat
(
keySelector
).
hasFieldOrPropertyWithValue
(
"jwsAlg"
,
JWSAlgorithm
.
RS384
);
assertThat
(
keySelector
).
hasFieldOrPropertyWithValue
(
"jwsAlgs"
,
Collections
.
singleton
(
JWSAlgorithm
.
RS384
));
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
();
assertThat
(
getBearerTokenFilter
(
context
)).
isNotNull
();
});
});
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/saml2/Saml2RelyingPartyAutoConfigurationTests.java
View file @
3354e0f0
...
@@ -80,16 +80,18 @@ public class Saml2RelyingPartyAutoConfigurationTests {
...
@@ -80,16 +80,18 @@ public class Saml2RelyingPartyAutoConfigurationTests {
this
.
contextRunner
.
withPropertyValues
(
getPropertyValues
()).
run
((
context
)
->
{
this
.
contextRunner
.
withPropertyValues
(
getPropertyValues
()).
run
((
context
)
->
{
RelyingPartyRegistrationRepository
repository
=
context
.
getBean
(
RelyingPartyRegistrationRepository
.
class
);
RelyingPartyRegistrationRepository
repository
=
context
.
getBean
(
RelyingPartyRegistrationRepository
.
class
);
RelyingPartyRegistration
registration
=
repository
.
findByRegistrationId
(
"foo"
);
RelyingPartyRegistration
registration
=
repository
.
findByRegistrationId
(
"foo"
);
assertThat
(
registration
.
getProviderDetails
().
getWebSsoUrl
())
assertThat
(
registration
.
getAssertingPartyDetails
().
getSingleSignOnServiceLocation
())
.
isEqualTo
(
"https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php"
);
.
isEqualTo
(
"https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php"
);
assertThat
(
registration
.
get
Provider
Details
().
getEntityId
())
assertThat
(
registration
.
get
AssertingParty
Details
().
getEntityId
())
.
isEqualTo
(
"https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"
);
.
isEqualTo
(
"https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"
);
assertThat
(
registration
.
getAssertionConsumerService
UrlTemplate
())
assertThat
(
registration
.
getAssertionConsumerService
Location
())
.
isEqualTo
(
"{baseUrl}"
+
Saml2WebSsoAuthenticationFilter
.
DEFAULT_FILTER_PROCESSES_URI
);
.
isEqualTo
(
"{baseUrl}"
+
Saml2WebSsoAuthenticationFilter
.
DEFAULT_FILTER_PROCESSES_URI
);
assertThat
(
registration
.
getProviderDetails
().
getBinding
()).
isEqualTo
(
Saml2MessageBinding
.
POST
);
assertThat
(
registration
.
getAssertingPartyDetails
().
getSingleSignOnServiceBinding
())
assertThat
(
registration
.
getProviderDetails
().
isSignAuthNRequest
()).
isEqualTo
(
false
);
.
isEqualTo
(
Saml2MessageBinding
.
POST
);
assertThat
(
registration
.
getSigningCredentials
()).
isNotNull
();
assertThat
(
registration
.
getAssertingPartyDetails
().
getWantAuthnRequestsSigned
()).
isEqualTo
(
false
);
assertThat
(
registration
.
getVerificationCredentials
()).
isNotNull
();
assertThat
(
registration
.
getSigningX509Credentials
()).
isNotNull
();
assertThat
(
registration
.
getAssertingPartyDetails
().
getVerificationX509Credentials
()).
isNotNull
();
});
});
}
}
...
...
spring-boot-project/spring-boot-dependencies/build.gradle
View file @
3354e0f0
...
@@ -1616,7 +1616,7 @@ bom {
...
@@ -1616,7 +1616,7 @@ bom {
]
]
}
}
}
}
library
(
"Spring Security"
,
"5.4.0-
M1
"
)
{
library
(
"Spring Security"
,
"5.4.0-
SNAPSHOT
"
)
{
group
(
"org.springframework.security"
)
{
group
(
"org.springframework.security"
)
{
imports
=
[
imports
=
[
"spring-security-bom"
"spring-security-bom"
...
...
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