keycloak-scim/docs/guides/securing-apps/partials/saml/required_per_war_configuration.adoc

62 lines
2 KiB
Text
Raw Normal View History

2016-06-02 16:07:45 +00:00
=== Securing a WAR
2016-06-02 16:07:45 +00:00
This section describes how to secure a WAR directly by adding config and editing files within your WAR package.
Once `keycloak-saml.xml` is created and in the `WEB-INF` directory of your WAR, you must set the `auth-method` to `KEYCLOAK-SAML` in `web.xml`.
2016-06-02 16:07:45 +00:00
You also have to use standard servlet security to specify role-base constraints on your URLs.
2016-06-02 21:18:42 +00:00
Here's an example _web.xml_ file:
2016-06-02 16:07:45 +00:00
[source,xml]
----
<web-app xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd"
version="6.0">
2016-06-02 16:07:45 +00:00
<module-name>customer-portal</module-name>
<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-SAML</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-06-02 21:18:42 +00:00
----
All standard servlet settings except the `auth-method` setting.
2016-06-02 16:07:45 +00:00