bharos opened a new pull request, #11970:
URL: https://github.com/apache/gravitino/pull/11970

   ### What changes were proposed in this pull request?
   
   First step of role assumption (SET ROLE), introducing the header grammar and 
parser only — no wiring and no behavior change yet.
   
   - Add the `X-Gravitino-Active-Roles` header constant to `AuthConstants`.
   - Add `ActiveRoles`, an immutable value type modeling the declared active 
roles as `ALL` / `NONE` / `NAMED` (ordered, de-duplicated role names).
   - Add `ActiveRoleParser`, which parses a raw header value into `ActiveRoles`:
     - absent / blank value → `ALL` (today's behavior);
     - entries are trimmed and de-duplicated; role names are case-sensitive;
     - `ALL` and `NONE` are reserved keywords (exact upper-case) and must each 
appear alone;
     - a malformed value (empty entry, or a reserved keyword combined with 
anything) raises `IllegalActiveRolesException` (extends 
`IllegalArgumentException`).
   - Unit tests covering the full grammar and malformed inputs.
   
   This is intentionally scoped to the pure model + parser so it can be 
reviewed on its own. Carrying the value on the request, the `400`/`403` 
mapping, and enforcement follow in later PRs.
   
   Part of #11965.
   
   ### Why are the changes needed?
   
   Implements Phase 1 of the approved design 
[design-docs/gravitino-role-assumption.md](https://github.com/apache/gravitino/blob/main/design-docs/gravitino-role-assumption.md)
 (discussion #10894). A caller needs a way to declare which of its roles should 
be active for a request so authorization can be narrowed; this PR establishes 
the header grammar that the rest of the feature builds on.
   
   Addresses part of #11966.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Not yet. It adds the `X-Gravitino-Active-Roles` header name and its grammar 
as internal building blocks, but nothing reads the header or changes 
authorization behavior in this PR.
   
   ### How was this patch tested?
   
   New unit tests in `TestActiveRoleParser` (JUnit 5) cover single role, 
comma-separated lists, whitespace trimming, duplicate collapsing, 
case-sensitivity, `ALL`/`NONE`, absent/blank values, and malformed inputs. 
Verified locally:
   
   - `./gradlew :common:test --tests 
"org.apache.gravitino.auth.TestActiveRoleParser"`
   - `./gradlew :common:spotlessCheck :common:javadoc`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to