Repository navigation
feat: read the stem of the stacklet:rls_access claim after a stem: prefix (ENG-9104) - #118
Merged
albertodonato merged 1 commit intoNov 16, 2026
Conversation
…efix (ENG-9104) ## What type of PR is this? - [x] Feature ## Description The platform is changing the `stacklet:rls_access` claim so that a scoped user's stem comes after a fixed `stem:` prefix, and a stem alone is no longer valid. This follows [ENG-9107](https://stacklet.atlassian.net/browse/ENG-9107), and keeps a stem from ever being taken for one of the two reserved values whatever shape it has. | `stacklet:rls_access` | Result | |---|---| | absent (token minted before the claim) | fall back to `stacklet:db_role` | | `unrestricted` | `db_role = None`: queries run as the data source user, unfiltered | | `no_visibility` | 401 | | `stem:` then a match for `[a-z0-9_]{1,20}_[0-9a-f]{6}` | `db_role = "sso_" + stem` | | anything else, a stem without the prefix included | 401 | Only the shape accepted for a stem changes: the reserved values, the fallback to `stacklet:db_role` and the role names it produces are as before. This has to be deployed before the platform starts sending the prefixed value, as until then a token carrying `stem:...` is refused. ## How is this tested? - [x] Unit tests `test_jwt_sets_db_role_from_claims` and `test_jwt_denied_claims` use the prefixed form and refuse a bare stem, a stem with nothing or a malformed value after the prefix, and a prefix in another case. I ran the claim function on those cases on its own; the suite itself needs the Docker test stack, which I didn't run. ## Related Tickets & Documents - [ENG-9104](https://stacklet.atlassian.net/browse/ENG-9104) - Epic: [ENG-9107](https://stacklet.atlassian.net/browse/ENG-9107)
albertodonato
marked this pull request as ready for review
November 16, 2026 11:33
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Client as API Client
participant Auth as Auth Service
participant JWT as JWT Validator
participant RLS as RLS Claim Parser
participant DB as Database
Client->>Auth: Request with JWT token
Auth->>JWT: Validate and decode token
JWT->>JWT: Extract claims payload
JWT-->>Auth: Claims (stacklet:rls_access, stacklet:db_role)
Auth->>RLS: _db_role_from_claims(payload)
alt stacklet:rls_access absent
RLS-->>Auth: Fall back to stacklet:db_role
else stacklet:rls_access = "unrestricted"
RLS-->>Auth: Return None (unfiltered access)
else stacklet:rls_access = "no_visibility"
RLS-->>Auth: Raise Unauthorized (401)
else stacklet:rls_access starts with "stem:"
RLS->>RLS: Extract stem after prefix
alt Stem matches [a-z0-9_]{1,20}_[0-9a-f]{6}
RLS-->>Auth: Return "sso_" + stem
else Stem malformed
RLS-->>Auth: Raise Unauthorized (401)
end
else Invalid claim format
RLS-->>Auth: Raise Unauthorized (401)
end
Auth-->>Client: Response (authorized or 401)
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Re-trigger cubic
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.
What type of PR is this?
Description
The platform is changing the
stacklet:rls_accessclaim so that a scoped user's stem comes after a fixedstem:prefix, and a stem alone is no longer valid. This follows ENG-9107, and keeps a stem from ever being taken for one of the two reserved values whatever shape it has.stacklet:rls_accessstacklet:db_roleunrestricteddb_role = None: queries run as the data source user, unfilteredno_visibilitystem:then a match for[a-z0-9_]{1,20}_[0-9a-f]{6}db_role = "sso_" + stemOnly the shape accepted for a stem changes: the reserved values, the fallback to
stacklet:db_roleand the role names it produces are as before. This has to be deployed before the platform starts sending the prefixed value, as until then a token carryingstem:...is refused.How is this tested?
test_jwt_sets_db_role_from_claimsandtest_jwt_denied_claimsuse the prefixed form and refuse a bare stem, a stem with nothing or a malformed value after the prefix, and a prefix in another case. I ran the claim function on those cases on its own; the suite itself needs the Docker test stack, which I didn't run.Related Tickets & Documents