Red Hat xPaaS SSO Image

Red Hat xPaaS 0

Using the Red Hat SSO xPaaS Image

Red Hat xPaaS Documentation Team

Legal Notice

Copyright © 2016 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat Software Collections is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.

Abstract

Guide to using the Red Hat xPaaS SSO image

Chapter 1. Introduction to the SSO Image

1.1. What Is Red Hat SSO?

Red Hat Single Sign-On (SSO) is an integrated sign-on solution available as a containerized xPaaS image designed for use with OpenShift. This image provides an authentication server for users to centrally log in, log out, register, and manage user accounts for web applications, mobile applications, and RESTful web services.

Red Hat offers five SSO application templates:

  • sso70-https: SSO backed by a H2 database on the same pod
  • sso70-mysql: SSO backed by a MySQL database on a separate pod
  • sso70-mysql-persistent: SSO backed by a persistent MySQL database on a separate pod
  • sso70-postgresql: SSO backed by a PostgreSQL database on a separate pod
  • sso70-postgresql-persistent: SSO backed by a persistent PostgreSQL database on a separate pod

Two templates for Red Hat JBoss Enterprise Application Platform (JBoss EAP) are also offered:

  • eap64-sso-s2i: SSO-enabled JBoss EAP64
  • eap70-sso-s2i: SSO-enabled JBoss EAP70

These templates contain environment variables specific to SSO that enable automatic SSO client registration when deployed.
See Automatic and Manual SSO Client Registration Methods for more information.

Chapter 2. Before You Begin

2.1. Comparison: SSO xPaaS Image and Red Hat SSO

The SSO xPaaS image is based on Red Hat Single Sign-On 7.0. There are some differences in functionality between the Red Hat Single Sign-On xPaaS Image and Red Hat Single Sign-On:

  • The SSO xPaaS Application includes all of the functionality of Red Hat Single Sign-On 7.0. In addition, the SSO-enabled JBoss EAP image automatically handles OpenID Connect or SAML client registration and configuration for .war deployments that contain <auth-method>KEYCLOAK</auth-method> or <auth-method>KEYCLOAK-SAML</auth-method> in their respective web.xml files.
  • The SSO xPaaS Application currently only supports replicated caching. Using distributed caching results in errors when the deployment is scaled or updated. See the Server Cache Configuration chapter in the Red Hat Single Sign-On Server Installation and Configuration Guide for more information on the caching types.

2.2. Version Compatibility and Support

See the xPaaS part of the OpenShift and Atomic Platform Tested Integrations page for details about OpenShift image version compatibility.

2.3. Initial Setup

The Tutorials in this guide follow on from and assume an OpenShift instance similar to that created in the OpenShift Primer.

Chapter 3. Get Started

3.1. Using the SSO Image Streams and Application Templates

Red Hat xPaaS images are pulled on demand from the Red Hat Registry:
registry.access.redhat.com

3.2. Preparing and Deploying the SSO xPaaS Application Templates

3.2.1. Configuring Keystores

The SSO image requires two keystores:
- An SSL keystore to provide private and public keys for https traffic encryption.
- A JGroups keystore to provide private and public keys for network traffic encryption between nodes in the cluster.

These keystores are expected by the SSO image, even if the application uses only http on a single-node OpenShift instance. Self-signed certificates do not provide secure communication and are intended for internal testing purposes.

Warning

For production environments Red Hat recommends that you use your own SSL certificate purchased from a verified Certificate Authority (CA) for SSL-encrypted connections (HTTPS).

See the JBoss Enterprise Application Platform Security Guide for more information on how to create a keystore with self-signed or purchased SSL certificates.

3.2.2. Generating the Secret

OpenShift uses objects called Secrets to hold sensitive information, such as passwords or keystores. See the Secrets chapter in the OpenShift documentation for more information.

The SSO image requires a secret that holds the two keystores described earlier. This provides the necessary authorization to applications in the project.

Use the SSL and JGroups keystore files to create a secret for the project:

$ oc create secret generic <sso-secret-name> --from-file=<ssl.jks> --from-file=<jgroups.jceks>

After the secret has been generated, it can be associated with a service account.

3.2.3. Creating the Service Account

Service accounts are API objects that exist within each project and allow users to associate certain secrets and roles with applications in a project namespace. This provides the application with the necessary authorization to run with all required privileges.

The service account that you create must be configured with the correct permissions to view pods in Kubernetes. This is required in order for clustering with the xPaaS SSO image to work. You can view the top of the log files to see whether the correct service account permissions have been configured.

The SSO templates have a default SERVICE_ACCOUNT_NAME variable of sso-service-account. If a different service account name is used, this variable must be configured with the appropriate service account name.

  1. Create a service account to be used for the SSO deployment:

    $ oc create serviceaccount <service-account-name>
  2. Add the view role to the service account. This enables the service account to view all the resources in the application namespace in OpenShift, which is necessary for managing the cluster.

    $ oc policy add-role-to-user view system:serviceaccount:<project-name>:<service-account-name> -n <project-name>
  3. Add the secret created for the project to the service account:

    $ oc secret add sa/<service-account-name> secret/<sso-secret-name>

3.2.4. Using the OpenShift Web Console

Log in to the OpenShift web console:

  1. Click Add to project to list all of the default image streams and templates.
  2. Use the Filter by keyword search bar to limit the list to those that match sso. You may need to click See all to show the desired application template.
  3. Select an application template and configure the deployment parameters as required.
  4. Click Create to deploy the application template.

These are some of the more common variables to configure an SSO deployment:

VariableDescription

APPLICATION_NAME

The name for the SSO application.

HOSTNAME_HTTPS

Custom hostname for https service route. Leave blank for default hostname of <application-name>.<project>.<default-domain-suffix>

HOSTNAME_HTTP

Custom hostname for http service route. Leave blank for default hostname of <application-name>.<project>.<default-domain-suffix>

