Skip to content
Kong Logo | Kong Docs Logo
search
  • We're Hiring!
  • Docs
    • Kong Gateway
    • Kong Konnect
    • Kong Mesh
    • Plugin Hub
    • decK
    • Kubernetes Ingress Controller
    • Insomnia
    • Kuma

    • Docs contribution guidelines
  • Plugin Hub
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Plugin Hub
  • decK
  • Kubernetes Ingress Controller
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • 3.2.x (latest)
  • 3.1.x
  • 3.0.x
  • 2.8.x
  • 2.7.x
  • 2.6.x
  • Older Enterprise versions (2.1-2.5)
  • Older OSS versions (2.1-2.5)
  • Archive (pre-2.1)
    • Version Support Policy
    • Compatibility
    • Changelog
    • Kubernetes
    • Helm
    • OpenShift with Helm
    • Docker
    • Amazon Linux
    • CentOS
    • Debian
    • RHEL
    • Ubuntu
    • Migrating from OSS to EE
    • Upgrade Kong Gateway
    • Upgrade Kong Gateway OSS
      • Configuring a Service
      • Configuring a gRPC Service
      • Enabling Plugins
      • Adding Consumers
      • Prepare to Administer
      • Expose your Services
      • Protect your Services
      • Improve Performance
      • Secure Services
      • Set Up Intelligent Load Balancing
      • Manage Administrative Teams
      • Publish, Locate, and Consume Services
    • Running Kong as a Non-Root User
    • Resource Sizing Guidelines
      • Deploy Kong Gateway in Hybrid Mode
    • Kubernetes Deployment Options
    • Control Kong Gateway through systemd
    • Performance Testing Framework
    • DNS Considerations
    • Default Ports
      • Access Your License
      • Deploy Your License
      • Monitor License Usage
      • Start Kong Gateway Securely
      • Keyring and Data Encryption
      • Kong Security Update Process
      • Authentication Reference
        • OpenID Connect with Curity
        • OpenID Connect with Azure AD
        • OpenID Connect with Google
        • OpenID Connect with Okta
        • OpenID Connect with Auth0
        • OpenID Connect with Cognito
        • OpenID Connect Plugin Reference
      • Allowing Multiple Authentication Methods
        • Create a Super Admin
        • Configure Networking
        • Configure Kong Manager to Send Email
        • Reset Passwords and RBAC Tokens
        • Configure Workspaces
        • Basic Auth
        • LDAP
        • OIDC
        • Sessions
        • Add a Role
        • Add a User
        • Add an Admin
      • Mapping LDAP Service Directory Groups to Kong Roles
      • Enable the Dev Portal
      • Structure and File Types
      • Portal API Documentation
      • Working with Templates
      • Using the Editor
          • Basic Auth
          • Key Auth
          • OIDC
          • Sessions
          • Adding Custom Registration Fields
        • SMTP
        • Workspaces
        • Manage Developers
        • Developer Roles and Content Permissions
          • Authorization Provider Strategy
          • Enable Application Registration
          • Enable Key Authentication for Application Registration
          • External OAuth2 Support
          • Set up Okta and Kong for external OAuth
          • Set Up Azure AD and Kong for External Authentication
          • Manage Applications
        • Easy Theme Editing
        • Migrating Templates Between Workspaces
        • Markdown Rendering Module
        • Customizing Portal Emails
        • Adding and Using JavaScript Assets
        • Single Page App in Dev Portal
        • Alternate OpenAPI Renderer
      • Helpers CLI
    • Configure gRPC Plugins
    • GraphQL Quickstart
    • Logging Reference
    • Network and Firewall
      • Metrics
      • Reports
      • Vitals with InfluxDB
      • Vitals with Prometheus
      • Estimate Vitals Storage in PostgreSQL
    • Prometheus plugin
    • Zipkin plugin
      • DB-less Mode
      • Declarative Configuration
      • Supported Content Types
      • Information Routes
      • Health Routes
      • Tags
      • Service Object
      • Route Object
      • Consumer Object
      • Plugin Object
      • Certificate Object
      • CA Certificate Object
      • SNI Object
      • Upstream Object
      • Target Object
        • Licenses Reference
        • Licenses Examples
        • Workspaces Reference
        • Workspace Examples
        • RBAC Reference
        • RBAC Examples
        • API Reference
        • Examples
        • API Reference
        • Examples
        • Event Hooks Reference
        • Examples
      • Audit Logging
      • Keyring and Data Encryption
      • Securing the Admin API
    • DB-less and Declarative Configuration
    • Configuration Reference
    • CLI Reference
    • Load Balancing Reference
    • Proxy Reference
    • Rate Limiting Library
    • Health Checks and Circuit Breakers Reference
    • Clustering Reference
      • kong.client
      • kong.client.tls
      • kong.cluster
      • kong.ctx
      • kong.ip
      • kong.log
      • kong.nginx
      • kong.node
      • kong.request
      • kong.response
      • kong.router
      • kong.service
      • kong.service.request
      • kong.service.response
      • kong.table
      • Introduction
      • File structure
      • Implementing custom logic
      • Plugin configuration
      • Accessing the datastore
      • Storing custom entities
      • Caching custom entities
      • Extending the Admin API
      • Writing tests
      • (un)Installing your plugin
    • Plugins in Other Languages
    • File Permissions Reference

