このページは、まだ日本語ではご利用いただけません。翻訳中です。
OIDC Authenticated Group Mapping
Using Kong’s OpenID Connect plugin (OIDC), you can map identity provider (IdP)
groups to Kong roles. Adding a user to Kong in this way gives them access to
Kong based on their group in the IdP.
Admin accounts are now created automatically
when you map your identity provider (IdP) groups to Kong roles. You do
not need to create the users, groups, and roles separately. These users then accept invitations to join
Kong Manager and log in with their IdP credentials.
Important: In v3.6.x, many of the parameters under admin_gui_auth_conf
have changed their behavior.
Review the changes and adjust your configuration accordingly.
If an admin’s group changes in the IdP, their Kong admin account’s associated
role also changes in Kong Gateway the next time they log in to Kong
Manager. The mapping removes the task of manually managing access in
Kong Gateway, because it makes the IdP the system of record.
When using OIDC group mapping, roles assigned to admins are managed by the IdP.
If you manually assign or unassign admin roles, changes will be overwritten during the next login.
Prerequisites
Apply OIDC auth mapping to Kong Gateway
Review important values
In the following examples, you specify the admin_claim
and authenticated_groups_claim
parameters
to identify which admin value and role name to map from the IdP to Kong Gateway, as well as
the admin_auto_create_rbac_token_disabled
to specify whether an RBAC token is created for admins in Kong.
-
The admin_claim
value specifies which IdP username value should map to Kong Manager.
The username and password are required for the user to log into the IdP.
-
The authenticated_groups_claim
value specifies which IdP claim should be used to assign Kong Gateway roles to the
specified Kong Gateway admin.
This value depends on your IdP – for example, Okta configures claims for groups
, and another IdP might configure them as roles
.
In the IdP, the group claim value must follow the format <workspace_name>:<role_name>
.
For example, if "authenticated_groups_claim": ["groups"]
is specified, and in the IdP groups:["default:super-admin"]
is specified, the administrators specified in admin_claim
are assigned to the super-admin role in the default Kong Gateway workspace.
If the mapping does not work as expected, decode the JWT that’s created by your IdP, and make sure that the admin ID token includes the key:value pair groups:["default:super-admin"]
for the case of this example, or the appropriate claim name and claim value as set in your IdP.
- The
admin_auto_create_rbac_token_disabled
boolean enables or disables RBAC token
creation when automatically creating admins with OpenID Connect. The default is
false
.
- Set to
true
to disable automatic token creation for admins
- Set to
false
to enable automatic token creation for admins
- The
admin_auto_create
boolean enables or disables admin auto-creation
with OpenID Connect. The default is true
.
- Set to
true
to enable automatic admin creation
- Set to
false
to disable automatic admin creation
Set up mapping
Kubernetes with Helm
Docker
kong.conf
-
Create a configuration file for the OIDC plugin and save it as
admin_gui_auth_conf
.
Provide your own values for all fields indicated by curly braces ({}
):
{
"issuer": "{YOUR_IDP_URL}",
"admin_claim": "email",
"client_id": ["{CLIENT_ID}"],
"client_secret": ["{CLIENT_SECRET}"],
"authenticated_groups_claim": ["{CLAIM_NAME}"],
"ssl_verify": false,
"leeway": 60,
"redirect_uri": ["{YOUR_REDIRECT_URI}"],
"login_redirect_uri": ["{YOUR_LOGIN_REDIRECT_URI}"],
"logout_methods": ["GET", "DELETE"],
"logout_query_arg": "logout",
"logout_redirect_uri": ["{YOUR_LOGOUT_REDIRECT_URI}"],
"scopes": ["openid","profile","email","offline_access"],
"auth_methods": ["authorization_code"],
"admin_auto_create_rbac_token_disabled": false,
"admin_auto_create": true
}
For detailed descriptions of all OIDC parameters, see the
OpenID Connect parameter reference.
-
Create a secret from the file you just created:
kubectl create secret generic kong-idp-conf --from-file=admin_gui_auth_conf -n kong
-
Update the RBAC section of the deployment values.yml
file with the
following parameters:
rbac:
enabled: true
admin_gui_auth: openid-connect
session_conf_secret: kong-session-conf
admin_gui_auth_conf_secret: kong-idp-conf
-
Using Helm, upgrade the deployment with your YAML filename:
helm upgrade --install kong-ee kong/kong -f ./myvalues.yaml -n kong
If you have a Docker installation, run the following command to set the needed
environment variables and reload the Kong Gateway configuration.
Provide your own values for all fields indicated by curly braces ({}
):
echo "
KONG_ENFORCE_RBAC=on \
KONG_ADMIN_GUI_AUTH=openid-connect \
KONG_ADMIN_GUI_AUTH_CONF='{
\"issuer\": \"{YOUR_IDP_URL}\",
\"admin_claim\": \"email\",
\"client_id\": [\"<someid>\"],
\"client_secret\": [\"<somesecret>\"],
\"authenticated_groups_claim\": [\"{CLAIM_NAME}\"],,
\"ssl_verify\": false,
\"leeway\": 60,
\"redirect_uri\": [\"{YOUR_REDIRECT_URI}\"],
\"login_redirect_uri\": [\"{YOUR_LOGIN_REDIRECT_URI}\"],
\"logout_methods\": [\"GET\", \"DELETE\"],
\"logout_query_arg\": \"logout\",
\"logout_redirect_uri\": [\"{YOUR_LOGOUT_REDIRECT_URI}\"],
\"scopes\": [\"openid\",\"profile\",\"email\",\"offline_access\"],
\"auth_methods\": [\"authorization_code\"],
\"admin_auto_create_rbac_token_disabled\": false,
\"admin_auto_create\": true
}' kong reload exit" | docker exec -i {KONG_CONTAINER_ID} /bin/sh
Replace {KONG_CONTAINER_ID}
with the ID of your container.
For detailed descriptions of all the parameters used here, and many other customization options,
see the OpenID Connect parameter reference.
-
Navigate to your kong.conf
file.
-
With RBAC enabled, add the admin_gui_auth
and admin_gui_auth_conf
properties to the file.
Provide your own values for all fields indicated by curly braces ({}
):
enforce_rbac = on
admin_gui_auth = openid-connect
admin_gui_auth_conf = {
"issuer": "{YOUR_IDP_URL}",
"admin_claim": "email",
"client_id": ["{CLIENT_ID}"],
"client_secret": ["{CLIENT_SECRET}"],
"authenticated_groups_claim": ["{CLAIM_NAME}"],
"ssl_verify": false,
"leeway": 60,
"redirect_uri": ["{YOUR_REDIRECT_URI}"],
"login_redirect_uri": ["{YOUR_LOGIN_REDIRECT_URI}"],
"logout_methods": ["GET", "DELETE"],
"logout_query_arg": "logout",
"logout_redirect_uri": ["{YOUR_LOGOUT_REDIRECT_URI}"],
"scopes": ["openid","profile","email","offline_access"],
"auth_methods": ["authorization_code"],
"admin_auto_create_rbac_token_disabled": false,
"admin_auto_create": true
}
For detailed descriptions of all the parameters used here, and many other
customization options, see the OpenID Connect parameter reference.
-
Restart Kong Gateway to apply the file.
kong restart -c /path/to/kong.conf