HTTPS_KEYSTORE

The name of the keystore file within the secret.

HTTPS_PASSWORD

The password for the keystore and certificate.

HTTPS_SECRET

The name of the secret containing the keystore file.

JGROUPS_ENCRYPT_KEYSTORE

The name of the JGroups keystore file within the secret.

JGROUPS_ENCRYPT_PASSWORD

The password for the JGroups keystore and certificate.

JGROUPS_ENCRYPT_SECRET

The name of the secret containing the JGroups keystore file.

SERVICE_ACCOUNT_NAME

The name of the service account to use for the deployment. The service account should be configured to allow usage of the secret(s) specified by HTTPS_SECRET and JGROUPS_ENCRYPT_SECRET. If not provided, the default is sso-service-account.

SSO_ADMIN_USERNAME

SSO server administrator user name. If this is not provided the deployment will create a default admin user.

SSO_ADMIN_PASSWORD

SSO server admin password. If not provided the deployment will generate a default password of admin.

SSO_REALM

The name of an additional SSO realm to create during deployment.

SSO_SERVICE_USERNAME

SSO service user name to manage the realm.

SSO_SERVICE_PASSWORD

SSO service user password.

See the Reference chapter for a more comprehensive list of the SSO environment variables. See the Example Workflow: Preparing and Deploying the SSO xPaaS Image for an end-to-end example of SSO deployment.

3.2.5. Deployment Process

Once deployed, the sso70-https image creates a single pod that contains both the database and SSO web servers. The sso70-mysql and sso70-postgres images create two pods, one for the database and one for the SSO web servers.

After the SSO web server pod has started, the web servers can be accessed at their custom configured hostnames, or at the default hostnames:

  • http://sso-<project-name>.<hostname>/auth/admin: for the web server, and
  • https://secure-sso-<project-name>.<hostname>/auth/admin: for the encrypted web server.

Unless specified during deployment with the SSO_ADMIN_USERNAME and SSO_ADMIN_PASSWORD variables, the default login user name/password credentials are admin/admin.

Note

If the SSO_ADMIN_PASSWORD variable was not used during deployment, the default login user admin credentials should be changed when you first log in. To do this, click the Admin drop-down menu in the top right of the web console and selecting Manage Account.

3.2.6. SSO Clients

Clients are SSO entities that request user authentication. A client could be an application requesting SSO to provide user authentication, or it could be making requests for access tokens in order to invoke services on behalf of an authenticated user. See the Managing Clients chapter of the Red Hat Single Sign-On documentation for more information.

SSO provides OpenID-Connect and SAML client protocols.
OpenID-Connect is the preferred protocol and utilizes three different access types:

  • public: Useful for JavaScript applications that run directly in the browser and require no server configuration.
  • confidential: Useful for server-side clients, such as EAP web applications, that need to perform a browser login.
  • bearer-only: Useful for back-end services that allow bearer token requests.

The client type must also be specified by the <auth-method> key in the application web.xml. This file is read by the image at deployment.
Use KEYCLOAK for the OpenID Connect client.
Use KEYCLOAK-SAML for the SAML client.

The following is an example snippet for the application web.xml to configure an OIDC client:

...
<login-config>
        <auth-method>KEYCLOAK</auth-method>
</login-config>
...

3.2.7. Automatic and Manual SSO Client Registration Methods

A client application can be automatically registered to an SSO realm using credentials passed in variables specific to the eap64-sso-s2i and eap70-sso-s2i templates.

Alternatively, you can manually register the client application by configuring and exporting the SSO client adapter and including it in the client application configuration.

3.2.8. Automatic SSO Client Registration

Automatic SSO client registration is determined by SSO environment variables specific to the eap64-sso-s2i and eap70-sso-s2i templates. The SSO credentials supplied in the template are then used to register the client to the SSO realm during deployment of the client application.

The SSO environment variables included in the eap64-sso-s2i and eap70-sso-s2i templates are:

VariableDescription

HOSTNAME_HTTP

Custom hostname for http service route. Leave blank for default hostname of <application-name>.<project>.<default-domain-suffix>

HOSTNAME_HTTPS

Custom hostname for https service route. Leave blank for default hostname of <application-name>.<project>.<default-domain-suffix>

SSO_URL

The SSO web server authentication address: https://secure-sso-<project-name>.<hostname>/auth

SSO_REALM

The SSO realm created for this procedure.

SSO_USERNAME

The name of the realm management user.

SSO_PASSWORD

The password of the user.

SSO_PUBLIC_KEY

The public key generated by the realm. It is located in the Keys tab of the Realm Settings in the SSO console.

SSO_BEARER_ONLY

If set to true, the OpenID Connect client is registered as bearer-only.

SSO_ENABLE_CORS

If set to true, the Keycloak adapter enables Cross-Origin Resource Sharing (CORS).

If the SSO realm uses a SAML client, the following additional variables need to be configured:

VariableDescription

SSO_SAML_KEYSTORE_SECRET

Secret to use for access to SAML keystore. The default is sso-app-secret.

SSO_SAML_KEYSTORE

Keystore filename in the SAML keystore secret. The default is keystore.jks.

SSO_SAML_KEYSTORE_PASSWORD

Keystore password for SAML. The default is mykeystorepass.

SSO_SAML_CERTIFICATE_NAME

Alias for keys/certificate to use for SAML. The default is jboss.

See Example Workflow: Automatically Registering EAP Application in SSO with OpenID-Connect Client for an end-to-end example of the automatic client registration method using an OpenID-Connect client.

3.2.9. Manual SSO Client Registration

Manual SSO client registration is determined by the presence of a deployment file in the client application’s ../configuration/ folder. These files are exported from the client adapter in the SSO web console. The name of this file is different for OpenID-Connect and SAML clients:

OpenID-Connect

../configuration/secure-deployments

SAML

../configuration/secure-saml-deployments

These files are copied to the SSO adapter configuration section in the standalone-openshift.xml at when the application is deployed.

There are two methods for passing the SSO adapter configuration to the client application:

  • Modify the deployment file to contain the SSO adapter configuration so that it is included in the _standalone-openshift.xml) file at deployment, or
  • Manually include the OpenID-Connect keycloak.json file, or the SAML keycloak-saml.xml file in the client application’s ../WEB-INF directory.

See Example Workflow: Manually Configure an Application to Use SSO Authentication, Using SAML Client for an end-to-end example of the manual SSO client registration method using a SAML client.

3.2.10. Limitations

OpenShift does not currently accept OpenShift role mapping from external providers. If SSO is used as an authentication gateway for OpenShift, users created in SSO must have the roles added using the OpenShift Administrator oadm policy command.

For example, to allow an SSO-created user to view a project namespace in OpenShift:

oadm policy add-role-to-user view <user-name> -n <project-name>

Chapter 4. Tutorials

4.1. Example Workflow: Preparing and Deploying the SSO xPaaS Image

4.1.1. Preparing SSO Authentication for OpenShift Deployment

Log in to the OpenShift CLI with a user that holds the cluster:admin role.

  1. Create a new project:

    $ oc new-project sso-app-demo
  2. Create a service account to be used for the SSO deployment:

    $ oc create serviceaccount sso-service-account
  3. Add the view role to the service account. This enables the service account to view all the resources in the sso-app-demo namespace, which is necessary for managing the cluster.

    $ oc policy add-role-to-user view system:serviceaccount:sso-app-demo:sso-service-account
  4. The SSO template requires an SSL keystore and a JGroups keystore.
    OpenShift does not permit login authentication from self-signed certificates. For demonstration purposes, this example uses ‘openssl‘ to generate a CA certificate to sign the SSL keystore and create a truststore. This truststore is also included in the creation of the secret, and specified in the SSO template.
    This example also uses ‘keytool’, a package included with the Java Development Kit, to generate self-signed certificates for these keystores. The following commands will prompt for passwords.

    1. Generate a CA certificate:

      $ openssl req -new -newkey rsa:4096 -x509 -keyout xpaas.key -out xpaas.crt -days 365 -subj "/CN=xpaas-sso-demo.ca"
    2. Generate a Certificate for the SSL keystore:

      $ keytool -genkeypair -keyalg RSA -keysize 2048 -dname "CN=secure-sso-sso-app-demo.openshift32.example.com" -alias sso-https-key -keystore sso-https.jks
    3. Generate a Certificate Sign Request for the SSL keystore:

      $ keytool -certreq -keyalg rsa -alias sso-https-key -keystore sso-https.jks -file sso.csr
    4. Sign the Certificate Sign Request with the CA certificate:

      $ openssl x509 -req -CA xpaas.crt -CAkey xpaas.key -in sso.csr -out sso.crt -days 365 -CAcreateserial
    5. Import the CA into the SSL keystore:

      $ keytool -import -file xpaas.crt -alias xpaas.ca -keystore sso-https.jks
    6. Import the signed Certificate Sign Request into the SSL keystore:

      $ keytool -import -file sso.crt -alias sso-https-key -keystore sso-https.jks
    7. Import the CA into a new truststore keystore:

      $ keytool -import -file xpaas.crt -alias xpaas.ca -keystore truststore.jks
    8. Generate a secure key for the JGroups keystore:

      $ keytool -genseckey -alias jgroups -storetype JCEKS -keystore jgroups.jceks
  5. Create the SSO secret with the SSL and JGroups keystore files, as well as the truststore:

    $ oc create secret generic sso-app-secret --from-file=jgroups.jceks --from-file=sso-https.jks --from-file=truststore.jks
  6. Add the secret to the service account created earlier:

    $ oc secret add sa/sso-service-account secret/sso-app-secret

4.1.2. Deploying the SSO Application Template

  1. Log in to the OpenShift web console and select the sso-app-demo project space.
  2. Click Add to project to list all of the default image streams and templates.
  3. Use the Filter by keyword search bar to limit the list to those that match sso. You may need to click See all to show the desired application template.
  4. Select an SSO application template. This example uses sso70-https. Specify the application name, hostnames, and SSL keystore, JGroups keystore, secret and service account information:

    VariableExample Value

    APPLICATION_NAME

    sso

    HOSTNAME_HTTPS

    secure-sso-sso-app-demo.openshift32.example.com

    HOSTNAME_HTTP

    sso-sso-app-demo.openshift32.example.com

    HTTPS_KEYSTORE

    sso-https.jks

    HTTPS_PASSWORD

    password

    HTTPS_SECRET

    sso-app-secret

    JGROUPS_ENCRYPT_KEYSTORE

    jgroups.jceks

    JGROUPS_ENCRYPT_PASSWORD

    password

    JGROUPS_ENCRYPT_SECRET

    sso-app-secret

    SERVICE_ACCOUNT_NAME

    sso-service-account

    Include the following variables to create a new demorealm realm when SSO is deployed and a user to manage that realm. You can also specify the SSO_ADMIN credentials here. If you do not specify the SSO_ADMIN credentials, a default admin user is created with a default password of admin.

    VariableExample Value

    SSO_REALM

    demorealm

    SSO_SERVICE_USERNAME

    sso-mgmtuser

    SSO_SERVICE_PASSWORD

    mgmt-password

    SSO_ADMIN_USERNAME

    admin

    SSO_ADMIN_PASSWORD

    adm-password

    This example uses self-signed certificates and must additionally include information on the truststore. These variables are not required with SSL certificates purchased from a verified Certificate Authority:

    VariableExample Value

    SSO_TRUSTSTORE

    truststore.jks

    SSO_TRUSTSTORE_SECRET

    sso-app-secret

    SSO_TRUSTSTORE_PASSWORD

    password

  5. Click Create to deploy the application template and start pod deployment. This may take a couple of minutes.

