mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-05 10:12:36 +00:00
Migrate SAML 2.0 Samples to PCFOne
Closes gh-9362
This commit is contained in:
parent
7aeda7c8d8
commit
e974c93f72
@ -124,7 +124,7 @@ public class Saml2LoginIntegrationTests {
|
|||||||
public void authenticateRequestWhenUnauthenticatedThenRespondsWithRedirectAuthNRequestXML() throws Exception {
|
public void authenticateRequestWhenUnauthenticatedThenRespondsWithRedirectAuthNRequestXML() throws Exception {
|
||||||
mockMvc.perform(get("http://localhost:8080/saml2/authenticate/simplesamlphp"))
|
mockMvc.perform(get("http://localhost:8080/saml2/authenticate/simplesamlphp"))
|
||||||
.andExpect(status().is3xxRedirection())
|
.andExpect(status().is3xxRedirection())
|
||||||
.andExpect(header().string("Location", startsWith("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php?SAMLRequest=")));
|
.andExpect(header().string("Location", startsWith("https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/SSOService.php?SAMLRequest=")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -136,7 +136,7 @@ public class Saml2LoginIntegrationTests {
|
|||||||
.param("OtherParam2", "OtherParamValue2")
|
.param("OtherParam2", "OtherParamValue2")
|
||||||
)
|
)
|
||||||
.andExpect(status().is3xxRedirection())
|
.andExpect(status().is3xxRedirection())
|
||||||
.andExpect(header().string("Location", startsWith("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php?SAMLRequest=")))
|
.andExpect(header().string("Location", startsWith("https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/SSOService.php?SAMLRequest=")))
|
||||||
.andExpect(header().string("Location", containsString("RelayState=relay%20state%20value%20with%20spaces")))
|
.andExpect(header().string("Location", containsString("RelayState=relay%20state%20value%20with%20spaces")))
|
||||||
//check order of parameters
|
//check order of parameters
|
||||||
.andExpect(header().string("Location", matchesRegex(".*\\?SAMLRequest\\=.*\\&RelayState\\=.*\\&SigAlg\\=.*\\&Signature\\=.*")));
|
.andExpect(header().string("Location", matchesRegex(".*\\?SAMLRequest\\=.*\\&RelayState\\=.*\\&SigAlg\\=.*\\&Signature\\=.*")));
|
||||||
@ -160,7 +160,7 @@ public class Saml2LoginIntegrationTests {
|
|||||||
String destination = authnRequest.getDestination();
|
String destination = authnRequest.getDestination();
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Destination must match",
|
"Destination must match",
|
||||||
"https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php",
|
"https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/SSOService.php",
|
||||||
destination
|
destination
|
||||||
);
|
);
|
||||||
String acsURL = authnRequest.getAssertionConsumerServiceURL();
|
String acsURL = authnRequest.getAssertionConsumerServiceURL();
|
||||||
@ -322,14 +322,14 @@ public class Saml2LoginIntegrationTests {
|
|||||||
Response response = OpenSamlActionTestingSupport.buildResponse();
|
Response response = OpenSamlActionTestingSupport.buildResponse();
|
||||||
response.setID("_" + UUID.randomUUID().toString());
|
response.setID("_" + UUID.randomUUID().toString());
|
||||||
response.setDestination("http://localhost:8080/login/saml2/sso/simplesamlphp");
|
response.setDestination("http://localhost:8080/login/saml2/sso/simplesamlphp");
|
||||||
response.setIssuer(buildIssuer("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"));
|
response.setIssuer(buildIssuer("https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php"));
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Assertion buildAssertion(String username) {
|
private Assertion buildAssertion(String username) {
|
||||||
Assertion assertion = OpenSamlActionTestingSupport.buildAssertion();
|
Assertion assertion = OpenSamlActionTestingSupport.buildAssertion();
|
||||||
assertion.setIssueInstant(DateTime.now());
|
assertion.setIssueInstant(DateTime.now());
|
||||||
assertion.setIssuer(buildIssuer("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php"));
|
assertion.setIssuer(buildIssuer("https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php"));
|
||||||
assertion.setSubject(buildSubject(username));
|
assertion.setSubject(buildSubject(username));
|
||||||
assertion.setConditions(buildConditions());
|
assertion.setConditions(buildConditions());
|
||||||
|
|
||||||
@ -351,7 +351,7 @@ public class Saml2LoginIntegrationTests {
|
|||||||
final PrivateKey privateKey = KeySupport.decodePrivateKey(key.getBytes(UTF_8), new char[0]);
|
final PrivateKey privateKey = KeySupport.decodePrivateKey(key.getBytes(UTF_8), new char[0]);
|
||||||
BasicCredential cred = CredentialSupport.getSimpleCredential(publicKey, privateKey);
|
BasicCredential cred = CredentialSupport.getSimpleCredential(publicKey, privateKey);
|
||||||
cred.setUsageType(usageType);
|
cred.setUsageType(usageType);
|
||||||
cred.setEntityId("https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php");
|
cred.setEntityId("https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php");
|
||||||
return cred;
|
return cred;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ spring:
|
|||||||
- private-key-location: "classpath:credentials/rp-private.key"
|
- private-key-location: "classpath:credentials/rp-private.key"
|
||||||
certificate-location: "classpath:credentials/rp-certificate.crt"
|
certificate-location: "classpath:credentials/rp-certificate.crt"
|
||||||
identityprovider:
|
identityprovider:
|
||||||
entity-id: https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php
|
entity-id: https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php
|
||||||
verification.credentials:
|
verification.credentials:
|
||||||
- certificate-location: "classpath:credentials/idp-certificate.crt"
|
- certificate-location: "classpath:credentials/idp-certificate.crt"
|
||||||
sso-url: https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php
|
sso-url: https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/SSOService.php
|
||||||
|
@ -45,9 +45,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
@Bean
|
@Bean
|
||||||
RelyingPartyRegistrationRepository getSaml2AuthenticationConfiguration() throws Exception {
|
RelyingPartyRegistrationRepository getSaml2AuthenticationConfiguration() throws Exception {
|
||||||
//remote IDP entity ID
|
//remote IDP entity ID
|
||||||
String idpEntityId = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/metadata.php";
|
String idpEntityId = "https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php";
|
||||||
//remote WebSSO Endpoint - Where to Send AuthNRequests to
|
//remote WebSSO Endpoint - Where to Send AuthNRequests to
|
||||||
String webSsoEndpoint = "https://simplesaml-for-spring-saml.cfapps.io/saml2/idp/SSOService.php";
|
String webSsoEndpoint = "https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/SSOService.php";
|
||||||
//local registration ID
|
//local registration ID
|
||||||
String registrationId = "simplesamlphp";
|
String registrationId = "simplesamlphp";
|
||||||
//local entity ID - autogenerated based on URL
|
//local entity ID - autogenerated based on URL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user