Secure your clusters with SAML

These steps show how you can secure your Elasticsearch clusters and Kibana instances in a deployment by using a Security Assertion Markup Language (SAML) identity provider (IdP) for cross-domain, single sign-on authentication.

Note

The SAML credentials are valid against the deployment, not the ECE platform. You can try out our beta release of role-based access control for the platform.

Before you begin

ECE supports SAML with Elastic Stack version 6.4 and later.

The steps in this section require an understanding of SAML, specifically the SAML 2.0 Web Browser SSO Profile. To learn more about SAML, see:

Configure your 7.x cluster to use SAML

You must edit your cluster configuration, sometimes also referred to as the deployment plan, to point to the SAML IdP before you can complete the configuration in Kibana.

  1. Create or use an existing deployment that includes a Kibana instance version 6.4 or later.
  2. Copy the Kibana endpoint URL.
  3. Update your Elasticsearch user settings for the saml realm and specify your IdP provider configuration:

    xpack:
      security:
        authc:
          realms:
            saml: 
              saml1: 
                order: 2
                attributes.principal: "nameid:persistent" 
                attributes.groups: "groups" 
                idp.metadata.path: "<check with your idp provider>" 
                idp.entity_id: "<check with your idp provider>" 
                sp.entity_id: "KIBANA_ENDPOINT_URL/" 
                sp.acs: "KIBANA_ENDPOINT_URL/api/security/v1/saml"
                sp.logout: "KIBANA_ENDPOINT_URL/logout"

    Specifies the authentication realm service.

    The SAML realm name. Note that cloud-saml is reserved for internal use only and you cannot use it. Choose a different name, such as the one shown in the example.

    Defines the SAML attribute that is going to be mapped to the principal (username) of the authenticated user in Kibana. In this example, nameid:persistent maps the NameID with the urn:oasis:names:tc:SAML:2.0:nameid-format:persistent format from the Subject of the SAML Assertion. See the attribute mapping documentation for details and available options.

    Defines the SAML attribute used for role mapping when configured in Kibana. Common choices are groups or roles. The values for both attributes.principal and attributes.groups depend on the IdP provider, so be sure to review their documentation. See the attribute mapping documentation for details and available options.

    The file path or the HTTPS URL where your IdP metadata is available, such as https://idpurl.com/sso/saml/metadata. If you configure a URL you need to make ensure that your Elasticsearch cluster can access it.

    The SAML EntityID of your IdP. This can be read from the configuration page of the IdP, or its SAML metadata, such as https://idpurl.com/entity_id.

    Replace KIBANA_ENDPOINT_URL with the one noted in the previous step, such as sp.entity_id: https://d1a45bf330b74c248d7cc2e0ead8e359.192.168.44.10.ip.es.io:9243/, including the slash at the end.

  4. By default, users authenticating via SAML have no roles assigned to them. For example, if you want all your users authenticating with SAML to get access to Kibana, issue the following request to Elasticsearch:

    POST /_xpack/security/role_mapping/SAML1_TO_KIBANAUSER 
    {
       "enabled": true,
        "roles": [ "kibana_user" ], 
        "rules": { 
            "field": { "realm.name": "saml1" }
        },
        "metadata": { "version": 1 }
    }

    The mapping name

    The Elastic Stack role to map to

    A rule specifying the SAML role to map from

  5. Alternatively, if you want the users that belong to the group elasticadmins in your identity provider to be assigned the superuser role in your Elasticsearch cluster, issue the following request to Elasticsearch:

    POST /_xpack/security/role_mapping/SAML1_ELASTICADMIN_TO_SUPERUSER 
    {
       "enabled": true,
        "roles": [ "superuser" ], 
        "rules": { "all" : [ 
            { "field": { "realm.name": "saml1" } },
            { "field": { "groups": "elasticadmins" } }
        ]},
        "metadata": { "version": 1 }
    }

    The mapping name

    The Elastic Stack role to map to

    A rule specifying the SAML role to map from

    Note

    In order to use the field groups in the mapping rule, you need to have mapped the SAML Attribute that conveys the group membership to attributes.groups in the previous step.

  6. Update Kibana in the user settings configuration to use SAML as the authentication provider:

    xpack.security.authProviders: [saml]
    server.xsrf.whitelist: [/api/security/v1/saml]
    xpack.security.public:
      protocol: https
      hostname: d1a45bf330b74c248d7cc2e0ead8e159.192.168.44.10.ip.es.io 
      port: 9243

    The hostname from your Kibana endpoint URL

    Tip

    This configuration disables all other realms and only allows users to authenticate with SAML. If you wish to allow your native realm users to authenticate, you need to also enable the basic authProvider by setting xpack.security.authProviders: [saml, basic] in the configuration of Kibana. You can then access the Kibana login screen at https://d1a45bf330b74c248d7cc2e0ead8e159.192.168.44.10.ip.es.io:9243/login

  7. Optional: If your Identity Provider doesn’t publish its SAML metadata at an http URL, or if your Elasticsearch cluster cannot reach that URL, you can upload the SAML metadata as a file.

    1. Prepare a ZIP file with a custom bundle that contains your Identity Provider’s metadata (metadata.xml) inside of a saml folder.

      This bundle allows all Elasticsearch containers to access the metadata file.

    2. Update your Elasticsearch cluster configuration using the advanced configuration editor to use the bundle you prepared in the previous step. You need to modify the user_bundles JSON attribute similar to the following example snippet:

      {
        "cluster_name": "REPLACE_WITH_YOUR_CLUSTER_NAME",
        "plan": {
      
          ...
      
          "elasticsearch": {
            "version": "6.4.1",
            "user_bundles": [
              {
                "name": "saml-metadata",
                "url": "https://www.MYURL.com/saml-metadata.zip",
                "elasticsearch_version": "6.4.1"
              }
            ]
          }
        }
      Note

      The URLs that point to the ZIP file containing the bundle must be accessible to the deployment.

      Custom bundles are unzipped under the path /app/config/BUNDLE_DIRECTORY_STRUCTURE, where BUNDLE_DIRECTORY_STRUCTURE is the directory structure in the ZIP file. Make sure to save the file location where custom bundles get unzipped, as you will need it in the next step.

      In our example, the SAML metadata file will be located in the path /app/config/saml/metadata.xml:

      $ tree .
      .
      └── saml
            └── metadata.xml
    3. Adjust your saml realm configuration accordingly:

          idp.metadata.path: /app/config/saml/metadata.xml 

      The path to the SAML metadata file that was uploaded

Configure your 6.x cluster to use SAML

For 6.x deployments the configuration is slightly different. For step 3, you must specify the realm name, then define the realm type using the following example:

xpack:
  security:
    authc:
      realms:
        cloud-saml:
          type: saml
            order: 2

All of the other steps are the same.

Sign Outgoing SAML Message

If configured, Elastic Stack will sign outgoing SAML messages.

As a prerequisite, you need to generate a signing key and a self-signed certificate. You need to share this certificate with your SAML Identity Provider so that it can verify the received messages. The key needs to be unencrypted. The exact procedure is system dependent, you can use for example openssl

+

openssl req -new -x509 -days 3650 -nodes -sha256 -out saml-sign.crt -keyout saml-sign.key

+ Place the files under saml folder and add them to the existing SAML bundle, or create a new one as described above.

+ In our example, the certificate and the key will be located in the path /app/config/saml/saml-sign.{crt,key}:

+

$ tree .
.
└── saml
    ├── saml-sign.crt
    └── saml-sign.key

Make sure the bundle is included with your deployment (see above).

Adjust your realm configuration accordingly:

+

    signing.certificate: /app/config/saml/saml-sign.crt 
    signing.key: /app/config/saml/saml-sign.key 

+ <1> The path to the SAML signing certificate that was uploaded.

+ <2> The path to the SAML signing key that was uploaded.

 When configured with a
signing key and certificate, Elastic Stack will sign all outgoing messages (SAML
Authentication Requests, SAML Logout Requests, SAML Logout Responses) by
default. This behavior can be altered by configuring `signing.saml_messages`
appropriately with the comma separated list of messages to sign. Supported
values are `AuthnRequest`, `LogoutRequest` and `LogoutResponse` and the default
value is `*`.
For example
+
xpack:
  security:
    authc:
      realms:
        saml1:
          type: saml
          order: 2
          ...
          signing.saml_messages: AuthnRequest 
          ...

+ <1> This configuration will ensure that only SAML Authentication Requests will be sent signed to the Identity Provider

Optional Settings

Following optional realm settings are supported:

  • force_authn Specifies whether to set the ForceAuthn attribute when requesting that the IdP authenticate the current user. If set to true, the IdP is required to verify the user’s identity, irrespective of any existing sessions they might have. Defaults to false.
  • idp.use_single_logout Indicates whether to utilise the Identity Provider’s <SingleLogoutService> (if one exists in the IdP metadata file). Defaults to true.

After completing these steps, you can log into Kibana by authenticating against your SAML IdP. If you encounter any issues with the configuration, please take a look at our [SAML troubleshooting page](https://www.elastic.co/guide/en/elastic-stack-overview/current/trb-security-saml.html) which contains information about common issues and suggestions for their resolution.