8.4. Single-Sign-On for CUBA Applications

Single-sign-on (SSO) for CUBA applications allows a user to log in to the multiple running applications by entering a single login name and password once in a browser session.

When using SSO, there are two types of applications:

  • Identity Provider (IDP) is an application that provides user authentication. It contains a login form for entering user credentials and checks the credentials against the list of registered users. Only one Identity Provider is allowed in a SSO environment.

  • Service Provider (SP) is a regular application that redirects to IDP for user authentication. SP should contain the same list of users as IDP (passwords do not matter though). SP provides authorization using CUBA security roles and access groups. There may be any number of Service Providers in a SSO environment.

An application can be an Identity Provider and a Service Provider at the same time, so you don’t have to setup a dedicated IDP. The SSO functionality is provided by the cuba-idp module which is a part of the Web Client block. You can develop your applications as usual and setup SSO just on deployment stage if needed.

Warning

CUBA SSO uses custom HTTP-based protocol and currently does not provide integration with systems using standard authentication protocols like SAML or OIDC.

In SSO environment, when a user enters a Service Provider URL, the SP redirects to the IDP page for entering login name and password. After successful authentication, IDP redirects back to the SP application and the user transparently logs in to SP.

In order to set up SSO, do the following:

  • On Identity Provider:

    • Add the following settings to the web.xml file of the web module (if you do it on the deployment stage, this file is located by the following path: tomcat/webapps/app/WEB-INF/web.xml):

      <servlet>
          <servlet-name>idp</servlet-name>
          <servlet-class>com.haulmont.idp.sys.CubaIdpServlet</servlet-class>
          <load-on-startup>3</load-on-startup>
      </servlet>
      
      <servlet-mapping>
          <servlet-name>idp</servlet-name>
          <url-pattern>/idp/*</url-pattern>
      </servlet-mapping>
      
      <filter>
          <filter-name>idpSpringSecurityFilterChain</filter-name>
          <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
          <init-param>
              <param-name>contextAttribute</param-name>
              <param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.idp</param-value>
          </init-param>
          <init-param>
              <param-name>targetBeanName</param-name>
              <param-value>springSecurityFilterChain</param-value>
          </init-param>
      </filter>
      
      <filter-mapping>
          <filter-name>idpSpringSecurityFilterChain</filter-name>
          <url-pattern>/idp/*</url-pattern>
      </filter-mapping>
    • Set the application properties:

  • On Service Providers: