Skip to content

Commit

Permalink
Migrate SAML 2.0 Samples to PCFOne
Browse files Browse the repository at this point in the history
Closes gh-9362
  • Loading branch information
jzheaux committed Jan 22, 2021
1 parent 7aeda7c commit e974c93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Expand Up @@ -124,7 +124,7 @@ public void applicationAccessWhenSingleProviderAndUnauthenticatedThenRedirectsTo
public void authenticateRequestWhenUnauthenticatedThenRespondsWithRedirectAuthNRequestXML() throws Exception {
mockMvc.perform(get("http://localhost:8080/saml2/authenticate/simplesamlphp"))
.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
Expand All @@ -136,7 +136,7 @@ public void authenticateRequestWhenRelayStateThenRespondsWithRedirectAndEncodedR
.param("OtherParam2", "OtherParamValue2")
)
.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")))
//check order of parameters
.andExpect(header().string("Location", matchesRegex(".*\\?SAMLRequest\\=.*\\&RelayState\\=.*\\&SigAlg\\=.*\\&Signature\\=.*")));
Expand All @@ -160,7 +160,7 @@ public void authenticateRequestWhenWorkingThenDestinationAttributeIsSet() throws
String destination = authnRequest.getDestination();
assertEquals(
"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
);
String acsURL = authnRequest.getAssertionConsumerServiceURL();
Expand Down Expand Up @@ -322,14 +322,14 @@ private Response buildResponse() {
Response response = OpenSamlActionTestingSupport.buildResponse();
response.setID("_" + UUID.randomUUID().toString());
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;
}

private Assertion buildAssertion(String username) {
Assertion assertion = OpenSamlActionTestingSupport.buildAssertion();
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.setConditions(buildConditions());

Expand All @@ -351,7 +351,7 @@ protected Credential getSigningCredential(String certificate, String key, UsageT
final PrivateKey privateKey = KeySupport.decodePrivateKey(key.getBytes(UTF_8), new char[0]);
BasicCredential cred = CredentialSupport.getSimpleCredential(publicKey, privateKey);
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;
}

Expand Down
4 changes: 2 additions & 2 deletions samples/boot/saml2login/src/main/resources/application.yml
Expand Up @@ -8,7 +8,7 @@ spring:
- private-key-location: "classpath:credentials/rp-private.key"
certificate-location: "classpath:credentials/rp-certificate.crt"
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:
- 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
Expand Up @@ -45,9 +45,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
RelyingPartyRegistrationRepository getSaml2AuthenticationConfiguration() throws Exception {
//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
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
String registrationId = "simplesamlphp";
//local entity ID - autogenerated based on URL
Expand Down

0 comments on commit e974c93

Please sign in to comment.