Enable OIDC for Kong Manager

Kong Gateway offers the ability to bind authentication for Kong Manager admins to an organization’s OpenID Connect Identity Provider using the OpenID Connect Plugin.

Note: By using the configuration below, OpenID Connect authentication will be enabled for Kong Manager. It is unnecessary to manually enable the OpenID Connect plugin via Admin API or Kong Manager.

Set up RBAC with OIDC

The following is an example using Google as the IdP and serving Kong Manager from its default URL, http://127.0.0.1:8002.

Important: If you are using configuration from previous versions, you may need to follow the migration guide to review and update your configuration.

The admin_gui_auth_config value must be valid JSON. The following is an example of the configuration:

  1. enforce_rbac = on
  2. admin_gui_auth=openid-connect # specify the plugin
  3. admin_gui_auth_conf={ \
  4. "issuer": "https://dev-xxxx.okta.com/oauth2/default", \
  5. "client_id": ["<ENTER_YOUR_CLIENT_ID>"], \
  6. "client_secret": ["<ENTER_YOUR_CLIENT_SECRET_HERE>"], \
  7. "redirect_uri": ["http://localhost:8001/auth"], \
  8. "scopes": ["openid","email","offline_access"], # "email" is for the admin_claim, may vary in different IdPs \
  9. "login_redirect_uri": ["http://localhost:8002"], \
  10. "logout_redirect_uri": ["http://localhost:8002"], \
  11. "admin_claim": "email", \
  12. "authenticated_groups_claim": ["groups"], \
  13. }

While authenticating Kong Manager with OpenID Connect, make sure that your IdP supports the authorization_code grant type and is enabled for the associated client.

While authenticating Kong Manager with OpenID Connect, admin_gui_auth_conf will be used to configure the OIDC plugin. Besides the common parameters, there are some parameters that are important and/or specific for using OIDC with Kong Manager:

parameterdata typedefault valuenotes
issuer
required
StringThe base URL to resolve metadata about the IdP (Identity Provider). For example: https://dev-xxxx.okta.com/oauth2/default
client_id
required
ArrayThe client ID(s) that the plugin uses while communicating with the IdP.
client_secret
required
ArrayThe client secret.
redirect_uri
required
ArrayThe URI to redirect after authentication with the IdP. Should point to Admin API’s /auth endpoint. For example: http://localhost:8001/auth
login_redirect_uri
required
ArrayThe URI to redirect after authentication with the Admin API. Should point to Kong Manager’s endpoint. For example: http://localhost:8002
logout_redirect_uri
required
ArrayThe URI to redirect after logging out from the IdP. Should point to Kong Manager’s endpoint. For example: http://localhost:8002
admin_auto_create
optional
BooleantrueThis parameter is used to enable the automatic creation of administrators.
admin_claim
optional
String“email”The claim to use while looking up for the admin’s username.
authenticated_groups_claim
optional
Array[“groups”]The claim to use while looking up for authenticated groups.
scopes
optional
Array[“openid”, “email”, “offline_access”]Scopes to use in while authenticating with the IdP. Must contain “openid” and “offline_access”. Should also contain necessary scopes for the claim admin_claim specifies.
ssl_verify
optional
BooleanfalseVerify identity provider server certificate.

You may also refer to the documentation of the plugin and modify the configuration according to your requirements.

When authenticating Kong Manager with OpenID Connect, session mechanism inside the plugin will be used to persist the authorization state. Please refer to the documentation for parameters prefixed by session_ to learn more.

Recommendations to enhance session security

  • session_secret is recommended to be set. A randomly generated secret will be used if unspecified.
  • session_cookie_secure (default value is false) is recommended to be enabled when using HTTPS instead of HTTP.
  • Considering upgrading the session_cookie_same_site to Strict when using the same domain for the Admin API and Kong Manager.

Learn more about these concepts in Session Security in Kong Manager.

Replace the entries surrounded by <> with values that are valid for your IdP. For example, Google credentials can be found here: https://console.cloud.google.com/projectselector/apis/credentials

Create an admin

Create an admin that has a username matching the email returned from the identity provider upon successful login:

  1. curl -i -X POST http://localhost:8001/admins \
  2. --data username="<admin_email>" \
  3. --data email="<admin_email>" \
  4. --header Kong-Admin-Token:<RBAC_TOKEN>

For example, if a user has the email address example_user@example.com:

  1. curl -i -X POST http://localhost:8001/admins \
  2. --data username="example_user@example_com" \
  3. --data email="example_user@example.com" \
  4. --header Kong-Admin-Token:<RBAC_TOKEN>

Note: The email entered for the admin in the request is used to ensure the admin receives an email invitation, whereas username is the attribute that the plugin uses with the IdP.

Assign a role to the admin

Assign the new admin at least one role so they can log in and access Kong entities:

  1. curl -i -X POST http://localhost:8001/admins/<admin_email>/roles \
  2. --data roles="<role-name>" \
  3. --header Kong-Admin-Token:<RBAC_TOKEN>

For example, to grant example_user@example.com the role of super admin:

  1. curl -i -X POST http://localhost:8001/admins/example_user@example.com/roles \
  2. --data roles="super-admin" \
  3. --header Kong-Admin-Token:<RBAC_TOKEN>