github-edit-pageEdit this page

report-issueReport an issue

enterprise-switcher-iconSwitch to OSS

On this page
  • Add a User
  • Retrieve a User
  • List Users
  • Update a User
  • Delete a User
  • Add a Role
  • Retrieve a Role
  • List Roles
  • Update or Create a Role
  • Update a Role
  • Delete a Role
  • Add a Role Endpoint Permission
  • Retrieve a Role Endpoint Permission
  • List Role Endpoints Permissions
  • Update a Role Endpoint Permission
  • Delete a Role Endpoint Permission
  • Add a Role Entity Permission
  • Retrieve a Role Entity Permission
  • List Entity Permissions
  • Update an Entity Permission
  • Delete an Entity Permission
  • List Role Permissions
  • Add a User to a Role
  • List a User’s Roles
  • Delete a Role from a User
  • List a User’s Permissions
Kong Gateway
2.7.x
  • Home
  • Kong Gateway
  • Admin API
  • Rbac
  • RBAC Reference
You are browsing documentation for an outdated version. See the latest documentation here.

RBAC Reference

Kong Kong Gateway’s RBAC feature is configurable through Kong’s Admin API or via the Kong Manager.

There are 4 basic entities involving RBAC.

  • User: The entity interacting with the system. Can be associated with zero, one or more roles. Example: user bob has token 1234.
  • Role: Set of permissions (role_endpoint and role_entity). Has a name and can be associated with zero, one or more permissions. Example: user bob is associated with role developer.
  • role_endpoint: A set of enabled or disabled (see negative parameter) actions (read, create, update, delete) endpoint. Example: Role developer has 1 role_endpoint: read & write to endpoint /routes
  • role_entity: A set of enabled or disabled (see negative parameter) actions (read, create, update, delete) entity. Example: Role developer has 1 role_entity: read & write & delete to entity 283fccff-2d4f-49a9-8730-dc8b71ec2245.

Add a User

Endpoint

/rbac/users

Request Body

Attribute Description
name The RBAC user name.
user_token The authentication token to be presented to the Admin API. The value will be hashed and cannot be fetched in plaintext.
enabled
optional
A flag to enable or disable the user. By default, users are enabled.
comment
optional
A string describing the RBAC user object.

Response

HTTP 201 Created
{
  "comment": null,
  "created_at": 1557522650,
  "enabled": true,
  "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  "name": "doc_knight",
  "user_token": "$2b$09$Za30VKAAAmyoB9zF2PNEF.9hgKcN2BdKkptPMCubPK/Ps08lzZjYG",
  "user_token_ident": "4d870"
}

Retrieve a User

Endpoint

/rbac/users/{name_or_id}
Attribute Description
name_or_id The RBAC user name or UUID.

Response

