Browse Source

Add Second Tenant to SAML 2.0 Login

Josh Cummings 3 years ago
parent
commit
7426260ee1

+ 3 - 2
servlet/spring-boot/java/saml2/login/src/integTest/java/example/Saml2LoginApplicationITests.java

@@ -74,7 +74,7 @@ public class Saml2LoginApplicationITests {
 	@Test
 	void indexWhenSamlResponseThenShowsUserInformation() throws Exception {
 		HttpSession session = this.mvc.perform(get("http://localhost:8080/")).andExpect(status().is3xxRedirection())
-				.andExpect(redirectedUrl("http://localhost:8080/saml2/authenticate/one")).andReturn().getRequest()
+				.andExpect(redirectedUrl("http://localhost:8080/login")).andReturn().getRequest()
 				.getSession();
 
 		this.mvc.perform(post("http://localhost:8080/login/saml2/sso/one").param("SAMLResponse", SIGNED_RESPONSE)
@@ -108,7 +108,8 @@ public class Saml2LoginApplicationITests {
 	}
 
 	private HtmlPage performLogin() throws IOException {
-		HtmlPage assertingParty = this.webClient.getPage("/");
+		HtmlPage login = this.webClient.getPage("/");
+		HtmlPage assertingParty = login.getAnchorByHref("/saml2/authenticate/one").click();
 		HtmlForm form = assertingParty.getFormByName("f");
 		HtmlInput username = form.getInputByName("username");
 		HtmlInput password = form.getInputByName("password");

+ 6 - 1
servlet/spring-boot/java/saml2/login/src/main/resources/application.yml

@@ -4,11 +4,16 @@ spring:
       relyingparty:
         registration:
           one:
-            signing.credentials:
+            signing.credentials: &rp-metadata
               - private-key-location: classpath:credentials/rp-private.key
                 certificate-location: classpath:credentials/rp-certificate.crt
             identityprovider:
               metadata-uri: https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php
+          two:
+            signing.credentials: *rp-metadata
+            decryption.credentials: *rp-metadata
+            identityprovider:
+              metadata-uri: https://simplesaml-for-spring-saml.apps.pcfone.io/saml2/idp/metadata.php
 
 
 logging.level: