2019-01-21 17:01:40 +00:00
[[_jboss_adapter]]
2016-11-29 22:20:33 +00:00
2017-08-28 12:50:14 +00:00
ifeval::[{project_community}==true]
2021-12-22 10:28:04 +00:00
==== JBoss EAP/WildFly adapter
2017-08-28 12:50:14 +00:00
endif::[]
ifeval::[{project_product}==true]
2021-12-22 10:28:04 +00:00
==== JBoss EAP adapter
2017-08-28 12:50:14 +00:00
endif::[]
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
You can install this adapter from a ZIP file or from an RPM.
* xref:jboss_adapter_installation[Installing JBOSS EAP adapters from a ZIP file]
* xref:jboss7_adapter_rpm[Installing JBoss EAP 7 Adapters from an RPM]
* xref:jboss6_adapter_rpm[Installing JBoss EAP 6 Adapters from an RPM]
[id="jboss_adapter_installation"]
==== Installing JBOSS EAP adapters from a ZIP file
2017-08-28 12:50:14 +00:00
ifeval::[{project_community}==true]
2016-06-10 04:13:14 +00:00
To be able to secure WAR apps deployed on JBoss EAP, WildFly or JBoss AS, you must install and configure the
2017-08-28 12:50:14 +00:00
{project_name} adapter subsystem. You then have two options to secure your WARs.
endif::[]
ifeval::[{project_product}==true]
2016-06-10 04:13:14 +00:00
To be able to secure WAR apps deployed on JBoss EAP, you must install and configure the
2017-08-28 12:50:14 +00:00
{project_name} adapter subsystem. You then have two options to secure your WARs.
endif::[]
2016-06-03 08:02:59 +00:00
2021-12-22 10:28:04 +00:00
* You can provide an adapter config file in your WAR and change the auth-method to KEYCLOAK within web.xml.
2016-06-03 08:02:59 +00:00
2021-12-22 10:28:04 +00:00
* Alternatively, you do not have to modify your WAR at all and you can secure it via the {project_name} adapter subsystem configuration in the configuration file, such as `standalone.xml`.
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
Both methods are described in this section.
2016-04-18 19:10:32 +00:00
2017-02-02 12:20:15 +00:00
Adapters are available as a separate archive depending on what server version you are using.
2016-04-18 19:10:32 +00:00
2017-08-28 12:50:14 +00:00
ifeval::[{project_community}==true]
2018-08-30 11:56:07 +00:00
2021-12-22 10:28:04 +00:00
NOTE: We test and maintain adapters only with the most recent version of WildFly available upon the release. Once a new version of
2018-08-30 11:56:07 +00:00
WildFly is released, the current adapters become deprecated and support for them will be removed after next WildFly release.
The other alternative is to switch your applications from WildFly to the JBoss EAP, as the JBoss EAP adapter is supported for much longer period.
2021-12-22 10:28:04 +00:00
.Procedure
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
. Install the adapter that applies to your application server from the link:https://www.keycloak.org/downloads[Downloads] site.
* Install on WildFly 9 or newer:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-04-18 19:10:32 +00:00
----
2016-06-03 08:02:59 +00:00
$ cd $WILDFLY_HOME
2017-08-28 12:50:14 +00:00
$ unzip keycloak-wildfly-adapter-dist-{project_version}.zip
2016-06-03 08:02:59 +00:00
----
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 7:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-04-18 19:10:32 +00:00
----
2016-06-03 08:02:59 +00:00
$ cd $EAP_HOME
2017-08-28 12:50:14 +00:00
$ unzip keycloak-eap7-adapter-dist-{project_version}.zip
2016-06-03 08:02:59 +00:00
----
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 6:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-04-18 19:10:32 +00:00
----
2016-06-03 08:02:59 +00:00
$ cd $EAP_HOME
2017-08-28 12:50:14 +00:00
$ unzip keycloak-eap6-adapter-dist-{project_version}.zip
2016-06-03 08:02:59 +00:00
----
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
* Install on JBoss AS 7.1:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-04-18 19:10:32 +00:00
----
$ cd $JBOSS_HOME
2017-08-28 12:50:14 +00:00
$ unzip keycloak-as7-adapter-dist-{project_version}.zip
2016-06-03 08:02:59 +00:00
----
2017-08-28 12:50:14 +00:00
endif::[]
ifeval::[{project_product}==true]
2017-11-10 05:46:35 +00:00
2021-12-22 10:28:04 +00:00
.Procedure
2017-11-10 05:46:35 +00:00
2021-12-22 10:28:04 +00:00
. Install the adapter that applies to your application server from the link:https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?downloadType=distributions&product=core.service.rhsso[Sotware Downloads] site.
2017-11-10 05:46:35 +00:00
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 7:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-06-03 08:02:59 +00:00
----
$ cd $EAP_HOME
2017-08-28 12:50:14 +00:00
$ unzip rh-sso-{project_version}-eap7-adapter.zip
2016-06-03 08:02:59 +00:00
----
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 6:
+
2016-06-09 12:54:13 +00:00
[source, subs="attributes"]
2016-04-18 19:10:32 +00:00
----
2016-06-03 08:02:59 +00:00
$ cd $EAP_HOME
2017-08-28 12:50:14 +00:00
$ unzip rh-sso-{project_version}-eap6-adapter.zip
2016-06-03 08:02:59 +00:00
----
2018-01-31 13:35:29 +00:00
endif::[]
2021-12-22 10:28:04 +00:00
+
2018-01-31 13:35:29 +00:00
This ZIP archive contains JBoss Modules specific to the {project_name} adapter. It also contains JBoss CLI scripts to configure the adapter subsystem.
2017-11-10 05:46:35 +00:00
2021-12-22 10:28:04 +00:00
. To configure the adapter subsystem, execute the appropriate command.
2018-01-31 13:35:29 +00:00
ifeval::[{project_community}==true]
2021-12-22 10:28:04 +00:00
* Install on WildFly 11 or newer if the server *is not* running
+
2018-01-31 13:35:29 +00:00
[source]
2017-11-10 05:46:35 +00:00
----
2018-12-11 16:42:01 +00:00
$ ./bin/jboss-cli.sh --file=bin/adapter-elytron-install-offline.cli
2017-11-10 05:46:35 +00:00
----
2021-12-22 10:28:04 +00:00
+
* Install on WildFly 11 or newer if the server *is* running
+
2018-01-31 13:35:29 +00:00
[source]
2017-11-10 05:46:35 +00:00
----
2021-12-22 10:28:04 +00:00
$ ./bin/jboss-cli.sh -c --file=bin/adapter-elytron-install.cli
2017-11-10 05:46:35 +00:00
----
2021-12-22 10:28:04 +00:00
+
2018-08-30 11:56:07 +00:00
NOTE: It is possible to use the legacy non-Elytron adapter on WildFly 11 or newer as well, meaning you can use `adapter-install-offline.cli`
even on those versions. However, we recommend to use the newer Elytron adapter.
2021-12-22 10:28:04 +00:00
+
* Install on WildFly 10 or older if the server *is not* running
+
2018-01-31 13:35:29 +00:00
[source]
2017-11-10 05:46:35 +00:00
----
2021-12-22 10:28:04 +00:00
$ ./bin/jboss-cli.sh --file=bin/adapter-install-offline.cli
2017-11-10 05:46:35 +00:00
----
2021-12-22 10:28:04 +00:00
+
* Install on WildFly 10 or older if the server *is* running
+
2017-03-31 15:16:00 +00:00
[source]
----
2021-12-22 10:28:04 +00:00
$ ./bin/jboss-cli.sh -c --file=bin/adapter-install.cli
2017-03-31 15:16:00 +00:00
----
2021-12-22 10:28:04 +00:00
NOTE: Alternatively, you can specify the `server.config` property while installing adapters from the command line to install adapters using a different config, for example: `-Dserver.config=standalone-ha.xml`.
endif::[]
ifeval::[{project_product}==true]
* Install on JBoss EAP 7.1 or newer if the server *is not* running.
+
2016-04-18 19:10:32 +00:00
[source]
----
2021-12-22 10:28:04 +00:00
$ ./bin/jboss-cli.sh --file=bin/adapter-elytron-install-offline.cli
2016-11-29 22:20:33 +00:00
----
2021-12-22 10:28:04 +00:00
+
NOTE: The offline script is not available for JBoss EAP 6.4
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 7.1 or newer if the server *is* running.
+
2017-03-31 15:16:00 +00:00
[source]
----
2018-12-11 16:42:01 +00:00
$ ./bin/jboss-cli.sh -c --file=bin/adapter-elytron-install.cli
2017-03-31 15:16:00 +00:00
----
2021-12-22 10:28:04 +00:00
+
2019-01-18 17:50:38 +00:00
NOTE: It is possible to use the legacy non-Elytron adapter on JBoss EAP 7.1 or newer as well, meaning you can use `adapter-install-offline.cli`
2021-12-22 10:28:04 +00:00
* Install on JBoss EAP 6.4
+
2017-02-02 12:20:15 +00:00
[source]
2016-04-18 19:10:32 +00:00
----
2018-12-11 16:42:01 +00:00
$ ./bin/jboss-cli.sh -c --file=bin/adapter-install.cli
2016-04-18 19:10:32 +00:00
----
2018-01-31 13:35:29 +00:00
endif::[]
2016-04-18 19:10:32 +00:00
2017-12-05 09:27:11 +00:00
===== JBoss SSO
{appserver_name} has built-in support for single sign-on for web applications deployed to the same {appserver_name}
instance. This should not be enabled when using {project_name}.
2021-12-22 10:28:04 +00:00
===== Securing a WAR
2016-04-18 19:10:32 +00:00
2017-02-03 23:34:01 +00:00
This section describes how to secure a WAR directly by adding configuration and editing files within your WAR package.
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
.Procedure
2016-06-06 09:25:35 +00:00
2021-12-22 10:28:04 +00:00
. Create a `keycloak.json` adapter configuration file within the `WEB-INF` directory of your WAR.
+
2017-08-28 12:50:14 +00:00
The format of this configuration file is described in the <<_java_adapter_config,Java adapter configuration>> section.
2021-12-22 10:28:04 +00:00
. Set the `auth-method` to `KEYCLOAK` in `web.xml`.
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
. Use standard servlet security to specify role-base constraints on your URLs.
+
2016-06-03 08:02:59 +00:00
Here's an example:
2021-12-22 10:28:04 +00:00
+
2016-06-03 08:02:59 +00:00
[source,xml]
2016-04-18 19:10:32 +00:00
----
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
2016-06-03 08:02:59 +00:00
<module-name>application</module-name>
2016-04-18 19:10:32 +00:00
<security-constraint>
<web-resource-collection>
<web-resource-name>Admins</web-resource-name>
<url-pattern>/admin/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Customers</web-resource-name>
<url-pattern>/customers/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>this is ignored currently</realm-name>
</login-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
</web-app>
2016-11-29 22:20:33 +00:00
----
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
===== Securing WARs via adapter subsystem
2016-04-18 19:10:32 +00:00
2017-08-28 12:50:14 +00:00
You do not have to modify your WAR to secure it with {project_name}. Instead you can externally secure it via the {project_name} Adapter Subsystem.
2016-04-18 19:10:32 +00:00
While you don't have to specify KEYCLOAK as an `auth-method`, you still have to define the `security-constraints` in `web.xml`.
You do not, however, have to create a `WEB-INF/keycloak.json` file.
2021-12-22 10:28:04 +00:00
The metadata is instead defined within server configuration (`standalone.xml`) in the {project_name} subsystem definition.
2016-04-18 19:10:32 +00:00
2016-06-03 08:02:59 +00:00
[source,xml]
2016-04-18 19:10:32 +00:00
----
<extensions>
<extension module="org.keycloak.keycloak-adapter-subsystem"/>
</extensions>
<profile>
<subsystem xmlns="urn:jboss:domain:keycloak:1.1">
<secure-deployment name="WAR MODULE NAME.war">
<realm>demo</realm>
<auth-server-url>http://localhost:8081/auth</auth-server-url>
<ssl-required>external</ssl-required>
<resource>customer-portal</resource>
<credential name="secret">password</credential>
</secure-deployment>
</subsystem>
</profile>
----
The `secure-deployment` `name` attribute identifies the WAR you want to secure.
2017-08-28 12:50:14 +00:00
Its value is the `module-name` defined in `web.xml` with `.war` appended. The rest of the configuration corresponds pretty much one to one with the `keycloak.json` configuration options defined in <<_java_adapter_config,Java adapter configuration>>.
2016-06-06 09:25:35 +00:00
2016-11-29 22:20:33 +00:00
The exception is the `credential` element.
2016-04-18 19:10:32 +00:00
2021-12-22 10:28:04 +00:00
To make it easier for you, you can go to the {project_name} Admin Console and go to the Client/Installation tab of the application this WAR is aligned with.
2016-11-29 22:20:33 +00:00
It provides an example XML file you can cut and paste.
2016-04-18 19:10:32 +00:00
2016-06-09 12:57:50 +00:00
If you have multiple deployments secured by the same realm you can share the realm configuration in a separate element. For example:
2016-04-18 19:10:32 +00:00
2016-06-03 08:02:59 +00:00
[source,xml]
2016-04-18 19:10:32 +00:00
----
<subsystem xmlns="urn:jboss:domain:keycloak:1.1">
<realm name="demo">
<auth-server-url>http://localhost:8080/auth</auth-server-url>
<ssl-required>external</ssl-required>
</realm>
<secure-deployment name="customer-portal.war">
<realm>demo</realm>
<resource>customer-portal</resource>
<credential name="secret">password</credential>
</secure-deployment>
<secure-deployment name="product-portal.war">
<realm>demo</realm>
<resource>product-portal</resource>
<credential name="secret">password</credential>
</secure-deployment>
<secure-deployment name="database.war">
<realm>demo</realm>
<resource>database-service</resource>
<bearer-only>true</bearer-only>
</secure-deployment>
</subsystem>
2016-11-29 22:20:33 +00:00
----
2017-02-02 12:20:15 +00:00
2021-12-22 10:28:04 +00:00
===== Security domain
2017-02-02 12:20:15 +00:00
2021-12-22 10:28:04 +00:00
The security context is propagated to the EJB tier automatically.