Configure Generic OIDC

If your organization uses an OIDC provider for user authentication, you can configure Rancher to allow login using Identity Provider (IdP) credentials. Rancher supports integration with the OpenID Connect (OIDC) protocol and the SAML protocol. Both implementations are functionally equivalent when used with Rancher. The following instructions describe how to configure Rancher to work using the OIDC protocol.

Prerequisites

  • In Rancher:
    • Generic OIDC is disabled.

Configure Generic OIDC - 图1note

Consult the documentation for your specific IdP to complete the listed prerequisites.

  • In your IdP:

    • Create a new client with the settings below:

      SettingValue
      Client ID<CLIENT_ID> (e.g. rancher)
      Name<CLIENT_NAME> (e.g. rancher)
      Client Protocolopenid-connect
      Access Typeconfidential
      Valid Redirect URIhttps://yourRancherHostURL/verify-auth
    • In the new OIDC client, create mappers to expose the users fields.

      • Create a new Groups Mapper with the settings below:

        SettingValue
        NameGroups Mapper
        Mapper TypeGroup Membership
        Token Claim Namegroups
        Add to ID tokenOFF
        Add to access tokenOFF
        Add to user infoON
      • Create a new Client Audience with the settings below:

        SettingValue
        NameClient Audience
        Mapper TypeAudience
        Included Client Audience<CLIENT_NAME>
        Add to access tokenON
      • Create a new “Groups Path” with the settings below.

        SettingValue
        NameGroup Path
        Mapper TypeGroup Membership
        Token Claim Namefull_group_path
        Full group pathON
        Add to user infoON
  • Important: Rancher will use the value received in the “sub” claim to form the PrincipalID which is the unique identifier in Rancher. It is important to make this a value that will be unique and immutable.

Configuring Generic OIDC in Rancher

  1. In the upper left corner of the Rancher UI, click ☰ > Users & Authentication.

  2. In the left navigation bar, click Auth Provider.

  3. Select Generic OIDC.

  4. Complete the Configure an OIDC account form. For help with filling the form, see the configuration reference.

  5. Click Enable.

    Rancher will redirect you to the IdP login page. Enter your IdP credentials to validate your Rancher Keycloak configuration.

    Configure Generic OIDC - 图2note

    You may need to disable your popup blocker to see the IdP login page.

Result: Rancher is configured to work with your provider using the OIDC protocol. Your users can now sign into Rancher using their IdP logins.

Configuration Reference

FieldDescription
Client IDThe Client ID of your OIDC client.
Client SecretThe generated Secret of your OIDC client.
Private Key/CertificateA key/certificate pair to create a secure shell between Rancher and your IdP. Required if HTTPS/SSL is enabled on your OIDC server.
EndpointsChoose whether to use the generated values for the Rancher URL, Issue, and Auth Endpoint fields or to provide manual overrides if incorrect.
Rancher URLThe URL for your Rancher Server.
IssuerThe URL of your IdP. If your provider has discovery enabled, Rancher uses the Issuer URL to fetch all of the required URLs.
Auth EndpointThe URL where users are redirected to authenticate.

Troubleshooting

If you are experiencing issues while testing the connection to the OIDC server, first double-check the configuration options of your OIDC client. You can also inspect the Rancher logs to help pinpoint what’s causing issues. Debug logs may contain more detailed information about the error. Please refer to How can I enable debug logging in this documentation.

All Generic OIDC related log entries are prepended with either [generic oidc] or [oidc].

You are not redirected to your authentication provider

If you fill out the Configure a Generic OIDC account form and click on Enable, and you are not redirected to your IdP, verify your OIDC client configuration.

The generated Issuer and Auth Endpoint are incorrect

If the Issuer and Auth Endpoint are generated incorrectly, open the Configure an OIDC account form, change Endpoints to Specify (advanced) and override the Issuer value.

Error: “Invalid grant_type”

In some cases, the “Invalid grant_type” error message may be misleading and is actually caused by setting the Valid Redirect URI incorrectly.