The SSO web console can be accessed at https://secure-sso-<sso-app-demo>.<openshift32.example.com>/auth/admin using the admin user.

Note

This example workflow uses a self-generated CA to provide an end-to-end workflow for demonstration purposes. Accessing the SSO web console will prompt an insecure connection warning.
For production environments, Red Hat recommends that you use an SSL certificate purchased from a verified Certificate Authority.

4.2. Example Workflow: Configuring OpenShift to use SSO for Authentication

Configure OpenShift to use the SSO deployment as the authorization gateway for OpenShift. This follows on from Example Workflow: Preparing and Deploying the SSO xPaaS Image, in which SSO was deployed on OpenShift.

This example adds SSO as an authentication method alongside the HTPasswd method configured in the OpenShift Primer. Once configured, both methods will be available for user login to your OpenShift web console.

4.2.1. Configuring SSO Credentials

Log in to the encrypted SSO web server at https://secure-sso-sso-app-demo.openshift32.example.com/auth/admin using the admin user created during the SSO deployment.

Create a Realm

  1. Hover your cursor over the realm namespace (default is Master) at the top of the sidebar and click Add Realm.
  2. Enter a realm name (this example uses OpenShift) and click Create.

Create a User

Create a test user that can be used to demonstrate the SSO-enabled OpenShift login:

  1. Click Users in the Manage sidebar to view the user information for the realm.
  2. Click Add User.
  3. Enter a valid Username (this example uses testuser) and any additional optional information and click Save.
  4. Edit the user configuration:

    1. Click the Credentials tab in the user space and enter a password for the user.
    2. Ensure the Temporary Password option is set to Off so that it does not prompt for a password change later on, and click Reset Password to set the user password. A pop-up window prompts for additional confirmation.

Create and configure an OpenID-Connect Client

See the Manager Clients chapter of the Red Hat Single Sign-On Server Administration Guide] for more information.

  1. Click Clients in the Manage sidebar and click Create.
  2. Enter the Client ID. This example uses openshift-demo.
  3. Select a Client Protocol from the drop-down menu (this example uses openid-connect) and click Save. You will be taken to the configuration Settings page of the openshift-demo client.
  4. From the Access Type drop-down menu, select confidential. This is the access type for server-side applications.
  5. In the Valid Redirect URIs dialog, enter the URI for the OpenShift web console, which is https://openshift.example.com:8443/* in this example.

The client Secret is needed to configure OpenID-Connect on the OpenShift master in the next section. You can copy it now from under the Credentials tab. The secret is <7b0384a2-b832-16c5-9d73-2957842e89h7> for this example.

4.2.2. Configuring OpenShift Master for Single Sign-On Authentication

Log in to the OpenShift master CLI. You must have the required permissions to edit the /etc/origin/master/master-config.yaml file.

  1. Edit the /etc/origin/master/master-config.yaml file and find the identityProviders. The OpenShift master, which was deployed using the OpenShift Primer, is configured with HTPassword and shows the following:

    identityProviders:
    - challenge: true
      login: true
      name: htpasswd_auth
      provider:
        apiVersion: v1
        file: /etc/origin/openshift-passwd
        kind: HTPasswdPasswordIdentityProvider

    Add SSO as a secondary identity provider with content similar to the following snippet:

    - name: rh_sso
      challenge: false
      login: true
      mappingInfo: add
      provider:
        apiVersion: v1
        kind: OpenIDIdentityProvider
        clientID: openshift-demo
        clientSecret: 7b0384a2-b832-16c5-9d73-2957842e89h7
        ca: xpaas.crt
        urls:
          authorize: https://secure-sso-sso-app-demo.openshift32.example.com/auth/realms/OpenShift/protocol/openid-connect/auth
          token: https://secure-sso-sso-app-demo.openshift32.example.com/auth/realms/OpenShift/protocol/openid-connect/token
          userInfo: https://secure-sso-sso-app-demo.openshift32.example.com/auth/realms/OpenShift/protocol/openid-connect/userinfo
        claims:
          id:
          - sub
          preferredUsername:
          - preferred_username
          name:
          - name
          email:
          - email
    1. The SSO Secret hash for the clientSecret can be found in the SSO web console: Clientsopenshift-demoCredentials
    2. The endpoints for the urls can be found by making a request with the SSO application. For example:

      <curl -k https://secure-sso-sso-app-demo.openshift32.example.com/auth/realms/OpenShift/.well-known/openid-configuration | python -m json.tool>

      The response includes the authorization_endpoint, token_endpoint, and userinfo_endpoint.

    3. This example workflow uses a self-generated CA to provide an end-to-end workflow for demonstration purposes. For this reason, the ca is provided as <ca: xpaas.crt>. This CA certificate must also be copied into the /etc/origin/master folder. This is not necessary if using a certificate purchased from a verified Certificate Authority.
  2. Save the configuration and restart the OpenShift master:

    $ systemctl restart atomic-openshift-master

4.2.3. Logging in to OpenShift

Navigate to the OpenShift web console, which in this example is https://openshift.example.com:8443/console. The OpenShift login page now has the option to use either htpasswd_auth or rh-sso. The former is still available because it is present in the /etc/origin/master/master-config.yaml.

Select rh-sso and log in to OpenShift with the testuser user created earlier in SSO. No projects are visible to testuser until they are added in the OpenShift CLI. This is the only way to provide user privileges in OpenShift because it currently does not accept external role mapping.

To provide testuser view privileges for the sso-app-demo, use the OpenShift CLI:

$ oadm policy add-role-to-user view testuser -n sso-app-demo

4.3. Example Workflow: Automatically Registering EAP Application in SSO with OpenID-Connect Client

