cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache CXF Documentation > SAML Web SSO
Date Mon, 25 Jun 2012 13:04:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/SAML+Web+SSO">SAML
Web SSO</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~sergey_beryozkin">Sergey
Beryozkin</a>
    </h4>
        <br/>
                         <h4>Changes (7)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >SP Security Filter protects the application
endpoints by checking that a valid SSO security context is available. If it is then the filter
lets the request to continue, if not then it redirects the current user to IDP. <br>
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">When
a filter redirects a user to IDP, it creates a SAML Authentication Request, see [this page|http://en.wikipedia.org/wiki/SAML_2.0#Web_Browser_SSO_Profile]
for the example and appends it to the IDP Service URI or gets it POSTed to IDP. <br>Additionally,
a RelayState token pointing to the state of the current user request is also included which
IDP will  <br>return to Request Assertion Consumer Service (RACS) after the user has
authenticated.  <br> <br></td></tr>
            <tr><td class="diff-unchanged" >CXF offers two SP Security filters,
one for redirecting the user back to IDP via GET and another one - via POST. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >3. Reference to SSO State Provider.
<br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
following optional property affecting the created SAML request may also be set: <br>*
String issuerId - it defaults to the base URI of the application endpoint protected by this
filter, for example, &quot;http://localhost:8080/services/app1&quot;. <br> <br>The
IDP address is where filters will redirect users to and the RACS address is where users will
be redirected by IDP to. <br>RACS will set up a security context and redirect the user
back to the original application address by using the RelayState token which is included by
the filters when users are initially redirected to IDP. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h2. POST Binding Filter <br>
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Note
that the POST binding filter has the same base properties as org.apache.cxf.rs.security.saml.sso.SamlRedirectBindingFilter
has but also  <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">Note that the POST binding filter has the same 3 required properties as org.apache.cxf.rs.security.saml.sso.SamlRedirectBindingFilter
has but also</span> sets a &quot;useDeflateEncoding&quot; property for getting
a SAML request deflated. Some IDPs might not be able to process deflated SAML requests with
POST binding redirects thus the compression may be optionally disabled. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>What is actually different
in this case from the GET-based redirect is that the filter prepares an instance of [SAMLRequestInfo|http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRequestInfo.java]
which is subsequently bound to an XHTML view via a JSP filter. The view will typically have
a Java Script handler which will actually redirect the user to IDP when it is loaded into
the browser. The data to view binding is facilitated by org.apache.cxf.jaxrs.provider.RequestDispatcherProvider,
please see [this page|http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection-WithRequestDispatcherProvider]
for more information. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br>One may prefer using the POST binding filter in cases where having SAML request
to IDP encoded as a URI parameter prohibited. <br> <br></td></tr>
            <tr><td class="diff-unchanged" >Here is a typical JSP handler for
binding org.apache.cxf.rs.security.saml.sso.SAMLRequestInfo to the view: <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{code} <br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">h2.
Signing SAML Authentication Requests <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
filters may optionally sign SAML requests, the following configuration properties can be set-up:
<br> <br>* boolean signRequest - Whether to sign the AuthnRequest or not. The
default is false. <br>* String signatureUsername - The keystore alias to use to sign
the AuthnRequest. <br>* Crypto signatureCrypto - A WSS4J Crypto object if the SAML AuthnRequest
is to be signed. <br>*    String signaturePropertiesFile - This points to a properties
file that can be used to load a Crypto instance if the SAML AuthnRequest is to be signed.
 <br>*    CallbackHandler callbackHandler - A CallbackHandler object to retrieve the
private key password used to sign the request. <br>*    String callbackHandlerClass
- A class name that is loaded for use as the CallbackHandler object.  <br> <br>Either
the &quot;signatureCrypto&quot; or &quot;signaturePropertiesFile&quot; properties
must be set if &quot;signRequest&quot; is set to true. Similarly, either &quot;callbackHandler&quot;
or &quot;callbackHandlerClass&quot; must be configured. <br> <br>h2. Filters
and State Management <br> <br>The following properties affect the way filters
manage the SSO state: <br> <br>* [SPStateManager|http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/state/SPStateManager.java]
stateProvider <br>* long stateTimeToLive - default is 2 minutes (in milliseconds). <br>*
String webAppDomain. <br>* boolean addWebAppContext - default is true. <br>* boolean
boolean addEndpointAddressToContext - default is false. <br> <br>The &#39;stateProvider&#39;
refers to a custom [SPStateManager|http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/state/SPStateManager.java]
implementation and is used for filters and RACS coordinating with the filters persisting the
current user request state, RACS validating it and persisting the current security context
state and filters getting the information about the context. Filters and RACS use a &#39;RelayState&#39;
token to work with the current request state. RACS persists the security context and the filters
retrieve and validate it using the cookie which RACS also sets to point to this security context.
<br> <br>Note that a &#39;stateTimeToLive&#39; property can be used to
control how long the current security context can be valid for. <br> <br>Both
filters and RACS use opaque cookies to refer to the original request and security context
state and &#39;webAppDomain&#39;, &#39;addWebAppContext&#39; and &#39;addEndpointAddressToContext&#39;
affect the way these cookies can be shared between multiple SP custom applications. <br>
<br>For example, here is a typical Set Cookie request issued by a web application to
the browser: <br>{code:java} <br>Set-Cookie: value; Domain=mydomain; Path=/accounts;
Expires=Wed, 13-Jan-2021 22:23:01 GMT; <br>{code} <br> <br>By default, CXF
will get a Cookie &#39;Path&#39; property set to something like &quot;/services&quot;,
where &#39;services&#39; is the actual name of the war archive. <br>The &#39;addEndpointAddressToContext&#39;
property can be further restrict this path to something like &quot;/services/app1&quot;,
&quot;/services/app2&quot;, where &quot;/app1&quot; and &quot;/app2&quot;
are jaxrs:endpoint addresses, this can be handy for testing, with every jaxrs:endpoint within
a single war having its own security context. <br>If the custom SP application is &#39;spread&#39;
across multiple containers with different application context names, then the &#39;addWebAppContext&#39;
can be set to &#39;false&#39; leading to Cookie &#39;Path&#39; parameters
set to &#39;/&#39; and the &#39;webAppDomain&#39; property set to some shared
value. <br> <br>Note that the stateTimeToLive property affects a Cookie &#39;Expires&#39;
property but also used by filters and RACS to enforce that the internal state has not expired.
<br> <br> <br></td></tr>
            <tr><td class="diff-unchanged" >h1. Request Assertion Security Service
<br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p><span style="font-size:2em;font-weight:bold"> JAX-RS: SAML Web SSO</span></p>


<div>
<ul>
    <li><a href='#SAMLWebSSO-Introduction'>Introduction</a></li>
<ul>
    <li><a href='#SAMLWebSSO-TypicalFlow'>Typical Flow</a></li>
</ul>
    <li><a href='#SAMLWebSSO-Mavendependencies'>Maven dependencies</a></li>
    <li><a href='#SAMLWebSSO-IdentityProvider'>Identity Provider</a></li>
    <li><a href='#SAMLWebSSO-ServiceProviderSecurityFilter'>Service Provider Security
Filter</a></li>
<ul>
    <li><a href='#SAMLWebSSO-RedirectBindingFilter'>Redirect Binding Filter</a></li>
    <li><a href='#SAMLWebSSO-POSTBindingFilter'>POST Binding Filter</a></li>
    <li><a href='#SAMLWebSSO-SigningSAMLAuthenticationRequests'>Signing SAML Authentication
Requests</a></li>
    <li><a href='#SAMLWebSSO-FiltersandStateManagement'>Filters and State Management</a></li>
</ul>
    <li><a href='#SAMLWebSSO-RequestAssertionSecurityService'>Request Assertion
Security Service</a></li>
    <li><a href='#SAMLWebSSO-SSOStateProvider'>SSO State Provider</a></li>
</ul></div>

<h1><a name="SAMLWebSSO-Introduction"></a>Introduction</h1>

<p><a href="http://en.wikipedia.org/wiki/Single_sign-on" class="external-link" rel="nofollow">SSO</a>
is about a user having to sign in only once when interacting with a custom web application
which may offer of a number of individual endpoints. </p>

<p>CXF 2.6.1 introduces a comprehensive service provider (SP) support for the SAML Web
SSO <a href="http://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf" class="external-link"
rel="nofollow">profile</a>. This <a href="http://en.wikipedia.org/wiki/SAML_2.0"
class="external-link" rel="nofollow">page</a> also offers a good overview of the
<a href="http://en.wikipedia.org/wiki/SAML_2.0#Web_Browser_SSO_Profile" class="external-link"
rel="nofollow">profile</a>.</p>

<p>HTTP Redirect(via GET) and POST bindings are supported. The module has been tested
against many IDP providers and is easily configurable.</p>

<p>The following components are required to get SSO supported:</p>

<ul class="alternate" type="square">
	<li>Identity Provider (IDP) supporting SAML SSO</li>
	<li>Request Assertion Consumer Service (RACS)</li>
	<li>Service Provider Security Filter</li>
	<li>SSO State Provider</li>
</ul>


<p>The following sections will describe these components in more details</p>

<h2><a name="SAMLWebSSO-TypicalFlow"></a>Typical Flow</h2>

<p>Typically, the following flow represents the way SAML SSO is enforced:</p>

<p>1. User accesses a custom application for the first time<br/>
2. Service Provider Security Filter checks if the security context is available <br/>
   and redirects the user to IDP with a SAML SSO request<br/>
3. IDP challenges the user with the authentication dialog and redirects the user to<br/>
   Request Assertion Consumer Service (RACS) after the user has authenticated<br/>
4. RACS validates the response from IDP, establishes a security context and redirects the
user <br/>
   to the original application endpoint<br/>
5. Service Provider Security Filter enforces that a valid security context is available and
lets the user<br/>
   access the custom application.</p>

<h1><a name="SAMLWebSSO-Mavendependencies"></a>Maven dependencies</h1>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
  <span class="code-tag">&lt;groupId&gt;</span>org.apache.cxf<span
class="code-tag">&lt;/groupId&gt;</span>
  <span class="code-tag">&lt;artifactId&gt;</span>cxf-rt-rs-security-sso-saml<span
class="code-tag">&lt;/artifactId&gt;</span>
  <span class="code-tag">&lt;version&gt;</span>2.6.1<span class="code-tag">&lt;/version&gt;</span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h1><a name="SAMLWebSSO-IdentityProvider"></a>Identity Provider</h1>

<p>Identity Provider (IDP) is the service which accepts the redirect requests from application
security filters, authenticates users and redirects them back to Request Assertion Security
Service.</p>

<p>CXF does not offer its own IDP SAML Web SSO implementation but might provide it in
the future as part of the <a href="http://cxf.apache.org/fediz.html" class="external-link"
rel="nofollow">Fediz</a> project.</p>

<p>However, CXF has been tested against a number of popular IDP implementations which
support SAML SSO and thus should be interoperable with whatever IDP is being used in the specific
production environment. The interoperability tests have shown that some IDPs may process SAML
request and produce SAML response data the way which may not be exactly specification-compliant
and thus CXF Request Assertion Consumer Service (RACS) and Service Provider Security Filter
implementations have a number of configuration properties for adjusting the way SAML requests
to IDP are prepared and SAML responses from IDP are processed.</p>

<h1><a name="SAMLWebSSO-ServiceProviderSecurityFilter"></a>Service Provider
Security Filter</h1>

<p>SP Security Filter protects the application endpoints by checking that a valid SSO
security context is available. If it is then the filter lets the request to continue, if not
then it redirects the current user to IDP.</p>

<p>When a filter redirects a user to IDP, it creates a SAML Authentication Request,
see <a href="http://en.wikipedia.org/wiki/SAML_2.0#Web_Browser_SSO_Profile" class="external-link"
rel="nofollow">this page</a> for the example and appends it to the IDP Service URI
or gets it POSTed to IDP.<br/>
Additionally, a RelayState token pointing to the state of the current user request is also
included which IDP will <br/>
return to Request Assertion Consumer Service (RACS) after the user has authenticated. </p>

<p>CXF offers two SP Security filters, one for redirecting the user back to IDP via
GET and another one - via POST.</p>

<h2><a name="SAMLWebSSO-RedirectBindingFilter"></a>Redirect Binding Filter</h2>

<p>Redirect Binding Filter is implemented by org.apache.cxf.rs.security.saml.sso.SamlRedirectBindingFilter.</p>

<p>Here is an example of a typical filter protecting a custom JAX-RS endpoint:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;bean id=<span class="code-quote">"serviceBean"</span>
class=<span class="code-quote">"org.apache.cxf.samlp.sso.BookStore"</span>/&gt;</span>

<span class="code-tag">&lt;jaxrs:server address=<span class="code-quote">"/app1"</span>&gt;</span>

       <span class="code-tag">&lt;jaxrs:serviceBeans&gt;</span>
          <span class="code-tag">&lt;ref bean=<span class="code-quote">"serviceBean"</span>/&gt;</span>
       <span class="code-tag">&lt;/jaxrs:serviceBeans&gt;</span>
       <span class="code-tag">&lt;jaxrs:providers&gt;</span>
          <span class="code-tag">&lt;ref bean=<span class="code-quote">"redirectGetFilter"</span>/&gt;</span>
       <span class="code-tag">&lt;/jaxrs:providers&gt;</span>
<span class="code-tag">&lt;/jaxrs:server&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"redirectGetFilter"</span>
class=<span class="code-quote">"org.apache.cxf.rs.security.saml.sso.SamlRedirectBindingFilter"</span>&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"idpServiceAddress"</span>
value=<span class="code-quote">"https://localhost:9443/idp"</span>/&gt;</span>
      <span class="code-tag"><span class="code-comment">&lt;!-- both relative
and absolute URIs are supported --&gt;</span></span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"assertionConsumerServiceAddress"</span>
value=<span class="code-quote">"/racs/sso"</span>/&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"stateProvider"</span>
ref=<span class="code-quote">"stateManager"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>


<span class="code-tag">&lt;bean id=<span class="code-quote">"stateManager"</span>
class=<span class="code-quote">"org.apache.cxf.rs.security.saml.sso.state.EHCacheSPStateManager"</span>&gt;</span>
    <span class="code-tag">&lt;constructor-arg ref=<span class="code-quote">"cxf"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>

</pre>
</div></div>

<p>Note that at the very minimum the filter needs to have 3 properties set-up:<br/>
1. IDP service address<br/>
2. RACS address - it can be absolute or relative if RACS is collocated <br/>
  (shares the same web application context) with the application endpoint.<br/>
3. Reference to SSO State Provider.</p>

<p>The following optional property affecting the created SAML request may also be set:</p>
<ul>
	<li>String issuerId - it defaults to the base URI of the application endpoint protected
by this filter, for example, "http://localhost:8080/services/app1".</li>
</ul>


<p>The IDP address is where filters will redirect users to and the RACS address is where
users will be redirected by IDP to.<br/>
RACS will set up a security context and redirect the user back to the original application
address by using the RelayState token which is included by the filters when users are initially
redirected to IDP.</p>

<h2><a name="SAMLWebSSO-POSTBindingFilter"></a>POST Binding Filter</h2>

<p>POST Binding Filter is implemented by org.apache.cxf.rs.security.saml.sso.SamlPostBindingFilter.</p>

<p>Here is an example of a typical filter protecting a custom JAX-RS endpoint.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;bean id=<span class="code-quote">"serviceBean"</span>
class=<span class="code-quote">"org.apache.cxf.samlp.sso.BookStore"</span>/&gt;</span>
<span class="code-tag">&lt;jaxrs:server address=<span class="code-quote">"/app2"</span>&gt;</span>

    <span class="code-tag">&lt;jaxrs:serviceBeans&gt;</span>
       <span class="code-tag">&lt;ref bean=<span class="code-quote">"serviceBean"</span>/&gt;</span>
     <span class="code-tag">&lt;/jaxrs:serviceBeans&gt;</span>
     <span class="code-tag">&lt;jaxrs:providers&gt;</span>
          <span class="code-tag">&lt;ref bean=<span class="code-quote">"ssoRedirectPOST"</span>/&gt;</span>
          <span class="code-tag">&lt;ref bean=<span class="code-quote">"samlRequestFormCreator"</span>/&gt;</span>

     <span class="code-tag">&lt;/jaxrs:providers&gt;</span>
       
<span class="code-tag">&lt;/jaxrs:server&gt;</span>

<span class="code-tag">&lt;bean id=<span class="code-quote">"ssoRedirectPOST"</span>
class=<span class="code-quote">"org.apache.cxf.rs.security.saml.sso.SamlPostBindingFilter"</span>&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"idpServiceAddress"</span>
value=<span class="code-quote">"https://localhost:9443/idp"</span>/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"assertionConsumerServiceAddress"</span>
value=<span class="code-quote">"/racs/sso"</span>/&gt;</span>
        <span class="code-tag">&lt;property name=<span class="code-quote">"stateProvider"</span>
ref=<span class="code-quote">"stateManager"</span>/&gt;</span>

        <span class="code-tag">&lt;property name=<span class="code-quote">"useDeflateEncoding"</span>
value=<span class="code-quote">"true"</span>/&gt;</span>
&lt;/bean

<span class="code-tag">&lt;bean id=<span class="code-quote">"samlRequestFormCreator"</span>
class=<span class="code-quote">"org.apache.cxf.jaxrs.provider.RequestDispatcherProvider"</span>&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"dispatcherName"</span>
value=<span class="code-quote">"jsp"</span>/&gt;</span>
      <span class="code-tag">&lt;property name=<span class="code-quote">"useClassNames"</span>
value=<span class="code-quote">"true"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>
    
<span class="code-tag">&lt;bean id=<span class="code-quote">"stateManager"</span>
class=<span class="code-quote">"org.apache.cxf.rs.security.saml.sso.state.EHCacheSPStateManager"</span>&gt;</span>
    <span class="code-tag">&lt;constructor-arg ref=<span class="code-quote">"cxf"</span>/&gt;</span>
<span class="code-tag">&lt;/bean&gt;</span>


</pre>
</div></div>

<p>Note that the POST binding filter has the same 3 required properties as org.apache.cxf.rs.security.saml.sso.SamlRedirectBindingFilter
has but also sets a "useDeflateEncoding" property for getting a SAML request deflated. Some
IDPs might not be able to process deflated SAML requests with POST binding redirects thus
the compression may be optionally disabled.</p>

<p>What is actually different in this case from the GET-based redirect is that the filter
prepares an instance of <a href="http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SamlRequestInfo.java"
class="external-link" rel="nofollow">SAMLRequestInfo</a> which is subsequently bound
to an XHTML view via a JSP filter. The view will typically have a Java Script handler which
will actually redirect the user to IDP when it is loaded into the browser. The data to view
binding is facilitated by org.apache.cxf.jaxrs.provider.RequestDispatcherProvider, please
see <a href="http://cxf.apache.org/docs/jax-rs-redirection.html#JAX-RSRedirection-WithRequestDispatcherProvider"
class="external-link" rel="nofollow">this page</a> for more information.</p>

<p>One may prefer using the POST binding filter in cases where having SAML request to
IDP encoded as a URI parameter prohibited.</p>

<p>Here is a typical JSP handler for binding org.apache.cxf.rs.security.saml.sso.SAMLRequestInfo
to the view:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;%@ page import=<span class="code-quote">"javax.servlet.http.HttpServletRequest,org.apache.cxf.rs.security.saml.sso.SamlRequestInfo"</span>
%&gt;</span>

&lt;%
    SamlRequestInfo data = (SamlRequestInfo)request.getAttribute(<span class="code-quote">"samlrequestinfo"</span>);
%&gt;
<span class="code-tag">&lt;html xmlns=<span class="code-quote">"http://www.w3.org/1999/xhtml"</span>&gt;</span>
<span class="code-tag">&lt;body onLoad=<span class="code-quote">"document.forms[0].submit();"</span>&gt;</span>
   <span class="code-tag">&lt;form action=<span class="code-quote">"&lt;%=
data.getIdpServiceAddress() %&gt;</span>"</span> method=<span class="code-quote">"POST"</span>&gt;
       <span class="code-tag">&lt;div&gt;</span>             
        &lt;input type=<span class="code-quote">"hidden"</span> name=<span
class="code-quote">"SAMLRequest"</span>
                value=<span class="code-quote">"<span class="code-tag">&lt;%=
data.getSamlRequest() %&gt;</span>"</span>/&gt;
        &lt;input type=<span class="code-quote">"hidden"</span> name=<span
class="code-quote">"RelayState"</span>
                value=<span class="code-quote">"<span class="code-tag">&lt;%=
data.getRelayState() %&gt;</span>"</span>/&gt;
       <span class="code-tag">&lt;/div&gt;</span>
        <span class="code-tag">&lt;div&gt;</span>
         <span class="code-tag">&lt;input type=<span class="code-quote">"submit"</span>
value=<span class="code-quote">"Continue"</span>/&gt;</span>
       <span class="code-tag">&lt;/div&gt;</span>
   <span class="code-tag">&lt;/form&gt;</span>
 
<span class="code-tag">&lt;/body&gt;</span>
<span class="code-tag">&lt;/html&gt;</span>
</pre>
</div></div>

<h2><a name="SAMLWebSSO-SigningSAMLAuthenticationRequests"></a>Signing SAML
Authentication Requests</h2>

<p>The filters may optionally sign SAML requests, the following configuration properties
can be set-up:</p>

<ul>
	<li>boolean signRequest - Whether to sign the AuthnRequest or not. The default is false.</li>
	<li>String signatureUsername - The keystore alias to use to sign the AuthnRequest.</li>
	<li>Crypto signatureCrypto - A WSS4J Crypto object if the SAML AuthnRequest is to be
signed.</li>
	<li>String signaturePropertiesFile - This points to a properties file that can be used
to load a Crypto instance if the SAML AuthnRequest is to be signed.</li>
	<li>CallbackHandler callbackHandler - A CallbackHandler object to retrieve the private
key password used to sign the request.</li>
	<li>String callbackHandlerClass - A class name that is loaded for use as the CallbackHandler
object.</li>
</ul>


<p>Either the "signatureCrypto" or "signaturePropertiesFile" properties must be set
if "signRequest" is set to true. Similarly, either "callbackHandler" or "callbackHandlerClass"
must be configured.</p>

<h2><a name="SAMLWebSSO-FiltersandStateManagement"></a>Filters and State
Management</h2>

<p>The following properties affect the way filters manage the SSO state:</p>

<ul>
	<li><a href="http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/state/SPStateManager.java"
class="external-link" rel="nofollow">SPStateManager</a> stateProvider</li>
	<li>long stateTimeToLive - default is 2 minutes (in milliseconds).</li>
	<li>String webAppDomain.</li>
	<li>boolean addWebAppContext - default is true.</li>
	<li>boolean boolean addEndpointAddressToContext - default is false.</li>
</ul>


<p>The 'stateProvider' refers to a custom <a href="http://svn.apache.org/repos/asf/cxf/trunk/rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/state/SPStateManager.java"
class="external-link" rel="nofollow">SPStateManager</a> implementation and is used
for filters and RACS coordinating with the filters persisting the current user request state,
RACS validating it and persisting the current security context state and filters getting the
information about the context. Filters and RACS use a 'RelayState' token to work with the
current request state. RACS persists the security context and the filters retrieve and validate
it using the cookie which RACS also sets to point to this security context.</p>

<p>Note that a 'stateTimeToLive' property can be used to control how long the current
security context can be valid for.</p>

<p>Both filters and RACS use opaque cookies to refer to the original request and security
context state and 'webAppDomain', 'addWebAppContext' and 'addEndpointAddressToContext' affect
the way these cookies can be shared between multiple SP custom applications.</p>

<p>For example, here is a typical Set Cookie request issued by a web application to
the browser:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
Set-Cookie: value; Domain=mydomain; Path=/accounts; Expires=Wed, 13-Jan-2021 22:23:01 GMT;
</pre>
</div></div>

<p>By default, CXF will get a Cookie 'Path' property set to something like "/services",
where 'services' is the actual name of the war archive.<br/>
The 'addEndpointAddressToContext' property can be further restrict this path to something
like "/services/app1", "/services/app2", where "/app1" and "/app2" are jaxrs:endpoint addresses,
this can be handy for testing, with every jaxrs:endpoint within a single war having its own
security context.<br/>
If the custom SP application is 'spread' across multiple containers with different application
context names, then the 'addWebAppContext' can be set to 'false' leading to Cookie 'Path'
parameters set to '/' and the 'webAppDomain' property set to some shared value.</p>

<p>Note that the stateTimeToLive property affects a Cookie 'Expires' property but also
used by filters and RACS to enforce that the internal state has not expired.</p>


<h1><a name="SAMLWebSSO-RequestAssertionSecurityService"></a>Request Assertion
Security Service</h1>

<h1><a name="SAMLWebSSO-SSOStateProvider"></a>SSO State Provider</h1>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/SAML+Web+SSO">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27850442&revisedVersion=5&originalVersion=4">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/SAML+Web+SSO?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message