From 179e371d0e346187a6dabbb10ab6ba9129a53080 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 30 Jan 2018 14:41:57 -0200 Subject: [PATCH] [KEYCLOAK-6298] SAML adapter script should support offline installation of adapter --- .../adapter-elytron-install-saml-offline.cli | 58 +++++++++++++++++++ .../adapter-install-saml-offline.cli | 3 + .../wildfly-adapter-zip/assembly.xml | 8 +++ 3 files changed, 69 insertions(+) create mode 100755 distribution/saml-adapters/shared-cli/adapter-elytron-install-saml-offline.cli create mode 100755 distribution/saml-adapters/shared-cli/adapter-install-saml-offline.cli diff --git a/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml-offline.cli b/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml-offline.cli new file mode 100755 index 0000000000..486defe0fe --- /dev/null +++ b/distribution/saml-adapters/shared-cli/adapter-elytron-install-saml-offline.cli @@ -0,0 +1,58 @@ +embed-server --server-config=standalone.xml + +if (outcome != success) of /extension=org.keycloak.keycloak-saml-adapter-subsystem:read-resource + /extension=org.keycloak.keycloak-saml-adapter-subsystem/:add(module=org.keycloak.keycloak-saml-adapter-subsystem) +else + echo Keycloak SAML Extension already installed +end-if + +if (outcome != success) of /subsystem=keycloak-saml:read-resource + /subsystem=keycloak-saml:add +else + echo Keycloak SAML Subsystem already installed +end-if + +if (outcome != success) of /subsystem=elytron/custom-realm=KeycloakSAMLRealm:read-resource + /subsystem=elytron/custom-realm=KeycloakSAMLRealm:add(class-name=org.keycloak.adapters.saml.elytron.KeycloakSecurityRealm, module=org.keycloak.keycloak-saml-wildfly-elytron-adapter) +else + echo Keycloak SAML Realm already installed +end-if + +if (outcome != success) of /subsystem=elytron/security-domain=KeycloakDomain:read-resource + /subsystem=elytron/security-domain=KeycloakDomain:add(default-realm=KeycloakSAMLRealm,permission-mapper=default-permission-mapper,security-event-listener=local-audit,realms=[{realm=KeycloakSAMLRealm}]) +else + echo Keycloak Security Domain already installed. Trying to install Keycloak SAML Realm. + /subsystem=elytron/security-domain=KeycloakDomain:list-add(name=realms, value={realm=KeycloakSAMLRealm}) +end-if + +if (outcome != success) of /subsystem=elytron/constant-realm-mapper=keycloak-saml-realm-mapper:read-resource + /subsystem=elytron/constant-realm-mapper=keycloak-saml-realm-mapper:add(realm-name=KeycloakSAMLRealm) +else + echo Keycloak SAML Realm Mapper already installed +end-if + +if (outcome != success) of /subsystem=elytron/service-loader-http-server-mechanism-factory=keycloak-saml-http-server-mechanism-factory:read-resource + /subsystem=elytron/service-loader-http-server-mechanism-factory=keycloak-saml-http-server-mechanism-factory:add(module=org.keycloak.keycloak-saml-wildfly-elytron-adapter) +else + echo Keycloak SAML HTTP Mechanism Factory already installed +end-if + +if (outcome != success) of /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:read-resource + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:add(http-server-mechanism-factories=[keycloak-saml-http-server-mechanism-factory, global]) +else + echo Keycloak HTTP Mechanism Factory already installed. Trying to install Keycloak SAML HTTP Mechanism Factory. + /subsystem=elytron/aggregate-http-server-mechanism-factory=keycloak-http-server-mechanism-factory:list-add(name=http-server-mechanism-factories, value=keycloak-saml-http-server-mechanism-factory) +end-if + +if (outcome != success) of /subsystem=elytron/http-authentication-factory=keycloak-http-authentication:read-resource + /subsystem=elytron/http-authentication-factory=keycloak-http-authentication:add(security-domain=KeycloakDomain,http-server-mechanism-factory=keycloak-http-server-mechanism-factory,mechanism-configurations=[{mechanism-name=KEYCLOAK-SAML,mechanism-realm-configurations=[{realm-name=KeycloakSAMLCRealm,realm-mapper=keycloak-saml-realm-mapper}]}]) +else + echo Keycloak HTTP Authentication Factory already installed. Trying to install Keycloak SAML Mechanism Configuration + /subsystem=elytron/http-authentication-factory=keycloak-http-authentication:list-add(name=mechanism-configurations, value={mechanism-name=KEYCLOAK-SAML,mechanism-realm-configurations=[{realm-name=KeycloakSAMLRealm,realm-mapper=keycloak-saml-realm-mapper}]}) +end-if + +if (outcome != success) of /subsystem=undertow/application-security-domain=other:read-resource + /subsystem=undertow/application-security-domain=other:add(http-authentication-factory=keycloak-http-authentication) +else + echo Undertow already configured with Keycloak +end-if diff --git a/distribution/saml-adapters/shared-cli/adapter-install-saml-offline.cli b/distribution/saml-adapters/shared-cli/adapter-install-saml-offline.cli new file mode 100755 index 0000000000..7075bad031 --- /dev/null +++ b/distribution/saml-adapters/shared-cli/adapter-install-saml-offline.cli @@ -0,0 +1,3 @@ +embed-server --server-config=standalone.xml +/extension=org.keycloak.keycloak-saml-adapter-subsystem/:add(module=org.keycloak.keycloak-saml-adapter-subsystem) +/subsystem=keycloak-saml:add \ No newline at end of file diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml index 9cb207e172..46185248d6 100755 --- a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml +++ b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml @@ -42,9 +42,17 @@ ../../shared-cli/adapter-install-saml.cli bin + + ../../shared-cli/adapter-install-saml-offline.cli + bin + ../../shared-cli/adapter-elytron-install-saml.cli bin + + ../../shared-cli/adapter-elytron-install-saml-offline.cli + bin +