This follows on from Example Workflow: Preparing and Deploying the SSO xPaaS Image, in which SSO was deployed on OpenShift. This example prepares SSO realm, role, and user credentials for an EAP project using an OpenID-Connect client adapter. These credentials are then provided in the EAP xPaaS template for automatic SSO client registration. Once deployed, the SSO user can be used to authenticate and access JBoss EAP.

Note

This example uses a OpenID-Connect client but an SAML client could also be used. See SSO Clients and Automatic and Manual SSO Client Registration Methods for more information on the differences between OpenID-Connect and SAML clients.

4.3.1. Preparing SSO Authentication for OpenShift Deployment

Log in to the OpenShift CLI with a user that holds the cluster:admin role.

  1. Create a new project:

    $ oc new-project eap-app-demo
  2. Create a service account to be used for the SSO deployment:

    $ oc create serviceaccount eap-service-account
  3. Add the view role to the service account. This enables the service account to view all the resources in the sso-app-demo namespace, which is necessary for managing the cluster.

    $ oc policy add-role-to-user view system:serviceaccount:eap-app-demo:eap-service-account
  4. The EAP template requires an SSL keystore and a JGroups keystore.
    This example uses the same keystores and truststore that were created for the SSO deployment in Example Workflow: Preparing and Deploying the SSO xPaaS Image. To reiterate, this is to show an end-to-end workflow for demonstration purposes. For production environments, Red Hat recommends that you use an SSL certificate purchased from a verified Certificate Authority.
    Create the EAP secret with the SSL and JGroups keystore files created for the SSO deployment, as well as the truststore:

    $ oc create secret generic eap-app-secret --from-file=jgroups.jceks --from-file=sso-https.jks  --from-file=truststore.jks
  5. Add the EAP secret to the EAP service account created earlier:

    $ oc secret add sa/eap-service-account secret/eap-app-secret

4.3.2. Preparing the SSO Credentials

Log in to the encrypted SSO web server at https://secure-sso-<project-name>.<hostname>/auth/admin using the admin user created during the SSO deployment.

Create a Realm

  1. Hover your cursor over the realm namespace at the top of the sidebar and click*Add Realm*.
  2. Enter a realm name (this example uses eap-demo) and click Create.

Copy the Public Key

In the newly created eap-demo realm, click the Keys tab and copy the public key that has been generated. This example uses the variable <realm-public-key> for brevity. This is used later to deploy the SSO-enabled JBoss EAP image.

Create a Role

Create a role in SSO with a name that corresponds to the JEE role defined in the web.xml of the example EAP application. This role is assigned to an SSO application user to authenticate access to user applications.

  1. Click Roles in the Configure sidebar to list the roles for this realm. This is a new realm, so there should only be the default offline_access role.
  2. Click Add Role.
  3. Enter the role name (this example uses the role eap-user-role) and click Save.

Create Users and Assign Roles

Create two users: - Assign the realm management user the realm-management roles to handle automatic SSO client registration in the SSO server. - Assign the application user the JEE role, created in the previous step, to authenticate access to user applications.

Create the realm management user:

  1. Click Users in the Manage sidebar to view the user information for the realm.
  2. Click Add User.
  3. Enter a valid Username (this example uses the user eap-mgmt-user) and click Save.
  4. Edit the user configuration. Click the Credentials tab in the user space and enter a password for the user. After the password has been confirmed you can click Reset Password to set the user password. A pop-up window prompts for additional confirmation.
  5. Click Role Mappings to list the realm and client role configuration. In the Client Roles drop-down menu, select realm-management and add all of the available roles to the user. This provides the user SSO server rights that can be used by the JBoss EAP image to create clients.

Create the application user:

  1. Click Users in the Manage sidebar to view the user information for the realm.
  2. Click Add User.
  3. Enter a valid Username and any additional optional information for the application user and click Save.
  4. Edit the user configuration. Click the Credentials tab in the user space and enter a password for the user. After the password has been confirmed you can click Reset Password to set the user password. A pop-up window prompts for additional confirmation.
  5. Click Role Mappings to list the realm and client role configuration. In Available Roles, add the role created earlier.

4.3.3. Deploy the SSO-enabled JBoss EAP Image

  1. Return to the OpenShift web console and click Add to project to list all of the default image streams and templates.
  2. Use the Filter by keyword search bar to limit the list to those that match sso. You may need to click See all to show the desired application template.
  3. Select the eap70-sso-s2i image to list all of the deployment parameters. Include the following SSO parameters to configure the SSO credentials during the EAP build:

    VariableExample Value

    APPLICATION_NAME

    sso

    HOSTNAME_HTTPS

    secure-sample-jsp.eap-app-demo.openshift32.example.com

    HOSTNAME_HTTP

    sample-jsp.eap-app-demo.openshift32.example.com

    SOURCE_REPOSITORY_URL

    https://repository-example.com/developer/application

    SSO_URL

    https://secure-sso-sso-app-demo.openshift32.example.com/auth

    SSO_REALM

    eap-demo

    SSO_USERNAME

    eap-mgmt-user

    SSO_PASSWORD

    password

    SSO_PUBLIC_KEY

    <realm-public-key>

    HTTPS_KEYSTORE

    sso-https.jks

    HTTPS_PASSWORD

    password

    HTTPS_SECRET

    sso-app-secret

    JGROUPS_ENCRYPT_KEYSTORE

    jgroups.jceks

    JGROUPS_ENCRYPT_PASSWORD

    password

    JGROUPS_ENCRYPT_SECRET

    eap-app-secret

    SERVICE_ACCOUNT_NAME

    eap-service-account

    This example uses self-signed certificates and must additionally include information on the truststore. These variables are not required with SSL certificates purchased from a verified Certificate Authority:

    VariableExample Value

    SSO_TRUSTSTORE

    truststore.jks

    SSO_TRUSTSTORE_SECRET

    eap-app-secret

    SSO_TRUSTSTORE_PASSWORD

    password

  4. Click Create to deploy the JBoss EAP image.

It may take several minutes for the JBoss EAP image to deploy.