HTTP 200 OK
{
  "created_at": 1557522650,
  "enabled": true,
  "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  "name": "doc_lord",
  "user_token": "$2b$09$Za30VKAAAmyoB9zF2PNEF.9hgKcN2BdKkptPMCubPK/Ps08lzZjYG",
  "user_token_ident": "4d870"
}

List Users

Endpoint

/rbac/users/

Response

HTTP 200 OK
{
  "data": [
    {
      "comment": null,
      "created_at": 1557512629,
      "enabled": true,
      "id": "f035f120-a95e-4327-b2ae-8fa264601d75",
      "name": "doc_lord",
      "user_token": "$2b$09$TIMneYcTosdG9WbzRsqcweAS2zote8g6I8HqXAtbFHR1pds2ymsh6",
      "user_token_ident": "88ea3"
    },
    {
      "comment": null,
      "created_at": 1557522650,
      "enabled": true,
      "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
      "name": "doc_knight",
      "user_token": "$2b$09$Za30VKAAAmyoB9zF2PNEF.9hgKcN2BdKkptPMCubPK/Ps08lzZjYG",
      "user_token_ident": "4d870"
    }
  ],
  "next": null
}

⚠️ Note: RBAC Users associated with Admins will not be listed with GET /rbac/users. Instead, use GET /admins to list all Admins.


Update a User

Endpoint

/rbac/users/{name_or_id}
Attribute Description
name_or_id The RBAC user name or UUID.

Request Body

Attribute Description
user_token
optional
The authentication token to be presented to the Admin API. If this value is not present, the token will automatically be generated.
enabled
optional
A flag to enable or disable the user. By default, users are enabled.
comment
optional
A string describing the RBAC user object.

Response

HTTP 200 OK
{
  "comment": "this comment came from a patch request",
  "created_at": 1557522650,
  "enabled": true,
  "id": "fa6881b2-f49f-4007-9475-577cd21d34f4",
  "name": "donut_lord",
  "user_token": "$2b$09$Za30VKAAAmyoB9zF2PNEF.9hgKcN2BdKkptPMCubPK/Ps08lzZjYG",
  "user_token_ident": "4d870"
}

Delete a User

Endpoint

/rbac/users/{name_or_id}
Attribute Description
name_or_id The RBAC user name or UUID.

Response

HTTP 204 No Content

Add a Role

Endpoint

/rbac/roles
Attribute Description
name The RBAC role name.
comment
optional
A string describing the RBAC user object.

Response

HTTP 201 Created
{
  "comment": null,
  "created_at": 1557532241,
  "id": "b5c5cfd4-3330-4796-9b7b-6026e91e3ad6",
  "is_default": false,
  "name": "service_reader"
}

Retrieve a Role

Endpoint

/rbac/roles/{name_or_id}
Attribute Description
name_or_id The RBAC role name or UUID.

Response

HTTP 200 OK
{
  "created_at": 1557532241,
  "id": "b5c5cfd4-3330-4796-9b7b-6026e91e3ad6",
  "is_default": false,
  "name": "service_reader"
}

List Roles

Endpoint

/rbac/roles

Response

HTTP 200 OK
{
  "data": [
    {
      "comment": "Full access to all endpoints, across all workspaces—except RBAC Admin API",
      "created_at": 1557506249,
      "id": "38a03d47-faae-4366-b430-f6c10aee5029",
      "name": "admin"
    },
    {
      "comment": "Read access to all endpoints, across all workspaces",
      "created_at": 1557506249,
      "id": "4141675c-8beb-41a5-aa04-6258ab2d2f7f",
      "name": "read-only"
    },
    {
      "comment": "Full access to all endpoints, across all workspaces",
      "created_at": 1557506249,
      "id": "888117e0-f2b3-404d-823b-dee595423505",
      "name": "super-admin"
    },
    {
      "comment": null,
      "created_at": 1557532241,
      "id": "b5c5cfd4-3330-4796-9b7b-6026e91e3ad6",
      "name": "doc_lord"
    }
  ],
  "next": null
}

Update or Create a Role

Endpoint

/rbac/roles/{name_or_id}

