realm-management roles that set what agents can see and change.
Prerequisites
- A Keycloak server CloudThinker can reach over the network. For a server behind a firewall, see Reaching private services. CloudThinker doesn’t block
http, but the client secret then travels unencrypted, so usehttps. - An administrator who can create a client in the target realm and assign it service account roles.
- The realm name.
- The Admin role in your CloudThinker workspace, which can add and edit connections. See Roles.
A workspace holds one Keycloak connection, and it targets one realm. Agents get a token from
<KEYCLOAK_URL>/realms/<KEYCLOAK_REALM>/protocol/openid-connect/token, so the base URL must be the part before /realms.Setup
Both tabs create the same thing: a confidential client namedcloudthinker-svc with service accounts enabled and realm-management roles on its service account.
- Admin console
- kcadm.sh
Works for self-hosted Keycloak and managed Keycloak such as Phase Two.
1
Create the client
In the admin console, switch to your realm, open Clients, and select Create client. Set Client ID to
cloudthinker-svc and select Next. Turn on Client authentication, check Service accounts roles, and leave the other flows off. Select Next, then Save.2
Assign realm-management roles
Open the client, go to Service accounts roles, and select Assign role. Filter by clients, search for
realm-management, and pick the roles. For read-only audits, pick view-realm, view-users, query-users, view-clients, query-clients, and query-groups. To allow changes, see Required permissions. The list can span more than one page.3
Copy the client secret
On the same client, open Credentials and copy Client Secret.
1
Add the connection in CloudThinker
Open More → Workspace settings → Connections, select Keycloak, and fill in the fields from Connection details. Click Connect.Success state: the connection shows Connecting and Verifying, then Connected. CloudThinker signs in as the service account and counts the realm’s users, which proves both the secret and the
view-users role.Connection details
For Phase Two, copy the base URL from the realm card in the Phase Two dashboard: select Details and copy Host.
Required permissions
Assignrealm-management client roles to the service account. Pick the narrowest set that covers your use.
realm-admin includes every role above. It’s the quickest choice and the broadest, so use it only if agents should manage the whole realm.
Agent capabilities
Reads run without asking. Allow writes on the connection’s detail panel is on by default; turn it off to refuse every change. Every change goes through Approvals first.
Every change an agent makes goes through your workspace’s Approvals first. On the default Auto · Rules + AI · Ask me mode, AI judgment can let a safe change run without asking — and an Allow Rule can too, once CloudThinker turns on Rule enforcement for your workspace. Choose Manual to approve every change yourself.
List reads return up to 100 entries by default, so for a large realm, ask about a group, a client, or a username rather than everyone.
CloudThinker passes a new user password to Keycloak on standard input, so it stays out of command logs. It can still appear in the conversation if you type it there, so prefer letting users reset their own password through Keycloak.
Verify the connection
view-users. To check client access too, ask which clients have direct access grants enabled, which needs view-clients.
Example prompts
Troubleshooting
Failed to connect to Keycloak
Failed to connect to Keycloak
CloudThinker couldn’t get a token or count users. Check in this order:
- KEYCLOAK_URL is reachable from CloudThinker and stops before
/realms. Add/authif your server serves under it. - KEYCLOAK_REALM is the realm where you created the client. Names are case-sensitive.
- Client authentication and Service accounts roles are on for the client, and the secret was copied in full.
- The service account has
view-users.
The client has no secret
The client has no secret
The client is public. Turn on Client authentication, or set
publicClient=false with kcadm.sh, then copy the secret from Credentials.403 Forbidden on some questions
403 Forbidden on some questions
The token works, but the service account lacks the role for that endpoint. Read questions need a
view-* or query-* role and changes need a manage-* role. Add the role from Required permissions. Roles apply on the next token, so retry the question.An agent shows only 100 users
An agent shows only 100 users
List reads stop at 100 by default. Ask for a specific username or group, or ask the agent to page through more results.
Security
- Least privilege — grant only the permissions the agents need for your use case; start read-only and widen later.
- Read-only by default — use read-only credentials unless you want agents to make changes through this connection.
- Rotate credentials — rotate keys and tokens on your normal schedule; CloudThinker picks up the new value when you update the connection.
- Revoke on offboarding — remove the credential at the provider when you delete a connection or a teammate leaves.
- Use a dedicated client: keep
cloudthinker-svcfor CloudThinker only, so you can revoke it without affecting other apps. - Rotate the secret: the connection breaks the moment you regenerate it, so do both steps together. Keycloak is a single-connection service, so its row has no pencil icon. Regenerate the secret under Credentials in Keycloak, then open More → Workspace settings → Connections and select Keycloak. Once it shows Error, click Replace credentials, click Replace… next to the saved credentials, paste the new KEYCLOAK_CLIENT_SECRET, and click Save and test. See Rotate a credential.
- Avoid
realm-adminfor audits: read-only roles cover every question in the read rows above.
Related
Approvals
Decide which Keycloak changes run, wait for a person, or are refused.
Connections
See every service you can connect and how connection status works.