4.3.4. Log in to the JBoss EAP Server Using SSO

  1. Access the JBoss EAP application server and click Login. You are redirected to the SSO login.
  2. Log in using the SSO user created in the example. You are authenticated against the SSO server and returned to the JBoss EAP application server.

4.4. Example Workflow: Manually Registering EAP Application in SSO with SAML Client

This follows on from Example Workflow: Preparing and Deploying the SSO xPaaS Image, in which SSO was deployed on OpenShift.

This example prepares SSO realm, role, and user credentials for an EAP project and configures an EAP xPaaS deployment. Once deployed, the SSO user can be used to authenticate and access JBoss EAP.

Note

This example uses a SAML client but an OpenID-Connect client could also be used. See SSO Clients and Automatic and Manual SSO Client Registration Methods for more information on the differences between SAML and OpenID-Connect clients.

4.4.1. Preparing the SSO Credentials

Log in to the encrypted SSO web server at https://secure-sso-<project-name>.<hostname>/auth/admin using the admin user created during the SSO deployment.

Create a Realm

  1. Hover your cursor over the realm namespace (default is Master) at the top of the sidebar and click Add Realm.
  2. Enter a realm name (this example uses saml-demo) and click Create.

Copy the Public Key

In the newly created saml-demo realm, click the Keys tab and copy the public key that has been generated. This example uses the variable realm-public-key for brevity. This is needed later to deploy the SSO-enabled JBoss EAP image.

Create a Role

Create a role in SSO with a name that corresponds to the JEE role defined in the web.xml of the example EAP application. This role will be assigned to an SSO application user to authenticate access to user applications.

  1. Click Roles in the Configure sidebar to list the roles for this realm. This is a new realm, so there should only be the default offline_access role.
  2. Click Add Role.
  3. Enter the role name (this example uses the role saml-user-role) and click Save.

Create Users and Assign Roles

Create two users: - Assign the realm management user the realm-management roles to handle automatic SSO client registration in the SSO server. - Assign the application user the JEE role, created in the previous step, to authenticate access to user applications.

Create the realm management user:

  1. Click Users in the Manage sidebar to view the user information for the realm.
  2. Click Add User.
  3. Enter a valid Username (this example uses the user app-mgmt-user) and click Save.
  4. Edit the user configuration. Click the Credentials tab in the user space and enter a password for the user. After the password has been confirmed you can click Reset Password to set the user password. A pop-up window prompts for additional confirmation.

Create the application user:

  1. Click Users in the Manage sidebar to view the user information for the realm.
  2. Click Add User.
  3. Enter a valid Username and any additional optional information for the application user and click Save.
  4. Edit the user configuration. Click the Credentials tab in the user space and enter a password for the user. After the password has been confirmed you can click Reset Password to set the user password. A pop-up window prompts for additional confirmation.
  5. Click Role Mappings to list the realm and client role configuration. In Available Roles, add the role created earlier.

Create and Configure a SAML Client:

Clients are SSO entities that request user authentication. This example configures a SAML client to handle authentication for the EAP application. This section saves two files, keystore.jks and keycloak-saml-subsystem.xml that are needed later in the procedure.

Create the SAML Client:

  1. Click Clients in the Configure sidebar to list the clients in the realm. Click Create.
  2. Enter a valid Client ID. This example uses sso-saml-demo.
  3. In the Client Protocol drop-down menu, select saml.
  4. Enter the Root URL for the application. This example uses https://demoapp-eap-app-demo.openshift32.example.com.
  5. Click Save.

Configure the SAML Client:

In the Settings tab, set the Root URL and the Valid Redirect URLs for the new sso-saml-demo client:

  1. For the Root URL, enter the same address used when creating the client. This example uses https://demoapp-eap-app-demo.openshift32.example.com.
  2. For the Valid Redirect URLs, enter an address for users to be redirected to at when they log in or out. This example uses a redirect address relative to the root https://demoapp-eap-app-demo.openshift32.example.com/*.

Export the SAML Keys:

  1. Click the SAML Keys tab in the sso-saml-demo client space and click Export.
  2. For this example, leave the Archive Format as JKS. This example uses the default Key Alias of sso-saml-demo and default Realm Certificate Alias of saml-demo.
  3. Enter the Key Password and the Store Password. This example uses password for both.
  4. Click Download and save the keystore.jks file for use later.
  5. Click the sso-saml-demo client to return to the client space ready for the next step.

Download the Client Adapter:

  1. Click Installation.
  2. Use the Format Option drop-down menu to select a format. This example uses Keycloak SAML Wildfly/JBoss Subsystem.
  3. Click Download and save the file keycloak-saml-subsystem.xml.

The keystore.jks will be used with the other SSO keystores in the next section to create an OpenShift secret for the EAP application project. Copy it to an OpenShift node as saml.jks.
The keycloak-saml-subsystem.xml will be modified and used in the application deployment. Copy it into the /configuration folder of the application as secure-saml-deployments.

4.4.2. Preparing SSO Authentication for OpenShift Deployment

Log in to the OpenShift CLI with a user that holds the cluster:admin role.

  1. Create a new project:

    $ oc new-project eap-app-demo
  2. Create a service account to be used for the SSO deployment:

    $ oc create serviceaccount app-service-account
  3. Add the view role to the service account. This enables the service account to view all the resources in the sso-app-demo namespace, which is necessary for managing the cluster.

    $ oc policy add-role-to-user view system:serviceaccount:eap-app-demo:app-service-account
  4. The EAP application template requires three keystores:

    • An SSL keystore to provide private and public keys to encrypt https traffic. This example uses sso-https.jks.
    • A JGroups keystore for encrypting network traffic between nodes in the cluster. This example uses jgroups.ceks.
    • The SAML keys for the SSO client, exported in the previous section. This example uses saml.jks.

      Note

      This example uses two keystores that were created for the SSO deployment. It also requires the truststore.jks created for the SSO deployment because the certificates were self-signed for the purpose of this example. To reiterate, this is to show an end-to-end workflow for demonstration purposes. For production environments, Red Hat recommends that you use an SSL certificate purchased from a verified Certificate Authority, in which case the truststore would not be specified in the secret.

      Create the EAP secret with the SSL and JGroups keystore files and the truststore file created for the SSO deployment, and the SAML keystore file exported from the SSO client and renamed saml.jks:

      $ oc secrets new eap-app-secret \
      keystore.jks=sso-https.jks \
      jgroups.jceks=jgroups.jceks \
      truststore.jks=truststore.jks \
      saml.jks=saml.jks
  5. Add the EAP application secret to the EAP service account created earlier:

    $ oc secret add sa/app-service-account secret/eap-app-secret

