Repository navigation
Conversation
…an the chosen one Keycloak keeps one offline session per browser session and client and issues every token of it with the scopes of its first login. When that session began at Safe access, a later Full access login came back with cli-access-write. Login took the missing cli-access-full scope for a meshStack without access levels and stored no level, which reads as Full access, so the next login did not end the session either and every Full access login silently kept Safe access. A login that comes back with another level's scope now revokes the new refresh token, which ends that offline session, and fails with a message that names both levels and asks to log in again. If the revoke fails, the message names the two logins that end the session. A level is stored as empty only when the token carries no access level scope at all. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Coverage of the acceptance run against the meshStack backend, on
Uncovered functions
|
A login that a CLI with the bug stored without a level read as Full access, although its tokens grant Safe access. The next Full access login then skipped ending the earlier session before the redirect and failed. The previous level now comes from the scope of the login's latest cached token, so that login ends the session first and succeeds. The stored level is the fallback when there is no token, or none of them carries a level scope. A login that comes back with no access level scope when Safe access or Read-only was chosen now ends its session too. It could be a session from before access levels rather than a meshStack without them, and without ending it every retry would fail the same way. Keycloak 26.2 and later end only the revoked token's own offline session and the CLI's client session in the matching browser session. Keycloak 26.0 instead revoked the client's consent and every offline session of the user for the client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
grubmeshi
requested changes
Nov 19, 2026
| assert.Empty(t, pages.chosenLevel()) | ||
| } | ||
|
|
||
| func TestALoginThatKeycloakGrantsAnotherAccessLevelIsEnded(t *testing.T) { |
Collaborator
There was a problem hiding this comment.
d: Please make this an acc test case and really check it works? I've investigated this as well and I doubt it has a simple solution.
…s a safe access login This is the case behind the fix: Keycloak grants a login the access level of another profile's earlier login in the same browser session. The test checks three things: - that first login fails and ends the shared session, so the other profile's refresh token stops working too - the next login gets the level it chose, both stored and in its token - the logout test now uses the same refresh check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en response The acceptance test showed what really happens: a Full access login in a browser session that already held a Safe access login stored Full access, but its access token carried cli-access-write. The scope field of Keycloak's token response does not match the access token's own scope claim, and meshStack authorizes by that claim, so the login has to check the claim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The acceptance run on 80569ef shows a Full access login that shares its browser session with a Safe access login of another profile. Its code-exchange token passes the check: it carries either cli-access-full or no level scope, and the run cannot tell which. The workspace token that the login fetches next by a refresh grants Safe access. A refresh takes its scopes from the offline session, which the two logins share. 80569ef put the cause in a mismatch between the token response and the access token. The run does not show that. Reading the level from the access token's claim is still right, since meshStack authorizes by that claim. The login now refreshes its new token once, with openid and offline_access so it inherits no workspace, and checks the level on the refreshed token. It keeps that token, because Keycloak rotates the refresh token on every refresh. On a mismatch it revokes the refreshed refresh token. The acceptance test now names the stored level and the token's level when the Full access login passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Keycloak keeps one offline session per browser session and client and issues every token of it with the scopes of its first login. When that session started at Safe access (
cli-access-write), every later Full access login came back withcli-access-write:browser.Logintook the missingcli-access-fullscope for a meshStack without access levels and returned the level"".resolveOidcLoginCredentialstored"", andPrevious.endIfReplacedreads""as Full access, so the next Full access login did not end the session either.meshstack auth statusshowed "with Full access, but the token grants Safe access". Building block orders failed with 403 Missing permissions (PLATFORMINSTANCE_DELETE,LANDINGZONE_DELETE, …).Reproduced on a meshStack 2026.47.0 dev instance. The workaround was two logins, first Safe access, then Full access.
Fix
loginPages.grantedLevelreads the level from the token's scopes:""for Full access and fails for any other level.Changes after review
OidcLogin.GrantedLevelreads the level from the scope of the latest cached token, and falls back to the stored level. A profile that the bug stored as""(Full access) now counts as Safe access. Its next Full access login ends the stuck session before the redirect and succeeds on the first try.How far the revoke reaches (Keycloak source)
DefaultRefreshTokenProvider.revokeToken: revoking a refresh token removes the CLI client from that one offline session, plus the CLI's client session in the matching browser session. The browser session ends only if no other client is left in it. Other offline sessions and consent stay. That matches the doc comment onRevokeRefreshToken.revokeClient: revoking a token also revoked the client's consent and every offline session of the user for the CLI, on every machine.keycloak:26image, so revoking reaches that far only on a 26.0 deployment.Verification
cli-access-writegranted, so the new refresh token gets revoked), and a failed revoke.go test ./internal/...andgo tool golangci-lint runpass.Follow-up
The browser tab shows "You are logged in with Full access" before the token exchange runs. In the mismatch case it contradicts the error in the terminal. Fixing that means doing the exchange in the callback handler, so this PR leaves it out.
🤖 Generated with Claude Code