Repository navigation
A sign-in token mints a namespace's admin token for the person who administers it - #187
Merged
Merged
Conversation
…ministers it Every sign-in token carries the flat role writer, a platform role, and delegation capped a child at it, so no one but a platform admin could mint an admin token, even for a namespace they hold admin on. The gate admits a primary token on the subject's grant alone, so on a named, unrestricted namespace the child now takes that grant. A token minted from another token keeps its own claim as the cap, and a restricted namespace keeps the role from both. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…rent's role A flat child's one role also answers ops that name no namespace, where the gate reads the flat role alone, so it stays inside the parent's. Tests for the flat child, a viewer primary parent and an unreadable classification. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…goes A delegated or per-namespace parent keeps its own role as the cap for a scoped child too, which the tests now exercise. A primary flat token with no role is a state no mint produces, and the gate admits such a token on its grant alone, so the guard for it goes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
…mment sits on its branch Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Lareb Zafar <[email protected]>
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.
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):
A person who holds admin on a standard namespace can now mint a per-namespace admin token for it from the dashboard or
service_accounts.create; a restricted namespace still caps the token at the sign-in role. Before, every such mint was refused withcannot delegate admin, because a sign-in token's flatwriterrole capped it.Why
Every sign-in token carries
roles: ["writer"]unless the person is a platform admin (server/auth/login.py,platform_roles). That is a platform role, not the person's role on any namespace: the gate (authz.check_authorized) admits a primary token to a namespace on the subject's grant alone, so the same session acts as admin wherever its grant says admin.Delegation applied a different measure.
_allowed_rolestook the parent token's flat role as a ceiling and lowered the grant to it, so a child could never exceedwriterfrom a sign-in token. The dashboard's token form offers the roles up to the person's grant and defaults to it, so for any namespace the person owns it asked for admin and the server answered 403. No one but a platform admin or the operator'sloom mint-tokencould produce an admin token.The fix makes delegation measure a primary token the way the gate does, for a per-namespace child: on a named, unrestricted namespace the child takes the subject's live grant. A flat child keeps the parent's role, because its one
rolesclaim also answers ops that name no namespace, where the gate reads the flat role alone and a higher claim would admit an org-wide admin op the parent cannot run. A token minted from another token still stays inside that token's own claim,*keeps its cap, and a restricted namespace keeps the role from both token and grant, as_check_restrictedrequires.Scope and risk
Touches one branch of
server/auth/delegation.py::_allowed_rolesand adds_primary. The request-time recheck is unchanged: a delegated token is still cut to its creator's live grant on every call, so a revoked or lowered grant ends the child's admin at once.What widens: a primary token (sign-in, or
loom mint-tokenwith no creator) can now mint a per-namespace child at the subject's grant on a named namespace even when its flat role is lower. That is exactly what the parent can already do itself on that namespace. Off the namespace, a scoped token is gated on its best per-namespace role only for deployment-scoped ops, all of which require viewer, and for row-scoped ops, wherememory.redactandblacklist.removerequire admin: such a child passes that first gate where its sign-in parent is refused outright, and the handler'srow_in_scopethen bounds it to the creator's live grant on the row's namespace, so it still acts only where the person holds admin. Not widened: flat children,*requests, scoped or delegated parents, restricted namespaces, and a namespace without a grant (still refused).Compatibility, rollout and rollback
service_accounts.createand the Setup page accept an admin role where they refused it.Tests
tests/unit/test_delegation.py:test_a_sign_in_token_delegates_the_persons_grant_not_its_flat_role: a sign-in token with an admin grant mints a per-namespace admin child (named and bare); a delegated-list parent, a scoped parent and a restricted namespace are still refused. Fails onmainat the mint, passes with the change.test_a_flat_child_keeps_the_sign_in_tokens_role: a flat child stayswriterand is refused ADMIN on a namespace-less op.test_a_viewer_flat_parent_delegates_its_subjects_grant_per_namespace: a viewer primary token whose subject holds admin mints a per-namespace admin child; its flat child stays viewer.test_an_unreadable_classification_keeps_the_token_role_cap: with the directory unreadable the mint keeps the old cap (fails closed).Ran:
ruff format --check,ruff check,mypy server/auth/delegation.py,scripts/gates/function_length_gate.py(baseline unchanged),tests/unit/test_delegation.py,tests/unit/test_me_setup_scoped_token.py,test_public_copy.pyandtest_doc_links.py(281 passed),tests/unit -k "deleg or grant or token or authz or service_account or setup"(2103 passed).The refusal was observed on a running deployment from the dashboard's token form: the namespace owner, signed in, chose Admin for their own namespace and got
403 AUTH_INSUFFICIENT cannot delegate admin on <namespace>. The sign-in token's flatwriterrole is the only cap that path meets, since the owner's grant there is admin. A delegated writer token asking for an admin child on the same namespace gets the same refusal, and keeps getting it after this change.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. Checked: the gate's primary-token path in
authz.check_authorizedand_check_restricted, everyceiling_rolecaller, and the existing delegation matrix.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no merged migration is edited. (none)frontend/changed. (unchanged)docs/describe the system as it now is, and this description names any operator steps and wire changes.git commit -s), as CONTRIBUTING.md asks.🤖 Generated with Claude Code