Kong Gateway uses a precedence model when checking if a user has sufficient permissions to access an endpoint, a resource, or a Workspace. This information is collected from the various permissions or applied across the roles and groups assigned to a user.
For each request, Kong Gateway checks for an RBAC rule assigned to the requesting user in the following order:
- Allow or deny permissions against the current endpoint in the current Workspace.
- Wildcard allow or deny permissions against the current endpoint in any Workspace.
- Allow or deny permissions against any endpoint (wildcard) in the current Workspace.
- Wildcard allow or deny permissions against any endpoint in any Workspace.
If Kong Gateway finds a matching permission for the current user, endpoint, or Workspace, it allows or denies the request based on it. Once Kong Gateway finds an applicable rule, the algorithm stops and doesn’t check less specific permissions. If no permission is found (approval or denial), the request is denied.
To create an endpoint permission via /rbac/roles/:role/endpoints
,
you must pass the parameters below, all of which can be replaced by a *
character:
-
endpoint
: *
matches any endpoint
-
workspace
: *
matches any workspace
-
actions
: *
evaluates to all actions—read, update, create, delete
endpoint
, in addition to a single *
, also accepts *
within the endpoint itself, replacing a URL segment between /
. For example,
all of the following are valid endpoints:
-
/rbac/*
: where *
replaces any possible segment, for example /rbac/users
and /rbac/roles
-
/services/*/plugins
: *
matches any service name or ID
Note *
is not a generic, shell-like, glob pattern.
Therefore, /rbac/*
or /workspaces/*
alone don’t match all of the RBAC and Workspaces endpoints.
For example, to cover all of the RBAC API, you would have to define permissions for the following endpoints:
/rbac/*
/rbac/*/*
/rbac/*/*/*
/rbac/*/*/*/*
/rbac/*/*/*/*/*
If workspace
is omitted, it defaults to the current request’s workspace. For
example, a role-endpoint permission created with /teamA/roles/admin/endpoints
is scoped to workspace teamA
.
For entity permissions created via /rbac/roles/:role/entities
,
the following parameter accepts a *
character:
-
entity_id
: *
matches any entity ID