pattern = Pattern.compile(samlTokenHttpHeaderRegEx, Pattern.DOTALL); Matcher m = pattern.matcher(content); m.matches(); m.group(samlTokenHttpHeaderRegExGroup)
org.picketlink.identity.federation.bindings.jboss.auth.SAMLTokenCertValidatingLoginModule
Peter Skopek
This LoginModule authenticates clients by validating their SAML assertions locally. If the supplied assertion contains roles, these roles are extracted and included in the Group returned by the getRoleSets method.
The LoginModule is designed to validate SAML token using X509 certificate stored in XML signature within SAML assertion token.
It validates:
CertPath against specified truststore. It has to have common valid public certificate in the trusted entries.
X509 certificate stored in SAML token didn't expire
if signature itself is valid
SAML token expiration
This module defines the following module options:
roleKey: key of the attribute name that we need to use for Roles from the SAML assertion. This can be a comma-separated string values such as (Role,Membership)
localValidationSecurityDomain: the security domain for the trust store information (via the JaasSecurityDomain)
cache.invalidation - set it to true if you require invalidation of JBoss Auth Cache at SAML Principal expiration.
jboss.security.security_domain -security domain at which Principal will expire if cache.invalidation is used.
tokenEncodingType: encoding type of SAML token delivered via http request's header.
Possible values are:
base64 - content encoded as base64. In case of encoding will vary between base64 and gzip use base64 and LoginModule will detect gzipped data.
gzip - gzipped content encoded as base64
none - content not encoded in any way
samlTokenHttpHeader - name of http request header to fetch SAML token from. For example: "Authorize"
samlTokenHttpHeaderRegEx - Java regular expression to be used to get SAML token from "samlTokenHttpHeader". Example: use: ."(.)".* to parse SAML token from header content like this: SAML_assertion="HHDHS=", at the same time set samlTokenHttpHeaderRegExGroup to 1.
samlTokenHttpHeaderRegExGroup - Group value to be used when parsing out value of http request header specified by "samlTokenHttpHeader" using "samlTokenHttpHeaderRegEx".
pattern = Pattern.compile(samlTokenHttpHeaderRegEx, Pattern.DOTALL); Matcher m = pattern.matcher(content); m.matches(); m.group(samlTokenHttpHeaderRegExGroup)
Example Configuration 1:
<application-policy xmlns="urn:jboss:security-beans:1.0" name="certpath"> <authentication> <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAMLTokenCertValidatingLoginModule" flag="required"> <module-option name="password-stacking">useFirstPass</module-option> <module-option name="cache.invalidation">true</module-option> <module-option name="localValidationSecurityDomain">java:jaas/localValidationDomain</module-option> </login-module> </authentication> </application-policy>
Example Configuration 2 using http header:
<application-policy xmlns="urn:jboss:security-beans:1.0" name="service"> <authentication> <login-module code="org.picketlink.identity.federation.bindings.jboss.auth.SAML2STSLoginModule" flag="required"> <module-option name="password-stacking">useFirstPass</module-option> <module-option name="cache.invalidation">true</module-option> <module-option name="localValidationSecurityDomain">java:jaas/localValidationDomain</module-option> <module-option name="tokenEncodingType">gzip</module-option> <module-option name="samlTokenHttpHeader">Auth</module-option> <module-option name="samlTokenHttpHeaderRegEx">.*"(.*)".*</module-option> <module-option name="samlTokenHttpHeaderRegExGroup">1</module-option> </login-module> </authentication> </application-policy>
Example of jboss-beans.xml file to use to configure JAAS Security Domain containing trust store for above examples:
<?xml version="1.0" encoding="UTF-8"?> <deployment xmlns="urn:jboss:bean-deployer:2.0"> <!-- localValidationDomain bean --> <bean name="LocalValidationBean" class="org.jboss.security.plugins.JaasSecurityDomain"> <constructor> <parameter>localValidationDomain</parameter> </constructor> <property name="keyStoreURL">file://${jboss.server.home.dir}/conf/stspub.jks</property> <property name="keyStorePass">keypass</property> <property name="keyStoreAlias">sts</property> <property name="securityManagement"><inject bean="JNDIBasedSecurityManagement"/></property> </bean> </deployment>