Request Body

Attribute Description
name The RBAC role name.
comment
optional
A string describing the RBAC user object.

The behavior of PUT endpoints is the following: if the request payload does contain an entity’s primary key, the payload will “replace” the entity specified by the given primary key. If the primary key is not that of an existing entity, the entity will be created with the given payload.

Response

If creating the entity:

HTTP 201 Created

If replacing the entity:

HTTP 200 OK
{
  "comment": "the best",
  "created_at": 1557532566,
  "id": "b5c5cfd4-3330-4796-9b7b-6026e91e3ad6",
  "is_default": false,
  "name": "doc_lord"
}

Update a Role

Endpoint

/rbac/roles/{name_or_id}
Attribute Description
name_or_id The RBAC role or UUID.

Request Body

Attribute Description
comment
optional
A string describing the RBAC role object.

Response

HTTP 200 OK
{
  "comment": "comment from patch request",
  "created_at": 1557532566,
  "id": "b5c5cfd4-3330-4796-9b7b-6026e91e3ad6",
  "is_default": false,
  "name": "service_reader"
}

Delete a Role

Endpoint

/rbac/roles/{name_or_id}
Attribute Description
name The RBAC role name.

Response

HTTP 204 No Content

Add a Role Endpoint Permission

Endpoint

/rbac/roles/{name_or_id}/endpoints
Attribute Description
name_or_id The RBAC role name.

Request Body

Attribute Description
workspace Workspace tied to the endpoint. Defaults to the default permission. Special value of “*” means all workspaces are affected
endpoint Endpoint associated with this permission.
negative If true, explicitly disallow the actions associated with the permissions tied to this endpoint. By default this value is false.
actions One or more actions associated with this permission. This is a comma separated string (read,create,update,delete)
comment
optional
A string describing the RBAC permission object.

endpoint must be the path of the associated endpoint. They can be exact matches, or contain wildcards, represented by *.

  • Exact matches; eg:
    • /services/
    • /services/foo
  • Wildcards; eg:
    • /services/*
    • /services/*/plugins

Where * replaces exactly one segment between slashes (or the end of the path).

Note that wildcards can be nested (/rbac/*, /rbac/*/*, /rbac/*/*/* would refer to all paths under /rbac/)

Response

HTTP 201 Created
{
  "actions": [
    "delete",
    "create",
    "update",
    "read"
  ],
  "created_at": 1557764505,
  "endpoint": "/consumers",
  "negative": false,
  "role": {
    "id": "23df9f20-e7cc-4da4-bc89-d3a08f976e50"
  },
  "workspace": "default"
}

Retrieve a Role Endpoint Permission

Endpoint

/rbac/roles/{name_or_id}/endpoints/{workspace_name_or_id}/{endpoint}
Attribute Description
name_or_id The RBAC role name or UUID.
workspace_name_or_id The workspace name or UUID.
endpoint The endpoint associated with this permission.

Response

HTTP 200 OK
{
  "actions": [
    "delete",
    "create",
    "update",
    "read"
  ],
  "created_at": 1557764505,
  "endpoint": "/consumers",
  "negative": false,
  "role": {
    "id": "23df9f20-e7cc-4da4-bc89-d3a08f976e50"
  },
  "workspace": "default"
}

List Role Endpoints Permissions

Endpoint

/rbac/roles/{role_name_or_id}/endpoints
Attribute Description
role_name_or_id The RBAC role name or UUID.

Response

HTTP 200 OK
{
  "data": [
    {
      "actions": [
        "delete",
        "create",
        "update",
        "read"
      ],
      "created_at": 1557764505,
      "endpoint": "/consumers",
      "negative": false,
      "role": {
        "id": "23df9f20-e7cc-4da4-bc89-d3a08f976e50"
      },
      "workspace": "default"
    },
    {
      "actions": [
        "read"
      ],
      "created_at": 1557764438,
      "endpoint": "/services",
      "negative": false,
      "role": {
        "id": "23df9f20-e7cc-4da4-bc89-d3a08f976e50"
      },
      "workspace": "default"
    }
  ]
}

