Configuration
This plugin is not compatible with DB-less mode.
For its regular work, the plugin needs to both generate and delete tokens, and commit those changes to the database, which is not compatible with DB-less.
In addition to this, its Admin API endpoints offer several POST, PATCH, PUT, and DELETE methods for tokens and credentials. None of them would work on DB-less.
Compatible protocols
The OAuth 2.0 Authentication plugin is compatible with the following protocols:
grpc
, grpcs
, http
, https
, ws
, wss
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
-
name or plugin
string requiredThe name of the plugin, in this case
oauth2
.- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
name
. - If using the KongPlugin object in Kubernetes, the field is
plugin
.
- If using the Kong Admin API, Konnect API, declarative configuration, or decK files, the field is
-
instance_name
stringAn optional custom name to identify an instance of the plugin, for example
oauth2_my-service
.The instance name shows up in Kong Manager and in Konnect, so it's useful when running the same plugin in multiple contexts, for example, on multiple services. You can also use it to access a specific plugin instance via the Kong Admin API.
An instance name must be unique within the following context:
- Within a workspace for Kong Gateway Enterprise
- Within a control plane or control plane group for Konnect
- Globally for Kong Gateway (OSS)
-
service.name or service.id
stringThe name or ID of the service the plugin targets. Set one of these parameters if adding the plugin to a service through the top-level
/plugins
endpoint. Not required if using/services/{serviceName|Id}/plugins
. -
route.name or route.id
stringThe name or ID of the route the plugin targets. Set one of these parameters if adding the plugin to a route through the top-level
/plugins
endpoint. Not required if using/routes/{routeName|Id}/plugins
. -
enabled
boolean default:true
Whether this plugin will be applied.
-
config
record required-
scopes
array of typestring
Describes an array of scope names that will be available to the end user. If
mandatory_scope
is set totrue
, thenscopes
are required.
-
mandatory_scope
boolean required default:false
An optional boolean value telling the plugin to require at least one
scope
to be authorized by the end user.
-
provision_key
string required encryptedThe unique key the plugin has generated when it has been added to the Service.
-
token_expiration
number required default:7200
An optional integer value telling the plugin how many seconds a token should last, after which the client will need to refresh the token. Set to
0
to disable the expiration.
-
enable_authorization_code
boolean required default:false
An optional boolean value to enable the three-legged Authorization Code flow (RFC 6742 Section 4.1).
-
enable_implicit_grant
boolean required default:false
An optional boolean value to enable the Implicit Grant flow which allows to provision a token as a result of the authorization process (RFC 6742 Section 4.2).
-
enable_client_credentials
boolean required default:false
An optional boolean value to enable the Client Credentials Grant flow (RFC 6742 Section 4.4).
-
enable_password_grant
boolean required default:false
An optional boolean value to enable the Resource Owner Password Credentials Grant flow (RFC 6742 Section 4.3).
-
hide_credentials
boolean required default:false
An optional boolean value telling the plugin to show or hide the credential from the upstream service.
-
accept_http_if_already_terminated
boolean required default:false
Accepts HTTPs requests that have already been terminated by a proxy or load balancer.
-
anonymous
stringAn optional string (consumer UUID or username) value to use as an “anonymous” consumer if authentication fails.
-
global_credentials
boolean required default:false
An optional boolean value that allows using the same OAuth credentials generated by the plugin with any other service whose OAuth 2.0 plugin configuration also has
config.global_credentials=true
.
-
auth_header_name
string default:authorization
The name of the header that is supposed to carry the access token.
-
refresh_token_ttl
number required default:1209600
between:0
100000000
Time-to-live value for data
-
reuse_refresh_token
boolean required default:false
An optional boolean value that indicates whether an OAuth refresh token is reused when refreshing an access token.
-
persistent_refresh_token
boolean required default:false
-
pkce
string default:lax
Must be one of:none
,lax
,strict
Specifies a mode of how the Proof Key for Code Exchange (PKCE) should be handled by the plugin.
-
realm
stringWhen authentication fails the plugin sends
WWW-Authenticate
header withrealm
attribute value.
-