SAML Web SSOPage edited by Sergey BeryozkinChanges (7)
Full ContentJAX-RS: SAML Web SSO IntroductionSSO 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. CXF 2.6.1 introduces a comprehensive service provider (SP) support for the SAML Web SSO profile. This page also offers a good overview of the profile. HTTP Redirect(via GET) and POST bindings are supported. The module has been tested against many IDP providers and is easily configurable. The following components are required to get SSO supported:
The following sections will describe these components in more details Typical FlowTypically, the following flow represents the way SAML SSO is enforced: 1. User accesses a custom application for the first time Maven dependencies<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-rs-security-sso-saml</artifactId> <version>2.6.1</version> </dependency>
The IDP address is where filters will redirect users to and the RACS address is where users will be redirected by IDP to. POST Binding FilterPOST Binding Filter is implemented by org.apache.cxf.rs.security.saml.sso.SamlPostBindingFilter. Here is an example of a typical filter protecting a custom JAX-RS endpoint. <bean id="serviceBean" class="org.apache.cxf.samlp.sso.BookStore"/> <jaxrs:server address="/app2"> <jaxrs:serviceBeans> <ref bean="serviceBean"/> </jaxrs:serviceBeans> <jaxrs:providers> <ref bean="ssoRedirectPOST"/> <ref bean="samlRequestFormCreator"/> </jaxrs:providers> </jaxrs:server> <bean id="ssoRedirectPOST" class="org.apache.cxf.rs.security.saml.sso.SamlPostBindingFilter"> <property name="idpServiceAddress" value="https://localhost:9443/idp"/> <property name="assertionConsumerServiceAddress" value="/racs/sso"/> <property name="stateProvider" ref="stateManager"/> <property name="useDeflateEncoding" value="true"/> </bean <bean id="samlRequestFormCreator" class="org.apache.cxf.jaxrs.provider.RequestDispatcherProvider"> <property name="dispatcherName" value="jsp"/> <property name="useClassNames" value="true"/> </bean> <bean id="stateManager" class="org.apache.cxf.rs.security.saml.sso.state.EHCacheSPStateManager"> <constructor-arg ref="cxf"/> </bean> 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. What is actually different in this case from the GET-based redirect is that the filter prepares an instance of SAMLRequestInfo which is subsequently bound to an XHTML view via a JSP filter. The view will typically have a _javascript_ 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 for more information. One may prefer using the POST binding filter in cases where having SAML request to IDP encoded as a URI parameter prohibited. Here is a typical JSP handler for binding org.apache.cxf.rs.security.saml.sso.SAMLRequestInfo to the view: <%@ page import="javax.servlet.http.HttpServletRequest,org.apache.cxf.rs.security.saml.sso.SamlRequestInfo" %> <% SamlRequestInfo data = "" class="code-quote">"samlrequestinfo"); %> <html xmlns="http://www.w3.org/1999/xhtml"> <body _onLoad_="document.forms[0].submit();"> <form action="" class="code-quote">"<%= data.getIdpServiceAddress() %>" method="POST"> <div> <input type="hidden" name="SAMLRequest" value="<%= data.getSamlRequest() %>"/> <input type="hidden" name="RelayState" value="<%= data.getRelayState() %>"/> </div> <div> <input type="submit" value="Continue"/> </div> </form> </body> </html> Signing SAML Authentication RequestsThe filters may optionally sign SAML requests, the following configuration properties can be set-up:
Either the "signatureCrypto" or "signaturePropertiesFile" properties must be set if "signRequest" is set to true. Similarly, either "callbackHandler" or "callbackHandlerClass" must be configured. Filters and State ManagementThe following properties affect the way filters manage the SSO state:
The 'stateProvider' refers to a custom SPStateManager 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. Note that a 'stateTimeToLive' property can be used to control how long the current security context can be valid for. 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. For example, here is a typical Set Cookie request issued by a web application to the browser: Set-Cookie: value; Domain=mydomain; Path=/accounts; Expires=Wed, 13-Jan-2021 22:23:01 GMT; By default, CXF will get a Cookie 'Path' property set to something like "/services", where 'services' is the actual name of the war archive. 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. Request Assertion Security ServiceSSO State Provider
Change Notification Preferences
View Online
|
View Changes
|
Add Comment
|
- [CONF] Apache CXF Documentation > SAML Web SSO confluence
- [CONF] Apache CXF Documentation > SAML Web SSO confluence
- [CONF] Apache CXF Documentation > SAML Web SSO confluence
