JBoss/Wildfly Adapter
To be able to secure WAR apps deployed on JBoss EAP 6.x or Wildfly, you must install and
configure the Keycloak SAML Adapter Subsystem. You then provide a keycloak
config, /WEB-INF/keycloak-saml file in your WAR and change the auth-method to KEYCLOAK-SAML within web.xml.
Both methods are described in this section.
Adapter Installation
SAML Adapters are no longer included with the appliance or war distribution.Each adapter is a separate download on
the Keycloak download site. They are also available as a maven artifact.
Install on Wildfly 9:
$ cd $WILDFLY_HOME
$ unzip keycloak-saml-wf9-adapter-dist.zip
Install on JBoss EAP 6.x:
$ cd $JBOSS_HOME
$ unzip keycloak-saml-eap6-adapter-dist.zip
This zip file creates new JBoss Modules specific to the Wildfly Keycloak SAML Adapter within your Wildfly distro.
After adding the Keycloak modules, you must then enable the Keycloak SAML Subsystem within your app server's server configuration:
domain.xml or standalone.xml.
There is a CLI script that will help you modify your server configuration. Start the server and run the script
from the server's bin directory:
$ cd $JBOSS_HOME/bin
$ jboss-cli.sh -c --file=adapter-install.cli
The script will add the extension, subsystem, and optional security-domain as described below.
...
...
]]>
The keycloak security domain should be used with EJBs and other components when you need the security context created
in the secured web tier to be propagated to the EJBs (other EE component) you are invoking. Otherwise
this configuration is optional.
...
]]>
For example, if you have a JAX-RS service that is an EJB within your WEB-INF/classes directory, you'll want
to annotate it with the @SecurityDomain annotation as follows:
getCustomers() {
return db.getCustomers();
}
}
]]>
We hope to improve our integration in the future so that you don't have to specify the @SecurityDomain
annotation when you want to propagate a keycloak security context to the EJB tier.
Required Per WAR Configuration
This section describes how to secure a WAR directly by adding config and editing files within your WAR package.
The first thing you must do is create
a keycloak-saml.xml adapter config file within the WEB-INF directory
of your WAR. The format of this config file is describe in the general adapter configuration
section.
Next you must set the auth-method to KEYCLOAK-SAML in web.xml. You also
have to use standard servlet security to specify role-base constraints on your URLs. Here's an example
pulled from one of the examples that comes distributed with Keycloak.
customer-portalAdmins/admin/*adminCONFIDENTIALCustomers/customers/*userCONFIDENTIALKEYCLOAK-SAMLthis is ignored currentlyadminuser
]]>