Repository navigation
Description
Part of #6909. Depends on #6910 for tokens issued by ToolHive's own authorization
server. Tokens from an external AS that already sets the claim can use this
without #6910.
Problem: ToolHive's proxies and vMCP are the resource server, and Cedar is
where they decide. Today every claim of the validated token is copied into
Cedar with a claim_ prefix (preprocessClaims in
pkg/authz/authorizers/cedar/core.go). Arrays become Cedar sets and objects
become records (convertToCedarValueAtDepth in entity.go). So
authorization_details would arrive as a set of records. Cedar has no way to
ask "is there an entry with type X whose actions include Y": set operations
(contains, containsAll, containsAny) only compare whole values. The raw
claim is close to useless for policy.
There is a second gap. When a primary upstream provider is configured
(embedded AS mode), resolveClaims gives Cedar the upstream IdP token's claims,
not the claims of the token ToolHive issued. Details granted by ToolHive's AS
would not be seen there at all.
Change:
- Project
authorization_detailsinto a shape Cedar can test. Proposal: a
context.authorization_detailsrecord keyed bytype, each holding sets
built from the RFC 9396 §2.2 common fields (actions,locations,
datatypes,privileges, andidentifieras a set). Projection is enabled
per type in the Cedar config. - For types whose fields do not fit that shape, allow an optional Go hook that
projects the entries into a record for the current request (tool name,
arguments, resource). - In embedded AS mode, read
authorization_detailsfrom the ToolHive-issued
token even when other claims come from the upstream token. - Keep the existing
claim_authorization_detailsattribute as it is, for
backward compatibility.
Acceptance:
- A policy like
context.authorization_details.repo_access.actions.contains("write")permits
a token with that entry and denies one without it. - The same policy works on a vMCP and on a single-server proxy, and in
embedded AS mode. - An entry of a type that is not configured for projection is not visible
through the projected record. docs/authz.mddescribes the attribute and its limits.
Open questions:
- RFC 9396 §2.2 says the permissions in one object are the product of its
values, and separate objects give finer control. Merging several entries of
the same type into one set per field loses that. Is that acceptable for the
common-field projection, or should it keep one record per entry and leave
matching to the Go hook? - Should this live in the Cedar authorizer only, or in a shared step so that
other authorizers get the same view?
Activity