Skip to content

feat(admission): let gates test token claims against a rule - #2225

Merged
c-thiel merged 1 commit into
mainfrom
ct/admission-token-claims
Nov 4, 2026
Merged

c-thiel merged 1 commit into
mainfrom
ct/admission-token-claims

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

AdmissionContext::token_claims lets a gate test the request's token against a limes::ClaimRule without reading any claim value. The auth middleware sets it on every admission; a context built with AdmissionContext::new alone holds no claims and satisfies no rule.

ClaimRuleConfig::to_rule makes every check a required-claim rule gets, including separator on exists and a whitespace literal on none_of, so a configuration reusing the grammar refuses the same rules.

Summary by CodeRabbit

  • New Features
    • Admission checks can now use a user’s token claims to determine whether a request meets configured requirements. Claim values are not exposed to the checks.
    • Requests without a token do not satisfy claim requirements, including rules that require a claim to be absent.
  • Documentation
    • Updated guidance explains how token claims affect admission checks and notes that claim-check results can vary between tokens for the same user.

`AdmissionContext::token_claims` lets a gate test the request's token against a
`limes::ClaimRule` without reading any claim value. The auth middleware sets it on
every admission; a context built with `AdmissionContext::new` alone holds no claims
and satisfies no rule.

`ClaimRuleConfig::to_rule` makes every check a required-claim rule gets, including
`separator` on `exists` and a whitespace literal on `none_of`, so a configuration
reusing the grammar refuses the same rules.
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Admission contexts can now carry request token claims for ClaimRule checks without exposing claim values. Authentication supplies claims to gates. Missing tokens match no rules. Claim-rule separator validation and related tests are updated.

Changes

Claim-Based Admission

Layer / File(s) Summary
Claim-rule validation
crates/lakekeeper/src/config.rs, crates/lakekeeper/src/service/authn.rs
to_rule validates separators for exists and none_of rules. Tests cover rejected combinations and an accepted all_of separator.
Token claims in admission context
crates/lakekeeper/src/request_metadata.rs, crates/lakekeeper/src/service/admission.rs
AdmissionContext can carry TokenClaims. satisfy checks claims against a rule and returns false when claims are absent. Tests check matching, absent-token behavior, and debug output that omits claim values.
Authentication wiring and gate use
crates/lakekeeper/src/service/authn.rs, docs/docs/admission.md, docs/docs/customize.md
Authentication attaches request claims before admission. A gate test checks matching and non-matching group claims. The documentation describes claim checks and warns against caching results by user.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant RequestMetadata
  participant TokenClaims
  participant AdmissionContext
  participant AdmissionGate
  RequestMetadata->>TokenClaims: from_request(metadata)
  TokenClaims->>AdmissionContext: attach token claims
  AdmissionContext->>AdmissionGate: admit(context)
  AdmissionGate->>TokenClaims: satisfy(ClaimRule)
Loading

Suggested reviewers: raffael-dzikowski, brgr-s

Merge Risk: Minimal · up to 5dbae

Claim-based gates receive the authenticated token’s claims. No material merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "feat(admission): let gates test token claims against a rule" matches the main change. The changeset adds TokenClaims and AdmissionContext::token_claims so admission gates can test a request…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "feat(admission): let gates test token claims against a rule" matches the main change. The changeset adds TokenClaims and AdmissionContext::token_claims so admission gates can test a request's token claims against a limes::ClaimRule without reading claim values. The title is specific, short, and follows conventional-commit style. The rest of the changeset (ClaimRuleConfig::to_rule validation changes, the test helper, and the docs) supports or relates to this main change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 3 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks a claim at dawn,
Then hops along the gate.
The token’s values stay unseen,
While rules decide its fate.
No claim, no match; the rabbit nods,
And bounds away to celebrate.

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1695255-25f9-4dde-b202-633f1031ede7
Commits

Reviewing files that changed from the base of the PR and between b8d435a and 5dbae14.

Files selected for processing: 6
  • crates/lakekeeper/src/config.rs
  • crates/lakekeeper/src/request_metadata.rs
  • crates/lakekeeper/src/service/admission.rs
  • crates/lakekeeper/src/service/authn.rs
  • docs/docs/admission.md
  • docs/docs/customize.md
Files with no reviewable changes: 1
  • crates/lakekeeper/src/config.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel merged commit f6b5e9c into main Nov 4, 2026
76 of 77 checks passed
@c-thiel
c-thiel deleted the ct/admission-token-claims branch November 4, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant