Repository navigation
Conversation
LOOM_OIDC_PLATFORM_ADMIN_GROUP names one group. An OIDC sign-in whose verified ID token lists it in its `groups` claim mints platform_admin, whatever LOOM_PLATFORM_ADMINS says. Each refresh verifies the ID token the provider issues with the refreshed token and keeps the role only while it names the same verified email and still lists the group; a missing or unverifiable ID token ends the role. A refresh never promotes. The decision is set from the verified ID token in the callback and stored with the sign-in, so an account link that finishes later keeps it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Sign-in asks for `groups` where discovery lists it, since an org authorization server puts the claim in the ID token only then. A refresh whose ID token cannot be checked because the provider's keys or discovery are unreachable answers 503 with its token put back, instead of dropping the role. Tests cover the scope, the nonce-free refresh verification, the outage, and an account link that finishes the sign-in later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
| if offline and "offline_access" in listed: | ||
| scope += " offline_access" | ||
| if settings.oidc_platform_admin_group and "groups" in listed: | ||
| scope += " groups" |
There was a problem hiding this comment.
Groups scope can block all sign-ins
High Severity
With LOOM_OIDC_PLATFORM_ADMIN_GROUP set, every SSO authorize request adds the groups scope whenever discovery's scopes_supported lists it. That list is for the whole authorization server, not the scopes this client may use. Okta policies and Keycloak realms often advertise groups without granting it to the Loom app, and the provider then rejects the redirect. Password sign-in is already closed in OIDC mode, so nobody can sign in.
Reviewed by Cursor Bugbot for commit bd3afc6. Configure here.
A refresh asks the provider's ID token about the group only when LOOM_PLATFORM_ADMINS did not keep platform_admin, so listed admins never depend on the provider's keys. The docs name every way to the role, the groups scope, each provider's groups claim format and what the previous build does with a group-conferred admin. Tests cover a listed admin, a key outage that answers 503 and keeps the token, a cleared setting, an unverified email and the MCP connect sign-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
A refreshed ID token is checked moments after the provider mints it, so a provider clock a few seconds ahead of Loom's made its iat look future and silently ended a group-conferred platform_admin. ID tokens now get the same LOOM_JWT_LEEWAY_SECONDS tolerance as Loom's own tokens. The docs say an unreachable provider keeps the role through a retried refresh, and that leaving the group does not disable the platform-admin bots a person registered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
PyJWT wraps only some transport errors in PyJWKClientConnectionError, so a connection reset or TLS error while reading the provider's keys ended a group-conferred platform_admin; any OSError now retries the refresh. The clock-skew test takes its times when it runs, not at collection, and pins the leeway at both edges. A test checks that oidc.refresh returns the provider's ID token. The docs say how to create the groups claim in Entra and Keycloak, that Okta's filter matches names from every source, and name every way to platform_admin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
PyJWT fetches the provider's keys again only after a cooldown, so a refreshed ID token signed with a key rotated in moments before raised PyJWKClientError and silently ended a group-conferred platform_admin. Every PyJWKClientError now answers 503 with the token put back, and the retry finds the key. The docs give the refresh interval as the access token lifetime it is, and two paragraphs are rewrapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4b883d8. Configure here.
PyJWT 2.14 waits 30 s before fetching keys again for an unknown key id, so a key the provider rotated in moments before refused a sign-in and stalled a platform admin's refresh. Sign-in's ID tokens come from Loom's own token request, so no caller picks their key id: that key client now refetches at once. A bot trust's client keeps the cooldown. Sign-in and the refresh's group check now retry the same outages (oidc.KEYS_AWAY), and any token that fails a check ends the role. The PyJWT floor moves to 2.14, where the cooldown and its argument appeared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…ounted The callback's verify step now retries every outage in oidc.KEYS_AWAY; the test drives a key-fetch error, a discovery connect error and a reset while reading keys, and checks each answers the start-again page without counting against the person's address. The docstring and log line name discovery too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Keycloak keeps group names unique only among siblings, so a short name matches a subgroup of that name anywhere in the realm, and whoever can create one could make platform admins: set the group to its full path. The listed-admin refresh test now drives the real group check with the provider's keys away and expects the role, instead of stubbing the check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The test's grant had no verified email, so the group check returned before it reached the provider's keys and the test passed whatever the guard did. It now seeds one and runs both ways: a listed admin refreshes while the keys are away, a group-conferred admin is retried with a 503. The pending sign-in key is named in_platform_admin_group, after the bool it holds; the group check's docstring names the outage path; the Users hint no longer says Loom keeps no group membership (SCIM keeps groups). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
PyJWT 2.14 wraps URLError and TimeoutError but not http.client's errors, so on the floor version an incomplete read of the provider's keys ended a group-conferred role instead of retrying; KEYS_AWAY now names http.client.HTTPException. The refresh verifier is one function again, the sign-in leeway has its own test, and sso.md says to pick a group only the provider's administrators can create and fill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
2.15 wraps http.client's errors in PyJWKClientConnectionError, so the outage list no longer names them, and the floor now matches what is tested. The nonce-free verifier is named verify_id_token_without_nonce, which reads right at sign-in and at refresh. The MCP reference says a refresh drops platform_admin only once neither the list nor the group names the subject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
With the provider's group conferring platform_admin, the admins are no longer readable from configuration. auth.device_approved and auth.connect_approved now carry the roles, as auth.sso_signin already did, so the audit log names who signed in as a platform admin and when, and a refresh that ends the role logs the session. The refresh-deadline comment names the deadline it means. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The MCP connect approval row's roles are now asserted, as the device row's are. The refresh's group guard tests its condition once, the deadline comment is two plain sentences, and the Users hint is formatted as the format job expects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
…no role The callback's group decision rides the link ticket for up to ten minutes; it now confers platform_admin only while the setting is still set. The never-promotes guard lives once, in the refresh, with a test at that level, and the outage tuple is named PROVIDER_AWAY, since it covers discovery as well as keys. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The fail-closed helper no longer takes the roles the group check stopped reading, the link-page test is named for its cleared-setting case too, sso.md names a linked password account's handle among the ways to the role, and the groups-claim docstring promises only the list check it makes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The callback now keeps which group matched, not a bool, so a link page finished after the operator changed the setting to another group grants no role, as one finished after clearing it already did. Denied device and connect rows carry no roles, since nothing was minted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The setting's description read as if a refresh could grant the role to someone newly in the group; it says now that only sign-in grants it and a refresh keeps it while the group is listed. The connect denial's audit row is pinned to carry no roles, and the back-channel routing test checks routing only, since the rotation test covers the cooldowns. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
PyJWT wraps a failed fetch but not a body it cannot parse, so a proxy's error page demoted a group-conferred platform admin instead of answering 503. Bot trusts now share the same outage errors, so a reset while reading their keys refuses as unavailable too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
json.load decodes the body before it parses it, so a Latin-1 or compressed proxy page raised UnicodeDecodeError past the outage check. The callback test now reads the roles back from the token the dashboard receives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Also runs the not-JSON key set case against a bot trust's key client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
… org Also names both cases of two parametrized tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
The exception-text ratchet counts a formatted exception outside a log call; the cause is chained already. Also puts the refresh's broad-except reason back on its line, reflows two lines, and proves a cleared group setting never reads the refreshed ID token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>


Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
LOOM_OIDC_PLATFORM_ADMIN_GROUPnames an identity-provider group whose members sign in as platform admins, read from the verified ID token'sgroupsclaim. Each refresh checks the group again in the ID token the provider returns with it, so a person it no longer lists in the group loses the role at their next refresh, within one access-token lifetime (an hour by default).Why
With single sign-on, the only way to make someone a platform admin is to list their email in
LOOM_PLATFORM_ADMINSand redeploy. Deployments that manage access in their identity provider (an approval adds a person to a group) want that group to decide who administers Loom, and to take the role away when the person leaves the group, without a config change.Design:
groupsmintsplatform_admin. Agroupsclaim that is not a list, a prefix match or any other group confers nothing. No other group claim is read; namespace roles still come only from Loom's grants.oidc.refreshnow also returns the ID token the provider issues with it. A platform admin's refresh keeps the role only if that ID token verifies (signature, issuer, audience, expiry; no nonce, which a refreshed ID token need not carry), names the same verified email as the session, and still lists the group. A missing or unverifiable ID token ends the role (fail closed).LOOM_PLATFORM_ADMINSkeeps working beside it, and the group is checked only when that list did not keep the role, so a listed admin's refresh never needs the provider's keys.LOOM_PLATFORM_ADMINS.auth.device_approvedandauth.connect_approvednow carry the minted roles (denials carry none), asauth.sso_signinalready did. A refresh that ends a session's platform_admin writes a server log line naming the session (no audit row).groupsscope where the provider's discovery document lists it: an org authorization server puts the claim in the ID token only for that scope. A custom authorization server defines the claim on the server instead; the docs say both.URLError,TimeoutErrorandhttp.client's errors, soOSErroris named too, and a key set that is not UTF-8 JSON, such as a proxy's error page, is raised as one) answers 503 and puts the refresh token back, as other provider outages do, so a short outage does not drop the role. Any other verification failure drops it, a key id the provider never publishes included.cooldown_duration=0): PyJWT otherwise refetches for an unknown key id at most once per 30 s, so a key rotated in just after a fetch refused a sign-in and ended a group admin's role at refresh. Only ID tokens from Loom's own token request reach that client, so no caller picks the key id; a bot trust's client keeps the cooldown. Sign-in, the refresh's group check and bot-trust key reads share one list of outage errors (oidc.PROVIDER_AWAY). At the OIDC callback, discovery or the keys away while verifying the ID token (a transport error from discovery, or a rawOSError) now revokes the provider's token and shows the start-again page (503) without counting a failed sign-in against the address, where it counted one and answeredoidc_error. Reading a bot trust's keys now refuses astemporarily_unavailableon a connection reset (which escaped as a 500) and on a key set that is not UTF-8 JSON (which refused asinvalid_grant).LOOM_JWT_LEEWAY_SECONDS(30 s), as Loom's own tokens are: a refreshed ID token is checked moments after the provider mints it, and a provider clock slightly ahead made itsiatlook future and silently ended the role.This reverses the documented rule that the provider can never grant admin. The provider is already trusted to say who the person is; with this setting the operator also trusts one named group in it to say who administers Loom. The setting is empty by default, so nothing changes unless an operator names a group.
Alternatives: keep
LOOM_PLATFORM_ADMINSonly (a redeploy per change, and removal is not automatic); map several groups to several roles (no other role is assigned deployment-wide, and namespace roles belong to namespace admins); read groups from SCIM (the SCIM endpoint keeps no groups, and sign-in would then depend on a sync having run).Scope and risk
Touches the OIDC callback, the OAuth refresh,
oidc.refresh, the authorize scope and the hint on the dashboard's Users page (Loom does not record who is in the group, so a group-conferred platform admin carries no badge there). Password sign-in and minted tokens are unchanged; a bot's token exchange changes only in how it answers an unreadable key set (above). A refresh with the setting empty, or of a session that is not a platform admin, does not read the ID token at all. Risk: whoever can add members to the named group can make platform admins, which span every org; the docs say to keep that group to as few people as possible, and to pick one only the provider's administrators can create and fill, since Loom matches the name exactly. Taking someone out of the group does not disable the--platform-adminbots they registered; the docs say to disable those.Checked against a real Okta org authorization server: its discovery document lists
groupsinscopes_supported, so sign-in asks for it. The Keycloak note keeps the full group path, since Keycloak names are unique only among siblings and a short name would match a subgroup anywhere in the realm.Still needs verification on a real provider: whether the ID token a refresh returns reflects the person's current group membership, and whether the provider sends one at all. If it sends none, a group-conferred platform admin drops to member at the first refresh (fail closed), and the role then lasts one access token's lifetime per sign-in.
Compatibility, rollout and rollback
pyjwtfloor moves from 2.10 to 2.15, the version the lock pins and CI runs (cooldown_durationfirst appears in 2.14; 2.15 also wrapshttp.client's errors).oidc.refreshreturns aRefreshedpair (internal).LOOM_OIDC_PLATFORM_ADMIN_GROUPand send the group in the ID token'sgroupsclaim (docs/operations/sso.md, Platform admins).LOOM_PLATFORM_ADMINSonly and drops the role; a sign-in that N-1 sent to the account-link page carries no flag and finishes on N as a member. Both fail closed, and the person signs in again once the upgrade completes.Tests
tests/unit/test_oidc.py: the callback mintsplatform_adminfor an exact group entry and not for another group, a non-listgroupsor a prefix; a flag carried in the sealed cookie is overwritten by the ID token, for both dashboard and MCP connect sign-ins, read back from the token the dashboard receives; thegroupsscope is asked only with the setting on and the scope listed; a refreshed ID token verifies without a nonce and with the provider's clock 10 s ahead, and is refused for another audience, issuer, a clock past the leeway or one expired past it; a key set that is not UTF-8 JSON is an outage for sign-in and bot-trust keys alike.tests/unit/test_oidc_backchannel.py:oidc.refreshreturns the provider's ID token.tests/unit/test_oauth.py: a platform admin's refresh keeps the role while the refreshed ID token lists the group and drops it otherwise;_still_in_admin_groupanswers no for a missing token, a verification failure, another email and an empty session email; through/oauth/token, a member the group lists who was not platform admin refreshes without the role; a JWKS or discovery outage is re-raised so the refresh is retried; a cleared setting ends the role without reading the ID token, and an unverified email ends it; with a verified email seeded, a listed admin refreshes while the provider's keys are away and a group-conferred admin's refresh reaches them and is retried; through/oauth/token, a key outage answers 503, the same refresh token works again and the rotated IdP token is kept.tests/unit/test_oidc_hardening.py: discovery or the keys away at the callback (PyJWKClientConnectionError,httpx.ConnectError,ConnectionResetError) shows the start-again page without counting a failed sign-in.tests/unit/test_device_login.py: a sign-in that finishes on the account-link page, by proving the password or declining the account, keeps the group'splatform_admin; a group admin's device and MCP connect approval rows name the role.pytest tests/unit/test_oidc.py tests/unit/test_oauth.py tests/unit/test_oidc_backchannel.py tests/unit/test_scim_sessions.py tests/unit/test_oidc_hardening.py tests/unit/test_device_login.py tests/unit/test_signup_privilege.py tests/unit/test_agent_claim.py tests/unit/test_doc_links.py tests/unit/test_public_copy.py tests/unit/test_settings_defaults.py tests/unit/test_settings_reference.py tests/unit/test_machines.py tests/unit/test_sdk_machine.py tests/unit/test_call_site_knobs.py tests/unit/test_oidc_signing_algorithms.py tests/unit/test_exception_text_ratchet.py(956 passed),ruff,mypyon the touched modules, the function-length gate, the Users page test,npm run build, the bundle budget andmake format-check.AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Claude Code. The design, the fail-closed paths and the tests were checked against the callback and refresh code.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.docs/reference/configuration.md,loom.example.yaml,schemas/loom-settings.schema.jsonand the settings defaults snapshot.docs/describe the system as it now is, and this description names any operator steps and wire changes.🤖 Generated with Claude Code