I can't disable the user with the Keyrock API

95 Views Asked by At

I want to disable or enable the user found in keyrock with API, but I can't. https://keyrock.docs.apiary.io/ doesn't say how to do it here. Isn't that possible?enter image description here

1

There are 1 best solutions below

0
Jason Fox On

Log in as an admin user via the REST API.

curl -iX POST \
  'http://localhost:3005/v1/auth/tokens' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "[email protected]",
  "password": "1234"
}'

The response header returns an X-Subject-token Header which identifies who has logged on the application. This token is required in all subsequent requests to gain access.

The image you give in the question is just a GUI version of the GET /users endpoint

curl -L -X GET 'http://localhost:3005/v1/users' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'

Or you can request a specific user:

curl -L -X GET 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'

Returns:

{
    "user": {
        "scope": [],
        "id": "bbbbbbbb-good-0000-0000-000000000000",
        "username": "bob",
        "email": "[email protected]",
        "enabled": true,
        "admin": false,
        "image": "default",
        "gravatar": false,
        "date_password": "2018-07-30T11:41:14.000Z",
        "description": "Bob is the regional manager",
        "website": null
    }
}

You want to set enabled: false using the PATCH /user endpoint.

curl -L -X PATCH 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
--data-raw '{
    "user": {
        "username": "bob",
        "email": "[email protected]",
        "enabled": false,
        "gravatar": false,
        "date_password": "2018-07-26T15:25:14.000Z"
    }
}'

More information can be found within the Security Chapter Tutorials within the FIWARE documentation where Keyrock is a component found within the FIWARE Catalogue

In the FIWARE documentation an example is given using Keyrock to provide user identities around a "powered by FIWARE" solution. Note that whilst Keyrock is commonly used in "powered by FIWARE" solutions (along with other elements from the FIWARE Catalogue), it could also be used to provide identities for other independent applications or micro-services - it is not tightly bound to only be used in FIWARE scenarios. Similarly alternative open-source or proprietary components for security or identity management systems could be used to secure "powered by FIWARE" solution as well.