4.4.3. Modifying the secure-saml-deployments File

The keycloak-saml-subsystem.xml, exported from the SSO client in a previous section, should have been copied into the /configuration folder of the application and renamed secure-saml-deployments. EAP searches for this file when it starts and copies it to the standalone-openshift.xml file inside the SSO SAML adapter configuration.

  1. Open the /configuration/secure-saml-deployments file in a text editor.
  2. Replace the YOUR-WAR.war value of the secure-deployment name tag with the application .war file. This example uses sso-saml-demo.war.
  3. Replace the SPECIFY YOUR LOGOUT PAGE! value of the logout page tag with the url to redirect users when they log out of the application. This example uses /index.jsp.
  4. Delete the <PrivateKeyPem> and <CertificatePem> tags and keys and replace it with keystore information:

    ...
    <Keys>
      <Key signing="true">
        <KeyStore file= "/etc/eap-secret-volume/saml.jks" password="password">
          <PrivateKey alias="sso-saml-demo" password="password"/>
          <Certificate alias="sso-saml-demo"/>
        </KeyStore>
      </Key>
    </Keys>

    The mount path of the saml.jks (in this example /etc/eap-secret-volume/saml.jks) can be specified in the application template with the parameter EAP_HTTPS_KEYSTORE_DIR.
    The aliases and passwords for the PrivateKey and the Certificate were configured when the SAML Keys were exported from the SSO client.

  5. Delete the second <CertificatePem> tag and key and replace it with the the realm certificate information:

    ...
    <Keys>
      <Key signing="true">
        <KeyStore file="/etc/eap-secret-volume/saml.jks" password="password">
          <Certificate alias="saml-demo"/>
        </KeyStore>
      </Key>
    </Keys>
    ...

    The certificate alias and password were configured when the SAML Keys were exported from the SSO client.

  6. Save and close the /configuration/secure-saml-deployments file.

4.4.4. Configuring SAML Client Registration in the Application web.xml

The client type must also be specified by the <auth-method> key in the application web.xml. This file is read by the image at deployment.

Open the application web.xml file and ensure it includes the following:

...
<login-config>
  <auth-method>KEYCLOAK-SAML</auth-method>
</login-config>
...

4.4.5. Deploying the Application

You do not need to include any SSO configuration for the image because that has been configured in the application itself. Navigating to the application login page redirects you to the SSO login. Log in to the application through SSO using the application user user created earlier.

Chapter 5. Reference

5.1. Environment Variables

5.1.1. Template variables for all SSO images

VariableDescription

APPLICATION_NAME

The name for the application.

DB_MAX_POOL_SIZE

Sets xa-pool/max-pool-size for the configured datasource.

DB_TX_ISOLATION

Sets transaction-isolation for the configured datasource.

DB_USERNAME

Database user name

HOSTNAME_HTTP

Custom hostname for http service route. Leave blank for default hostname, e.g.: <application-name>.<project>.<default-domain-suffix>

HOSTNAME_HTTPS

Custom hostname for https service route. Leave blank for default hostname, e.g.: <application-name>.<project>.<default-domain-suffix>

HTTPS_KEYSTORE

The name of the keystore file within the secret. If defined along with HTTPS_PASSWORD and HTTPS_NAME, enable HTTPS and set the SSL certificate key file to a relative path under $JBOSS_HOME/standalone/configuration

HTTPS_KEYSTORE_TYPE

The type of the keystore file (JKS or JCEKS)

HTTPS_NAME

The name associated with the server certificate (e.g. jboss). If defined along with HTTPS_PASSWORD and HTTPS_KEYSTORE, enable HTTPS and set the SSL name.

HTTPS_PASSWORD

The password for the keystore and certificate (e.g. mykeystorepass). If defined along with HTTPS_NAME and HTTPS_KEYSTORE, enable HTTPS and set the SSL key password.

HTTPS_SECRET

The name of the secret containing the keystore file

IMAGE_STREAM_NAMESPACE

Namespace in which the ImageStreams for Red Hat Middleware images are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you have installed the ImageStreams in a different namespace/project.

JGROUPS_CLUSTER_PASSWORD

JGroups cluster password

JGROUPS_ENCRYPT_KEYSTORE

The name of the keystore file within the secret

JGROUPS_ENCRYPT_NAME

The name associated with the server certificate (e.g. secret-key)

JGROUPS_ENCRYPT_PASSWORD

The password for the keystore and certificate (e.g. password)

JGROUPS_ENCRYPT_SECRET

The name of the secret containing the keystore file

SERVICE_ACCOUNT_NAME

The name of the service account to use for the deployment. The service account should be configured to allow usage of the secret(s) specified by HTTPS_SECRET and JGROUPS_ENCRYPT_SECRET.

SSO_ADMIN_USERNAME

SSO Server admin username

SSO_ADMIN_PASSWORD

SSO Server admin password

SSO_REALM

SSO Realm

SSO_SERVICE_USERNAME

SSO service username

SSO_SERVICE_PASSWORD

SSO service password

SSO_TRUSTSTORE

