Kong Enterprise Edition (KongEE) - List Admin Roles using REST API
                
            
            
            
            
            
            
                           
                
            
            
            
                
    
    
    
            
                
                    by
                    Jeremy Canfield  |  
                    Updated: September 08 2022
                    
                          |  Kong Enterprise Edition (KongEE) articles
                    
                    
                    
                
            
            This assumes Kong has been secured with Role Based Access Control (RBAC) and you have created your Kong-Admin-Token. The following curl command can be used to list the endpoints that can be used with the API.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/endpoints"
Something like this should be returned. Notice that the /admins endpoint can be used.
{       
    "data": [
        "/",
        "/acls",
        "/acls/{acls}",
        "/acls/{acls}/consumer",
        "/acme",
        "/acme/certificates",
        "/acme/certificates/{ceritificates}",
        "/acme_storage",
        "/acme_storage/{acme_storage}",
        "/admins",
        "/admins/password_resets",
        "/admins/register",
        "/admins/self/password",
        "/admins/self/token",
        "/admins/{admins}",
        "/admins/{admins}/consumer",
        "/admins/{admins}/rbac_user",
        "/admins/{admin}/roles",
        "/admins/{admin}/workspaces"
    ]
}
This assumes Kong has been secured with Role Based Access Control (RBAC) and you have created your Kong-Admin-Token. The following curl command can be used to list every admin.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/admins"
Something like this should be returned.
{
    "data": [
        {
            "created_at": 1603213998,
            "email": "john.doe@example.com",
            "id": "025f899e-46de-45a8-aedd-9a6e60eb0cd9",
            "rbac_token_enabled": true,
            "status": 0,
            "updated_at": 1603215092,
            "username": "john.doe",
            "workspaces": [
                {
                    "name": "*"
                },
                {
                    "config": {
                        "portal": false,
                        "portal_developer_meta_fields": "[{\"label\":\"Full Name\",\"title\":\"full_name\",\"validator\":{\"required\":true,\"type\":\"string\"}}]"
                    },
                    "created_at": 1556808555,
                    "id": "23dcd187-1f7a-463c-8565-8f6e5bfbb430",
                    "is_admin_workspace": true,
                    "name": "default"
                }
            ]
        }
    ],
    "next": null
}
Or, a specific admin can be listed.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/admin/john.doe"
The following can be used to list an admins roles.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/admin/john.doe/roles"
Something like this should be returned.
{
    "roles": [
        {
            "comment": "Full access to all endpoints, across all workspaces",
            "created_at": 1556808553,
            "id": "64f6c2af-1d05-42b7-b3bc-0346930f0fe7",
            "is_default": false,
            "name": "super-admin",
            "ws_id": "23dcd187-1f7a-463c-8565-8f6e5bfbb430"
        }
    ]
}
Did you find this article helpful?
If so, consider buying me a coffee over at 