Update a Role Endpoint Permission

Endpoint

/rbac/roles/{name_or_id}/endpoints/{workspace_name_or_id}/{endpoint}
Attribute Description
name_or_id The RBAC role name or UUID.
workspace_name_or_id The workspace name or UUID.
endpoint The endpoint associated with this permission.

Request Body

Attribute Description
negative If true, explicitly disallow the actions associated with the permissions tied to this resource. By default this value is false.
actions One or more actions associated with this permission.

Response

HTTP 200 OK
{
  "actions": [
    "delete",
    "create",
    "update",
    "read"
  ],
  "created_at": 1557764438,
  "endpoint": "/services",
  "negative": false,
  "role": {
    "id": "23df9f20-e7cc-4da4-bc89-d3a08f976e50"
  },
  "workspace": "default"
}

Delete a Role Endpoint Permission

Endpoint

/rbac/roles/{name_or_id}/endpoints/{workspace_name_or_id}/{endpoint}
Attribute Description
name_or_id The RBAC role name or UUID.
workspace_name_or_id The workspace name or UUID.
endpoint The endpoint associated with this permission.

Response

HTTP 204 No Content

Add a Role Entity Permission

Endpoint

/rbac/roles/{name_or_id}/entities
Attribute Description
name_or_id The RBAC role name or UUID.

Request Body

Attribute Description
negative If true, explicitly disallow the actions associated with the permissions tied to this resource. By default this value is false.
entity_id id of the entity associated with this permission.
entity_type Type of the entity of a given entity_id.
actions One or more actions associated with this permission.
comment
optional
A string describing the RBAC permission object

entity_id must be the ID of an entity in Kong; if the ID of a workspace is given, the permission will apply to all entities in that workspace. Future entities belonging to that workspace will get the same permissions. A wildcard * will be interpreted as all entities in the system.

Response

HTTP 201 Created
{
  "actions": [
    "delete",
    "create",
    "read"
  ],
  "created_at": 1557771505,
  "entity_id": "*",
  "entity_type": "wildcard",
  "negative": false,
  "role": {
    "id": "bba049fa-bf7e-40ef-8e89-553dda292e99"
  }
}

Retrieve a Role Entity Permission

Endpoint

/rbac/roles/{name_or_id}/entities/{entity_id}
Attribute Description
name_or_id The RBAC permission name or UUID.
entity_id id of the entity associated with this permission.

Response

HTTP 200 Ok
{
  "actions": [
    "delete",
    "create",
    "read"
  ],
  "created_at": 1557771505,
  "entity_id": "*",
  "entity_type": "wildcard",
  "negative": false,
  "role": {
    "id": "bba049fa-bf7e-40ef-8e89-553dda292e99"
  }
}

List Entity Permissions

Endpoint

/rbac/roles/{name_or_id}/entities
Attribute Description
name_or_id The RBAC permission name or UUID.

Response

HTTP 200 Ok
{
  "data": [
    {
      "actions": [
        "delete",
        "create",
        "read"
      ],
      "created_at": 1557771505,
      "entity_id": "*",
      "entity_type": "wildcard",
      "negative": false,
      "role": {
        "id": "bba049fa-bf7e-40ef-8e89-553dda292e99"
      }
    }
  ]
}

Update an Entity Permission

Endpoint

/rbac/roles/{name_or_id}/entities/{entity_id}
Attribute Description
name_or_id The RBAC role name or UUID.
entity_id The entity name or UUID.

Request Body

Attribute Description
negative If true, explicitly disallow the actions associated with the permissions tied to this resource. By default this value is false.
actions One or more actions associated with this permission.

Response

HTTP 200 OK
{
  "actions": [
    "update"
  ],
  "created_at": 1557771505,
  "entity_id": "*",
  "entity_type": "wildcard",
  "negative": false,
  "role": {
    "id": "bba049fa-bf7e-40ef-8e89-553dda292e99"
  }
}

Delete an Entity Permission

Endpoint

/rbac/roles/{name_or_id}/entities/{entity_id}
Attribute Description
name_or_id The RBAC role name or UUID.
entity_id The entity name or UUID.

