commit
960cd8c822
5 changed files with 122 additions and 12 deletions
|
@ -47,6 +47,7 @@
|
||||||
<!ENTITY ProtocolMappers SYSTEM "modules/protocol-mappers.xml">
|
<!ENTITY ProtocolMappers SYSTEM "modules/protocol-mappers.xml">
|
||||||
<!ENTITY Recaptcha SYSTEM "modules/recaptcha.xml">
|
<!ENTITY Recaptcha SYSTEM "modules/recaptcha.xml">
|
||||||
<!ENTITY AuthSPI SYSTEM "modules/auth-spi.xml">
|
<!ENTITY AuthSPI SYSTEM "modules/auth-spi.xml">
|
||||||
|
<!ENTITY FilterAdapter SYSTEM "modules/servlet-filter-adapter.xml">
|
||||||
]>
|
]>
|
||||||
|
|
||||||
<book>
|
<book>
|
||||||
|
@ -105,6 +106,7 @@ This one is short
|
||||||
&TomcatAdapter;
|
&TomcatAdapter;
|
||||||
&Jetty9Adapter;
|
&Jetty9Adapter;
|
||||||
&Jetty8Adapter;
|
&Jetty8Adapter;
|
||||||
|
&FilterAdapter;
|
||||||
&FuseAdapter;
|
&FuseAdapter;
|
||||||
&JavascriptAdapter;
|
&JavascriptAdapter;
|
||||||
&SpringBootAdapter;
|
&SpringBootAdapter;
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
<section>
|
||||||
|
<title>Java Servlet Filter Adapter</title>
|
||||||
|
<para>
|
||||||
|
If you want to use Keycloak with a Java servlet application that doesn't have an adapter for that servlet
|
||||||
|
platform, you can opt to use the servlet filter adapter that Keycloak has. This adapter works a little
|
||||||
|
differently than the other adapters. You do not define security constraints in web.xml. Instead you define
|
||||||
|
a filter mapping using the Keycloak servlet filter adapter to secure the url patterns you want to secure.
|
||||||
|
</para>
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
Backchannel logout works a bit differently than the standard adapters. Instead of invalidating the http session
|
||||||
|
it instead marks the session id as logged out. There's just no way of arbitrarily invalidating an http session
|
||||||
|
based on a session id.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<module-name>customer-portal</module-name>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>Keycloak Filter</filter-name>
|
||||||
|
<filter-class>org.keycloak.adapters.servlet.KeycloakOIDCFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>Keycloak Filter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
</web-app>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
The Keycloak filter has the same configuration parameters available as the other adapters except you must define
|
||||||
|
them as filter init params instead of context params.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
To use this filter, include this maven artifact in your WAR poms
|
||||||
|
</para>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-servlet-filter-adapter</artifactId>
|
||||||
|
<version>&project.version;</version>
|
||||||
|
</dependency>
|
||||||
|
]]></programlisting>
|
||||||
|
</section>
|
|
@ -7,6 +7,7 @@
|
||||||
<!ENTITY TomcatAdapter SYSTEM "modules/tomcat-adapter.xml">
|
<!ENTITY TomcatAdapter SYSTEM "modules/tomcat-adapter.xml">
|
||||||
<!ENTITY Jetty9Adapter SYSTEM "modules/jetty9-adapter.xml">
|
<!ENTITY Jetty9Adapter SYSTEM "modules/jetty9-adapter.xml">
|
||||||
<!ENTITY Jetty8Adapter SYSTEM "modules/jetty8-adapter.xml">
|
<!ENTITY Jetty8Adapter SYSTEM "modules/jetty8-adapter.xml">
|
||||||
|
<!ENTITY FilterAdapter SYSTEM "modules/servlet-filter-adapter.xml">
|
||||||
<!ENTITY Logout SYSTEM "modules/logout.xml">
|
<!ENTITY Logout SYSTEM "modules/logout.xml">
|
||||||
]>
|
]>
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ This one is short
|
||||||
&TomcatAdapter;
|
&TomcatAdapter;
|
||||||
&Jetty9Adapter;
|
&Jetty9Adapter;
|
||||||
&Jetty8Adapter;
|
&Jetty8Adapter;
|
||||||
|
&FilterAdapter;
|
||||||
&Logout;
|
&Logout;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,13 @@
|
||||||
<para>
|
<para>
|
||||||
Here is the explanation of the SP element attributes
|
Here is the explanation of the SP element attributes
|
||||||
</para>
|
</para>
|
||||||
<para><![CDATA[
|
<programlisting><![CDATA[
|
||||||
<SP entityID="sp"
|
<SP entityID="sp"
|
||||||
sslPolicy="ssl"
|
sslPolicy="ssl"
|
||||||
nameIDPolicyFormat="format"
|
nameIDPolicyFormat="format"
|
||||||
forceAuthentication="true">
|
forceAuthentication="true">
|
||||||
...
|
...
|
||||||
</SP>]]></para>
|
</SP>]]></programlisting>
|
||||||
<para>
|
<para>
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
or you can cut and paste the keys directly within <literal>keycloak-saml.xml</literal>
|
or you can cut and paste the keys directly within <literal>keycloak-saml.xml</literal>
|
||||||
in the PEM format.
|
in the PEM format.
|
||||||
</para>
|
</para>
|
||||||
<para><![CDATA[
|
<programlisting><![CDATA[
|
||||||
<Keys>
|
<Keys>
|
||||||
<Key signing="true" >
|
<Key signing="true" >
|
||||||
<KeyStore resource="/WEB-INF/keystore.jks" password="store123">
|
<KeyStore resource="/WEB-INF/keystore.jks" password="store123">
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
</Key>
|
</Key>
|
||||||
</Keys>
|
</Keys>
|
||||||
]]>
|
]]>
|
||||||
</para>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
The <literal>Key</literal> element has two optional attributes <literal>signing</literal>
|
The <literal>Key</literal> element has two optional attributes <literal>signing</literal>
|
||||||
and <literal>encryption</literal>. When set to true these tell the adapter what the
|
and <literal>encryption</literal>. When set to true these tell the adapter what the
|
||||||
|
@ -215,13 +215,13 @@
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<title>RoleIdentifiers element</title>
|
<title>RoleIdentifiers element</title>
|
||||||
<para><![CDATA[
|
<programlisting><![CDATA[
|
||||||
<RoleIdentifiers>
|
<RoleIdentifiers>
|
||||||
<Attribute name="Role"/>
|
<Attribute name="Role"/>
|
||||||
<Attribute name="member"/>
|
<Attribute name="member"/>
|
||||||
<Attribute name="memberOf"/>
|
<Attribute name="memberOf"/>
|
||||||
</RoleIdentifiers>
|
</RoleIdentifiers>
|
||||||
]]></para>
|
]]></programlisting>
|
||||||
<para>
|
<para>
|
||||||
This element is optional. It defines which SAML attribute values in the assertion should be
|
This element is optional. It defines which SAML attribute values in the assertion should be
|
||||||
mapped to a Java EE role. By default <literal>Role</literal> attribute values are converted
|
mapped to a Java EE role. By default <literal>Role</literal> attribute values are converted
|
||||||
|
@ -236,7 +236,7 @@
|
||||||
Everything in the IDP element describes the settings for the IDP the SP is communicating
|
Everything in the IDP element describes the settings for the IDP the SP is communicating
|
||||||
with.
|
with.
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<programlisting>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
<IDP entityID="idp"
|
<IDP entityID="idp"
|
||||||
signaturesRequired="true"
|
signaturesRequired="true"
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
signatureCanonicalizationMethod="http://www.w3.org/2001/10/xml-exc-c14n#">
|
signatureCanonicalizationMethod="http://www.w3.org/2001/10/xml-exc-c14n#">
|
||||||
...
|
...
|
||||||
</IDP>]]>
|
</IDP>]]>
|
||||||
</para>
|
</programlisting>
|
||||||
<para>
|
<para>
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -300,12 +300,12 @@
|
||||||
The <literal>SignleSignOnService</literal> sub element defines the
|
The <literal>SignleSignOnService</literal> sub element defines the
|
||||||
login SAML endpoint of the IDP.
|
login SAML endpoint of the IDP.
|
||||||
</para>
|
</para>
|
||||||
<para><![CDATA[
|
<programlisting><![CDATA[
|
||||||
<SingleSignOnService signRequest="true"
|
<SingleSignOnService signRequest="true"
|
||||||
validateResponseSignature="true"
|
validateResponseSignature="true"
|
||||||
requestBinding="post"
|
requestBinding="post"
|
||||||
bindingUrl="url"/>
|
bindingUrl="url"/>
|
||||||
]]></para>
|
]]></programlisting>
|
||||||
<para>
|
<para>
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
@ -367,7 +367,7 @@
|
||||||
The <literal>SignleSignOnService</literal> sub element defines the
|
The <literal>SignleSignOnService</literal> sub element defines the
|
||||||
login SAML endpoint of the IDP.
|
login SAML endpoint of the IDP.
|
||||||
</para>
|
</para>
|
||||||
<para><![CDATA[
|
<programlisting><![CDATA[
|
||||||
<SingleLogoutService validateRequestSignature="true"
|
<SingleLogoutService validateRequestSignature="true"
|
||||||
validateResponseSignature="true"
|
validateResponseSignature="true"
|
||||||
signRequest="true"
|
signRequest="true"
|
||||||
|
@ -376,7 +376,7 @@
|
||||||
responseBinding="post"
|
responseBinding="post"
|
||||||
postBindingUrl="posturl"
|
postBindingUrl="posturl"
|
||||||
redirectBindingUrl="redirecturl">
|
redirectBindingUrl="redirecturl">
|
||||||
]]></para>
|
]]></programlisting>
|
||||||
<para>
|
<para>
|
||||||
<variablelist>
|
<variablelist>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<chapter>
|
||||||
|
<title>Java Servlet Filter Adapter</title>
|
||||||
|
<para>
|
||||||
|
If you want to use SAML with a Java servlet application that doesn't have an adapter for that servlet
|
||||||
|
platform, you can opt to use the servlet filter adapter that Keycloak has. This adapter works a little
|
||||||
|
differently than the other adapters. You do not define security constraints in web.xml. Instead you define
|
||||||
|
a filter mapping using the Keycloak servlet filter adapter to secure the url patterns you want to secure.
|
||||||
|
</para>
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
Backchannel logout works a bit differently than the standard adapters. Instead of invalidating the http session
|
||||||
|
it instead marks the session id as logged out. There's just no way of arbitrarily invalidating an http session
|
||||||
|
based on a session id.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
<warning>
|
||||||
|
<para>
|
||||||
|
Backchannel logout does not currently work when you have a clustered application that uses the SAML filter.
|
||||||
|
</para>
|
||||||
|
</warning>
|
||||||
|
<programlisting>
|
||||||
|
<![CDATA[
|
||||||
|
<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">
|
||||||
|
|
||||||
|
<module-name>customer-portal</module-name>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<filter-name>Keycloak Filter</filter-name>
|
||||||
|
<filter-class>org.keycloak.adapters.saml.servlet.SamlFilter</filter-class>
|
||||||
|
</filter>
|
||||||
|
<filter-mapping>
|
||||||
|
<filter-name>Keycloak Filter</filter-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</filter-mapping>
|
||||||
|
</web-app>
|
||||||
|
]]>
|
||||||
|
</programlisting>
|
||||||
|
<para>
|
||||||
|
The Keycloak filter has the same configuration parameters available as the other adapters except you must define
|
||||||
|
them as filter init params instead of context params.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
To use this filter, include this maven artifact in your WAR poms
|
||||||
|
</para>
|
||||||
|
<programlisting><![CDATA[
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.keycloak</groupId>
|
||||||
|
<artifactId>keycloak-saml-servlet-filter-adapter</artifactId>
|
||||||
|
<version>&project.version;</version>
|
||||||
|
</dependency>
|
||||||
|
]]></programlisting>
|
||||||
|
</chapter>
|
Loading…
Reference in a new issue