Skip to content

Commit

Permalink
Merge branch 'mattsheppard-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed May 8, 2020
2 parents ea6a0e7 + c612f93 commit fe6227e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mujina-idp/src/main/java/mujina/idp/MetadataController.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.opensaml.xml.signature.Signer;
import org.opensaml.xml.util.XMLHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.security.saml.key.KeyManager;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -49,8 +50,9 @@ public class MetadataController {
@Autowired
Environment environment;

@Autowired
@RequestMapping(method = RequestMethod.GET, value = "/metadata", produces = "application/xml")
public String metadata() throws SecurityException, ParserConfigurationException, SignatureException, MarshallingException, TransformerException {
public String metadata(@Value("${idp.base_url}") String idpBaseUrl) throws SecurityException, ParserConfigurationException, SignatureException, MarshallingException, TransformerException {
EntityDescriptor entityDescriptor = buildSAMLObject(EntityDescriptor.class, EntityDescriptor.DEFAULT_ELEMENT_NAME);
entityDescriptor.setEntityID(idpConfiguration.getEntityId());
entityDescriptor.setID(SAMLBuilder.randomSAMLId());
Expand All @@ -76,10 +78,8 @@ public String metadata() throws SecurityException, ParserConfigurationException,

idpssoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);

String localPort = environment.getProperty("local.server.port");

SingleSignOnService singleSignOnService = buildSAMLObject(SingleSignOnService.class, SingleSignOnService.DEFAULT_ELEMENT_NAME);
singleSignOnService.setLocation("http://localhost:" + localPort + "/SingleSignOnService");
singleSignOnService.setLocation(idpBaseUrl + "/SingleSignOnService");
singleSignOnService.setBinding(SAMLConstants.SAML2_REDIRECT_BINDING_URI);

idpssoDescriptor.getSingleSignOnServices().add(singleSignOnService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import mujina.AbstractIntegrationTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Value;

import static io.restassured.RestAssured.given;
import static io.restassured.config.RestAssuredConfig.newConfig;
Expand All @@ -11,6 +12,9 @@

public class MetadataControllerTest extends AbstractIntegrationTest {

@Value("${idp.base_url}")
private String idpBaseUrl;

@Test
public void metadata() throws Exception {
given()
Expand All @@ -22,7 +26,7 @@ public void metadata() throws Exception {
.statusCode(SC_OK)
.body(
"EntityDescriptor.IDPSSODescriptor.SingleSignOnService.@Location",
equalTo("http://localhost:" + serverPort + "/SingleSignOnService"));
equalTo(idpBaseUrl + "/SingleSignOnService"));
}

}
Expand Down

0 comments on commit fe6227e

Please sign in to comment.