Response

HTTP 204 No Content

List Role Permissions

Endpoint

/rbac/roles/{name_or_id}/permissions/
Attribute Description
name_or_id The RBAC role name or UUID.

Response

HTTP 200 OK
{
  "endpoints": {
    "*": {
      "*": {
        "actions": [
          "delete",
          "create",
          "update",
          "read"
        ],
        "negative": false
      },
      "/*/rbac/*": {
        "actions": [
          "delete",
          "create",
          "update",
          "read"
        ],
        "negative": true
      }
    }
  },
  "entities": {}
}

Add a User to a Role

Endpoint

/rbac/users/{name_or_id}/roles
Attribute Description
name_or_id The RBAC role name or UUID.

Request Body

Attribute Description
roles Comma-separated list of role names to assign to the user.

Response

HTTP 201 Created
{
  "roles": [
    {
      "created_at": 1557772263,
      "id": "aae80073-095f-4553-ba9a-bee5ed3b8b91",
      "name": "doc-knight"
    }
  ],
  "user": {
    "comment": null,
    "created_at": 1557772232,
    "enabled": true,
    "id": "b65ca712-7ceb-4114-87f4-5c310492582c",
    "name": "gruce-wayne",
    "user_token": "$2b$09$gZnMKK/mm/d2rAXN7gL63uL43mjdX/62iwMqdyCQwLyC0af3ce/1K",
    "user_token_ident": "88ea3"
  }
}

List a User’s Roles

Endpoint

/rbac/users/{name_or_id}/roles
Attribute Description
name_or_id The RBAC role name or UUID.

Response

HTTP 200 OK

{
  "roles": [
    {
      "comment": "Read access to all endpoints, across all workspaces",
      "created_at": 1557765500,
      "id": "a1c810ee-8366-4654-ba0c-963ffb9ccf2e",
      "name": "read-only"
    },
    {
      "created_at": 1557772263,
      "id": "aae80073-095f-4553-ba9a-bee5ed3b8b91",
      "name": "doc-knight"
    }
  ],
  "user": {
    "comment": null,
    "created_at": 1557772232,
    "enabled": true,
    "id": "b65ca712-7ceb-4114-87f4-5c310492582c",
    "name": "gruce-wayne",
    "user_token": "$2b$09$gZnMKK/mm/d2rAXN7gL63uL43mjdX/62iwMqdyCQwLyC0af3ce/1K",
    "user_token_ident": "88ea3"
  }
}

Delete a Role from a User

Endpoint

/rbac/users/{name_or_id}/roles
Attribute Description
name_or_id The RBAC role name or UUID.

Request Body

Attribute Description
roles Comma-separated list of role names to assign to the user.

Response

HTTP 204 No Content

List a User’s Permissions

Endpoint

/rbac/users/{name_or_id}/permissions
Attribute Description
name_or_id The RBAC role name or UUID.

Response

HTTP 200 OK
{
  "endpoints": {
    "*": {
      "*": {
        "actions": [
          "read"
        ],
        "negative": false
      }
    }
  },
  "entities": {}
}

Thank you for your feedback.
Was this page useful?
  • Kong
    THE CLOUD CONNECTIVITY COMPANY

    Kong powers reliable digital connections across APIs, hybrid and multi-cloud environments.

    • Company
    • Customers
    • Events
    • Investors
    • Careers Hiring!
    • Partners
    • Press
    • Contact
  • Products
    • Kong Konnect
    • Kong Gateway
    • Kong Mesh
    • Get Started
    • Pricing
  • Resources
    • eBooks
    • Webinars
    • Briefs
    • Blog
    • API Gateway
    • Microservices
  • Open Source
    • Install Kong Gateway
    • Kong Community
    • Kubernetes Ingress
    • Kuma
    • Insomnia
  • Solutions
    • Decentralize
    • Secure & Govern
    • Create a Dev Platform
    • API Gateway
    • Kubernetes
    • Service Mesh
Star
  • Terms•Privacy
© Kong Inc. 2023