Enable the plugin for the Client Credentials flow
Configure the plugin to enable the Client Credentials OAuth 2.0 flow
Environment variables
-
PROVISION_KEY
: The provision key to use.
Add this section to your declarative configuration file:
_format_version: "3.0"
plugins:
- name: oauth2
config:
scopes:
- email
provision_key: ${{ env "DECK_PROVISION_KEY" }}
enable_client_credentials: true
Make the following request:
curl -i -X POST http://localhost:8001/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "oauth2",
"config": {
"scopes": [
"email"
],
"provision_key": "'$PROVISION_KEY'",
"enable_client_credentials": true
}
}
'
echo "
apiVersion: configuration.konghq.com/v1
kind: KongClusterPlugin
metadata:
name: oauth2
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
labels:
global: 'true'
config:
scopes:
- email
provision_key: '$PROVISION_KEY'
enable_client_credentials: true
plugin: oauth2
" | kubectl apply -f -
Prerequisite: Configure your Personal Access Token
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Add the following to your Terraform configuration to create a Konnect Gateway Plugin:
resource "konnect_gateway_plugin_oauth2" "my_oauth2" {
enabled = true
config = {
scopes = ["email"]
provision_key = var.provision_key
enable_client_credentials = true
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
}
This example requires the following variables to be added to your manifest. You can specify values at runtime by setting TF_VAR_name=value
.
variable "provision_key" {
type = string
}
Add this section to your declarative configuration file:
_format_version: "3.0"
plugins:
- name: oauth2
service: serviceName|Id
config:
scopes:
- email
provision_key: ${{ env "DECK_PROVISION_KEY" }}
enable_client_credentials: true
Make sure to replace the following placeholders with your own values:
-
serviceName|Id
: Theid
orname
of the service the plugin configuration will target.
Make the following request:
curl -i -X POST http://localhost:8001/services/{serviceName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "oauth2",
"config": {
"scopes": [
"email"
],
"provision_key": "'$PROVISION_KEY'",
"enable_client_credentials": true
}
}
'
Make sure to replace the following placeholders with your own values:
-
serviceName|Id
: Theid
orname
of the service the plugin configuration will target.
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: oauth2
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
scopes:
- email
provision_key: '$PROVISION_KEY'
enable_client_credentials: true
plugin: oauth2
" | kubectl apply -f -
Next, apply the KongPlugin
resource by annotating the service
resource:
kubectl annotate -n kong service SERVICE_NAME konghq.com/plugins=oauth2
Prerequisite: Configure your Personal Access Token
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Add the following to your Terraform configuration to create a Konnect Gateway Plugin:
resource "konnect_gateway_plugin_oauth2" "my_oauth2" {
enabled = true
config = {
scopes = ["email"]
provision_key = var.provision_key
enable_client_credentials = true
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
service = {
id = konnect_gateway_service.my_service.id
}
}
This example requires the following variables to be added to your manifest. You can specify values at runtime by setting TF_VAR_name=value
.
variable "provision_key" {
type = string
}
Add this section to your declarative configuration file:
_format_version: "3.0"
plugins:
- name: oauth2
route: routeName|Id
config:
scopes:
- email
provision_key: ${{ env "DECK_PROVISION_KEY" }}
enable_client_credentials: true
Make sure to replace the following placeholders with your own values:
-
routeName|Id
: Theid
orname
of the route the plugin configuration will target.
Make the following request:
curl -i -X POST http://localhost:8001/routes/{routeName|Id}/plugins/ \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '
{
"name": "oauth2",
"config": {
"scopes": [
"email"
],
"provision_key": "'$PROVISION_KEY'",
"enable_client_credentials": true
}
}
'
Make sure to replace the following placeholders with your own values:
-
routeName|Id
: Theid
orname
of the route the plugin configuration will target.
echo "
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: oauth2
namespace: kong
annotations:
kubernetes.io/ingress.class: kong
config:
scopes:
- email
provision_key: '$PROVISION_KEY'
enable_client_credentials: true
plugin: oauth2
" | kubectl apply -f -
Next, apply the KongPlugin
resource by annotating the httproute
or ingress
resource:
kubectl annotate -n kong httproute konghq.com/plugins=oauth2
kubectl annotate -n kong ingress konghq.com/plugins=oauth2
Prerequisite: Configure your Personal Access Token
terraform {
required_providers {
konnect = {
source = "kong/konnect"
}
}
}
provider "konnect" {
personal_access_token = "$KONNECT_TOKEN"
server_url = "https://us.api.konghq.com/"
}
Add the following to your Terraform configuration to create a Konnect Gateway Plugin:
resource "konnect_gateway_plugin_oauth2" "my_oauth2" {
enabled = true
config = {
scopes = ["email"]
provision_key = var.provision_key
enable_client_credentials = true
}
control_plane_id = konnect_gateway_control_plane.my_konnect_cp.id
route = {
id = konnect_gateway_route.my_route.id
}
}
This example requires the following variables to be added to your manifest. You can specify values at runtime by setting TF_VAR_name=value
.
variable "provision_key" {
type = string
}