diff --git a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/Constants.java b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/Constants.java index 14518f687e..0151305160 100755 --- a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/Constants.java +++ b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/Constants.java @@ -24,48 +24,48 @@ public class Constants { static class Model { static final String SECURE_DEPLOYMENT = "secure-deployment"; - static final String SERVICE_PROVIDER = "service-provider"; + static final String SERVICE_PROVIDER = "SP"; - static final String SSL_POLICY = "ssl-policy"; - static final String NAME_ID_POLICY_FORMAT = "name-id-policy-format"; - static final String LOGOUT_PAGE = "logout-page"; - static final String FORCE_AUTHENTICATION = "force-authentication"; + static final String SSL_POLICY = "sslPolicy"; + static final String NAME_ID_POLICY_FORMAT = "nameIDPolicyFormat"; + static final String LOGOUT_PAGE = "logoutPage"; + static final String FORCE_AUTHENTICATION = "forceAuthentication"; static final String IS_PASSIVE = "isPassive"; static final String TURN_OFF_CHANGE_SESSSION_ID_ON_LOGIN = "turnOffChangeSessionIdOnLogin"; - static final String ROLE_ATTRIBUTES = "role-attributes"; + static final String ROLE_ATTRIBUTES = "RoleIdentifiers"; static final String SIGNING = "signing"; static final String ENCRYPTION = "encryption"; - static final String KEY = "key"; + static final String KEY = "Key"; static final String RESOURCE = "resource"; static final String PASSWORD = "password"; - static final String PRIVATE_KEY_ALIAS = "private-key-alias"; - static final String PRIVATE_KEY_PASSWORD = "private-key-password"; - static final String CERTIFICATE_ALIAS = "certificate-alias"; - static final String KEY_STORE = "key-store"; - static final String SIGN_REQUEST = "sign-request"; - static final String VALIDATE_RESPONSE_SIGNATURE = "validate-response-signature"; - static final String REQUEST_BINDING = "request-binding"; - static final String BINDING_URL = "binding-url"; - static final String VALIDATE_REQUEST_SIGNATURE = "validate-request-signature"; - static final String SIGN_RESPONSE = "sign-response"; - static final String RESPONSE_BINDING = "response-binding"; - static final String POST_BINDING_URL = "post-binding-url"; - static final String REDIRECT_BINDING_URL = "redirect-binding-url"; - static final String SINGLE_SIGN_ON = "single-sign-on"; - static final String SINGLE_LOGOUT = "single-logout"; - static final String IDENTITY_PROVIDER = "identity-provider"; - static final String PRINCIPAL_NAME_MAPPING_POLICY = "principal-name-mapping-policy"; - static final String PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME = "principal-name-mapping-attribute-name"; - static final String SIGNATURE_ALGORITHM = "signature-algorithm"; - static final String SIGNATURE_CANONICALIZATION_METHOD = "signature-canonicalization-method"; - static final String PRIVATE_KEY_PEM = "private-key-pem"; - static final String PUBLIC_KEY_PEM = "public-key-pem"; - static final String CERTIFICATE_PEM = "certificate-pem"; + static final String PRIVATE_KEY_ALIAS = "PrivateKey-alias"; + static final String PRIVATE_KEY_PASSWORD = "PrivateKey-password"; + static final String CERTIFICATE_ALIAS = "Certificate-alias"; + static final String KEY_STORE = "KeyStore"; + static final String SIGN_REQUEST = "signRequest"; + static final String VALIDATE_RESPONSE_SIGNATURE = "validateResponseSignature"; + static final String REQUEST_BINDING = "requestBinding"; + static final String BINDING_URL = "bindingUrl"; + static final String VALIDATE_REQUEST_SIGNATURE = "validateRequestSignature"; + static final String SIGN_RESPONSE = "signResponse"; + static final String RESPONSE_BINDING = "responseBinding"; + static final String POST_BINDING_URL = "postBindingUrl"; + static final String REDIRECT_BINDING_URL = "redirectBindingUrl"; + static final String SINGLE_SIGN_ON = "SingleSignOnService"; + static final String SINGLE_LOGOUT = "SingleLogoutService"; + static final String IDENTITY_PROVIDER = "IDP"; + static final String PRINCIPAL_NAME_MAPPING_POLICY = "PrincipalNameMapping-policy"; + static final String PRINCIPAL_NAME_MAPPING_ATTRIBUTE_NAME = "PrincipalNameMapping-attribute-name"; + static final String SIGNATURE_ALGORITHM = "signatureAlgorithm"; + static final String SIGNATURE_CANONICALIZATION_METHOD = "signatureCanonicalizationMethod"; + static final String PRIVATE_KEY_PEM = "PrivateKeyPem"; + static final String PUBLIC_KEY_PEM = "PublicKeyPem"; + static final String CERTIFICATE_PEM = "CertificatePem"; static final String TYPE = "type"; static final String ALIAS = "alias"; static final String FILE = "file"; - static final String SIGNATURES_REQUIRED = "signatures-required"; + static final String SIGNATURES_REQUIRED = "signaturesRequired"; } diff --git a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeyDefinition.java b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeyDefinition.java old mode 100644 new mode 100755 index 7d199946a0..74871e312e --- a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeyDefinition.java +++ b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeyDefinition.java @@ -64,7 +64,7 @@ public class KeyDefinition extends SimpleResourceDefinition { static final ObjectTypeAttributeDefinition KEY_STORE = ObjectTypeAttributeDefinition.Builder.of(Constants.Model.KEY_STORE, KeyStoreDefinition.ALL_ATTRIBUTES) - .setAllowNull(false) + .setAllowNull(true) .build(); static final SimpleAttributeDefinition[] ATTRIBUTES = {SIGNING, ENCRYPTION}; diff --git a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakSubsystemParser.java b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakSubsystemParser.java index 8b205652f8..ac5a783cca 100755 --- a/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakSubsystemParser.java +++ b/adapters/saml/wildfly/wildfly-subsystem/src/main/java/org/keycloak/subsystem/adapter/saml/extension/KeycloakSubsystemParser.java @@ -555,14 +555,18 @@ class KeycloakSubsystemParser implements XMLStreamConstants, XMLElementReader
  • URI to a logout page - + Redirected unauthenticated request to a login page - + If user isn't logged in just return with an error. Used to check if a user is already logged in or not - + The session id is changed by default on a successful login. Change this to true if you want to turn this off @@ -88,7 +88,7 @@ The entity ID for SAML service provider - + Require signatures for single-sign-on and single-logout diff --git a/examples/saml/post-with-signature/pom.xml b/examples/saml/post-with-signature/pom.xml index cd4d829c49..32ced7b327 100755 --- a/examples/saml/post-with-signature/pom.xml +++ b/examples/saml/post-with-signature/pom.xml @@ -8,7 +8,7 @@ 1.9.0.CR1-SNAPSHOT - saml-post-signatures + sales-post-sig war diff --git a/examples/saml/testsaml.json b/examples/saml/testsaml.json index 69e28fd3a0..eb666e1b9c 100755 --- a/examples/saml/testsaml.json +++ b/examples/saml/testsaml.json @@ -25,27 +25,13 @@ } ], "clients": [ - { - "clientId": "http://localhost:8080/sales-post/", - "enabled": true, - "fullScopeAllowed": true, - "protocol": "saml", - "baseUrl": "http://localhost:8080/sales-post/", - "adminUrl": "http://localhost:8080/sales-post/", - "redirectUris": [ - "http://localhost:8080/sales-post/*" - ], - "attributes": { - "saml.authnstatement": "true" - } - }, { "clientId": "http://localhost:8080/sales-post-sig/", "enabled": true, "protocol": "saml", "fullScopeAllowed": true, "baseUrl": "http://localhost:8080/sales-post-sig/", - "adminUrl": "http://localhost:8080/sales-post-sig/", + "adminUrl": "http://localhost:8080/sales-post-sig/saml", "redirectUris": [ "http://localhost:8080/sales-post-sig/*" ], @@ -64,7 +50,7 @@ "protocol": "saml", "fullScopeAllowed": true, "baseUrl": "http://localhost:8080/sales-post-enc/", - "adminUrl": "http://localhost:8080/sales-post-enc/", + "adminUrl": "http://localhost:8080/sales-post-enc/saml", "redirectUris": [ "http://localhost:8080/sales-post-enc/*" ], @@ -80,27 +66,13 @@ "saml.encryption.certificate": "MIIB1DCCAT0CBgFJGVacCDANBgkqhkiG9w0BAQsFADAwMS4wLAYDVQQDEyVodHRwOi8vbG9jYWxob3N0OjgwODAvc2FsZXMtcG9zdC1lbmMvMB4XDTE0MTAxNjE0MjA0NloXDTI0MTAxNjE0MjIyNlowMDEuMCwGA1UEAxMlaHR0cDovL2xvY2FsaG9zdDo4MDgwL3NhbGVzLXBvc3QtZW5jLzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA2+5MCT5BnVN+IYnKZcH6ev1pjXGi4feE0nOycq/VJ3aeaZMi4G9AxOxCBPupErOC7Kgm/Bw5AdJyw+Q12wSRXfJ9FhqCrLXpb7YOhbVSTJ8De5O8mW35DxAlh/cxe9FXjqPb286wKTUZ3LfGYR+X235UQeCTAPS/Ufi21EXaEikCAwEAATANBgkqhkiG9w0BAQsFAAOBgQBMrfGD9QFfx5v7ld/OAto5rjkTe3R1Qei8XRXfcs83vLaqEzjEtTuLGrJEi55kXuJgBpVmQpnwCCkkjSy0JxbqLDdVi9arfWUxEGmOr01ZHycELhDNaQcFqVMPr5kRHIHgktT8hK2IgCvd3Fy9/JCgUgCPxKfhwecyEOKxUc857g==" } }, - { - "clientId": "http://localhost:8080/employee/", - "enabled": true, - "fullScopeAllowed": true, - "protocol": "saml", - "baseUrl": "http://localhost:8080/employee/", - "adminUrl": "http://localhost:8080/employee/", - "redirectUris": [ - "http://localhost:8080/employee/*" - ], - "attributes": { - "saml.authnstatement": "true" - } - }, { "clientId": "http://localhost:8080/employee-sig/", "enabled": true, "protocol": "saml", "fullScopeAllowed": true, "baseUrl": "http://localhost:8080/employee-sig/", - "adminUrl": "http://localhost:8080/employee-sig/", + "adminUrl": "http://localhost:8080/employee-sig/saml", "redirectUris": [ "http://localhost:8080/employee-sig/*" ], diff --git a/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlClientInstallation.java b/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlClientInstallation.java index 1fb742eb84..eb75937c69 100755 --- a/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlClientInstallation.java +++ b/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlClientInstallation.java @@ -26,6 +26,12 @@ public class KeycloakSamlClientInstallation implements ClientInstallationProvide SamlClient samlClient = new SamlClient(client); StringBuffer buffer = new StringBuffer(); buffer.append("\n"); + baseXml(realm, client, baseUri, samlClient, buffer); + buffer.append("\n"); + return Response.ok(buffer.toString(), MediaType.TEXT_PLAIN_TYPE).build(); + } + + public static void baseXml(RealmModel realm, ClientModel client, URI baseUri, SamlClient samlClient, StringBuffer buffer) { buffer.append(" \n"); @@ -99,8 +105,6 @@ public class KeycloakSamlClientInstallation implements ClientInstallationProvide } buffer.append(" \n"); buffer.append(" \n"); - buffer.append("\n"); - return Response.ok(buffer.toString(), MediaType.TEXT_PLAIN_TYPE).build(); } @Override diff --git a/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlSubsystemInstallation.java b/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlSubsystemInstallation.java new file mode 100755 index 0000000000..d9911299d2 --- /dev/null +++ b/services/src/main/java/org/keycloak/protocol/saml/installation/KeycloakSamlSubsystemInstallation.java @@ -0,0 +1,88 @@ +package org.keycloak.protocol.saml.installation; + +import org.keycloak.Config; +import org.keycloak.models.ClientModel; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.KeycloakSessionFactory; +import org.keycloak.models.RealmModel; +import org.keycloak.protocol.ClientInstallationProvider; +import org.keycloak.protocol.saml.SamlClient; +import org.keycloak.protocol.saml.SamlProtocol; +import org.keycloak.services.resources.RealmsResource; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import java.net.URI; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class KeycloakSamlSubsystemInstallation implements ClientInstallationProvider { + + @Override + public Response generateInstallation(KeycloakSession session, RealmModel realm, ClientModel client, URI baseUri) { + SamlClient samlClient = new SamlClient(client); + StringBuffer buffer = new StringBuffer(); + buffer.append("\n"); + KeycloakSamlClientInstallation.baseXml(realm, client, baseUri, samlClient, buffer); + buffer.append("\n"); + return Response.ok(buffer.toString(), MediaType.TEXT_PLAIN_TYPE).build(); + } + + @Override + public String getProtocol() { + return SamlProtocol.LOGIN_PROTOCOL; + } + + @Override + public String getDisplayType() { + return "Keycloak SAML Wildfly/JBoss Subsystem"; + } + + @Override + public String getHelpText() { + return "Keycloak SAML adapter Wildfly/JBoss subsystem xml. Put this element of your standalone.xml file."; + } + + @Override + public String getFilename() { + return "keycloak-saml-subsystem.xml"; + } + + @Override + public String getMediaType() { + return MediaType.APPLICATION_XML; + } + + @Override + public boolean isDownloadOnly() { + return false; + } + + @Override + public void close() { + + } + + @Override + public ClientInstallationProvider create(KeycloakSession session) { + return this; + } + + @Override + public void init(Config.Scope config) { + + } + + @Override + public void postInit(KeycloakSessionFactory factory) { + + } + + @Override + public String getId() { + return "keycloak-saml-subsystem"; + } +} diff --git a/services/src/main/resources/META-INF/services/org.keycloak.protocol.ClientInstallationProvider b/services/src/main/resources/META-INF/services/org.keycloak.protocol.ClientInstallationProvider index 5f69307bd4..ab46d8dd4c 100755 --- a/services/src/main/resources/META-INF/services/org.keycloak.protocol.ClientInstallationProvider +++ b/services/src/main/resources/META-INF/services/org.keycloak.protocol.ClientInstallationProvider @@ -4,4 +4,5 @@ org.keycloak.protocol.saml.installation.KeycloakSamlClientInstallation org.keycloak.protocol.saml.installation.SamlSPDescriptorClientInstallation org.keycloak.protocol.saml.installation.SamlIDPDescriptorClientInstallation org.keycloak.protocol.saml.installation.ModAuthMellonClientInstallation +org.keycloak.protocol.saml.installation.KeycloakSamlSubsystemInstallation