Updated config
This commit is contained in:
@@ -266,13 +266,12 @@ public class SecurityConfig {
|
|||||||
|
|
||||||
String entityId = baseUrl + "/v1/saml/gw/metadata";
|
String entityId = baseUrl + "/v1/saml/gw/metadata";
|
||||||
String acsUrl = baseUrl + "/login/saml2/sso/loginumbria";
|
String acsUrl = baseUrl + "/login/saml2/sso/loginumbria";
|
||||||
|
|
||||||
RelyingPartyRegistration registration = RelyingPartyRegistration.withRegistrationId("loginumbria")
|
RelyingPartyRegistration registration = RelyingPartyRegistration.withRegistrationId("loginumbria")
|
||||||
.entityId(entityId)
|
.entityId(entityId)
|
||||||
.signingX509Credentials(credentials -> {
|
.signingX509Credentials(credentials -> {
|
||||||
try {
|
try {
|
||||||
credentials.add(Saml2X509Credential.signing(readPrivateKey(), readCertificate()));
|
credentials.add(Saml2X509Credential.signing(readPrivateKey(), readCertificate()));
|
||||||
// AuthnRequest signedAuthnRequest = createSignedAuthnRequest(readPrivateKey(), readCertificate());
|
|
||||||
//logger.info("Signed SAML AuthnRequest: " + SamlRequestLogger.convertSAMLObjectToString(signedAuthnRequest));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -280,9 +279,19 @@ public class SecurityConfig {
|
|||||||
.assertionConsumerServiceLocation(acsUrl)
|
.assertionConsumerServiceLocation(acsUrl)
|
||||||
.assertingPartyDetails(details -> details.entityId("https://federatest.umbriadigitale.it/gw/metadata")
|
.assertingPartyDetails(details -> details.entityId("https://federatest.umbriadigitale.it/gw/metadata")
|
||||||
.singleSignOnServiceLocation("https://federatest.umbriadigitale.it/gw/SSOProxy/SAML2")
|
.singleSignOnServiceLocation("https://federatest.umbriadigitale.it/gw/SSOProxy/SAML2")
|
||||||
.singleSignOnServiceBinding(Saml2MessageBinding.POST).wantAuthnRequestsSigned(true).build()
|
.singleSignOnServiceBinding(Saml2MessageBinding.POST)
|
||||||
|
.wantAuthnRequestsSigned(true)
|
||||||
|
.verificationX509Credentials(credentials -> {
|
||||||
|
try {
|
||||||
|
// Load the IDP's public certificate for verifying the SAML response signature
|
||||||
|
credentials.add(Saml2X509Credential.verification(readIdpCertificate()));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
})
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
return new InMemoryRelyingPartyRegistrationRepository(registration);
|
return new InMemoryRelyingPartyRegistrationRepository(registration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +387,15 @@ private RequestedAuthnContext buildRequestedAuthnContext() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public X509Certificate readIdpCertificate() throws Exception {
|
||||||
|
// Path to your IDP public certificate PEM file
|
||||||
|
try (InputStream inStream = readKey("dev/saml/idp-certificate.pem")) {
|
||||||
|
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
|
||||||
|
return (X509Certificate) certFactory.generateCertificate(inStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public InputStream readKey(String path) throws IOException {
|
public InputStream readKey(String path) throws IOException {
|
||||||
ClassLoader classLoader = getClass().getClassLoader();
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
InputStream inputStream = classLoader.getResourceAsStream(path);
|
InputStream inputStream = classLoader.getResourceAsStream(path);
|
||||||
|
|||||||
3
src/main/resources/dev/saml/idp-certificate.pem
Normal file
3
src/main/resources/dev/saml/idp-certificate.pem
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDJDCCAgygAwIBAgIVAIq/MUgxPKO0cuX/GtD7YUvk87GtMA0GCSqGSIb3DQEBBQUAMBkxFzAVBgNVBAMTDmlkcC5tYWNoaW5lLml0MB4XDTA5MDMyNTEwNTM1OFoXDTI5MDMyNTA5NTM1OFowGTEXMBUGA1UEAxMOaWRwLm1hY2hpb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