The name of the truststore file within the secret (e.g. /etc/sso-secret-volume/truststore.jks)

SSO_TRUSTSTORE_SECRET

The name of the secret containing the truststore file (e.g. truststore-secret). Used for volume secretName

SSO_TRUSTSTORE_PASSWORD

The password for the truststore and certificate (e.g. mykeystorepass)

5.1.2. Template variables specific to sso70-mysql and sso70-mysql-persistent

VariableDescription

DB_USERNAME

Database user name

DB_PASSWORD

Database user password

DB_JNDI

Database JNDI name used by application to resolve the datasource, e.g. java:/jboss/datasources/mysql

MYSQL_AIO

Controls the innodb_use_native_aio setting value if the native AIO is broken.

MYSQL_FT_MAX_WORD_LEN

The maximum length of the word to be included in a FULLTEXT index.

MYSQL_FT_MIN_WORD_LEN

The minimum length of the word to be included in a FULLTEXT index.

MYSQL_LOWER_CASE_TABLE_NAMES

Sets how the table names are stored and compared.

MYSQL_MAX_CONNECTIONS

The maximum permitted number of simultaneous client connections.

5.1.3. Template variables specific to sso70-postgresql and sso70-postgresql-persistent

VariableDescription

DB_USERNAME

Database user name

DB_PASSWORD

Database user password

DB_JNDI

Database JNDI name used by application to resolve the datasource, e.g. java:/jboss/datasources/postgresql

POSTGRESQL_MAX_CONNECTIONS

The maximum number of client connections allowed. This also sets the maximum number of prepared transactions.

POSTGRESQL_SHARED_BUFFERS

Configures how much memory is dedicated to PostgreSQL for caching data.

5.1.4. Template variables specific to sso70-mysql-persistent and sso70-postgresql-persistent

VariableDescription

VOLUME_CAPACITY

Size of persistent storage for database volume.

5.1.5. Template variables for general eap64 and eap70 s2i images

VariableDescription

APPLICATION_NAME

The name for the application.

ARTIFACT_DIR

Artifacts

AUTO_DEPLOY_EXPLODED

Controls whether exploded deployment content should be automatically deployed

CONTEXT_DIR

Path within Git project to build; empty for root project directory.

GENERIC_WEBHOOK_SECRET

Generic build trigger secret

GITHUB_WEBHOOK_SECRET

GitHub trigger secret

HORNETQ_CLUSTER_PASSWORD

HornetQ cluster admin password

HORNETQ_QUEUES

Queue names

HORNETQ_TOPICS

Topic names

HOSTNAME_HTTP

Hostname for http service route. Required for SSO-enabled applications

HOSTNAME_HTTPS

Hostname for https service route. Required for SSO-enabled applications

HTTPS_KEYSTORE_TYPE

The type of the keystore file (JKS or JCEKS)

HTTPS_KEYSTORE

The name of the keystore file within the secret.

HTTPS_NAME

The name associated with the server certificate (e.g. jboss)

HTTPS_PASSWORD

The password for the keystore and certificate (e.g. mykeystorepass)

HTTPS_SECRET

The name of the secret containing the keystore file

IMAGE_STREAM_NAMESPACE

Namespace in which the ImageStreams for Red Hat Middleware images are installed. These ImageStreams are normally installed in the openshift namespace. You should only need to modify this if you’ve installed the ImageStreams in a different namespace/project.

JGROUPS_CLUSTER_PASSWORD

JGroups cluster password

JGROUPS_ENCRYPT_KEYSTORE

The name of the keystore file within the secret

JGROUPS_ENCRYPT_NAME

The name associated with the server certificate (e.g. secret-key)

JGROUPS_ENCRYPT_PASSWORD

The password for the keystore and certificate (e.g. password)

JGROUPS_ENCRYPT_SECRET

The name of the secret containing the keystore file

SERVICE_ACCOUNT_NAME

The name of the service account to use for the deployment. The service account should be configured to allow usage of the secret(s) specified by HTTPS_SECRET and JGROUPS_ENCRYPT_SECRET.

SOURCE_REPOSITORY_REF

Git branch/tag reference

SOURCE_REPOSITORY_URL

Git source URI for application

5.1.6. Template variables specific to eap64-sso-s2i and eap70-sso-s2i for automatic client registration

VariableDescription

SSO_URL

SSO Location

SSO_REALM

SSO Realm

SSO_USERNAME

SSO Username

SSO_PASSWORD

SSO Password

SSO_PUBLIC_KEY

SSO Public Key. Public key is recommended to be passed into the template to avoid man-in-the-middle security vulnerability

SSO_SECRET

The SSO Client Secret for Confidential Access

SSO_SERVICE_URL

SSO Service Location

SSO_TRUSTSTORE_SECRET

The name of the secret containing the truststore file (e.g. truststore-secret). Used for volume secretName

SSO_TRUSTSTORE

The name of the truststore file within the secret (e.g. truststore.jks)

SSO_TRUSTSTORE_PASSWORD

The password for the truststore and certificate (e.g. mykeystorepass)

SSO_BEARER_ONLY

SSO Client Access Type

SSO_DISABLE_SSL_CERTIFICATE_VALIDATION

If true SSL communication between EAP and the SSO Server will be insecure (i.e. certificate validation is disabled with curl)

SSO_ENABLE_CORS

Enable CORS for SSO applications

5.1.7. Template variables specific to eap64-sso-s2i and eap70-sso-s2i for automatic client registration with SAML clients

VariableDescription

SSO_SAML_CERTIFICATE_NAME

The name associated with the server certificate

SSO_SAML_KEYSTORE_PASSWORD

The password for the keystore and certificate

SSO_SAML_KEYSTORE

The name of the keystore file within the secret

SSO_SAML_KEYSTORE_SECRET

The name of the secret containing the keystore file

SSO_SAML_LOGOUT_PAGE

SSO logout page for SAML applications