Include user-defined attributes when building PolarisPrincipal from PrincipalEntity#4405
Include user-defined attributes when building PolarisPrincipal from PrincipalEntity#4405iprithv wants to merge 1 commit into
Conversation
|
Thanks for your contribution, @iprithv ! Please start a discussion for this change on the |
dimas-b
left a comment
There was a problem hiding this comment.
Changes LGTM 👍 pending a discussion on dev.
| * <p>The created principal will have the same ID and name as the {@link PrincipalEntity}, and its | ||
| * properties will be derived from the internal properties of the entity. | ||
| * <p>The created principal will have the same name as the {@link PrincipalEntity}, and its | ||
| * properties will be the merger of the entity's user-defined properties and its internal |
There was a problem hiding this comment.
nit: the merger is the actor who merges or the process of merging, but it's not the result, right? 🤔
| PrincipalEntity principalEntity, Set<String> roles, Optional<String> token) { | ||
| return of( | ||
| principalEntity.getName(), principalEntity.getInternalPropertiesAsMap(), roles, token); | ||
| return of(principalEntity.getName(), mergeEntityProperties(principalEntity), roles, token); |
There was a problem hiding this comment.
This change looks fine in isolation. However, from #4291 I guess that the real intent is to ensure the Authenticator implementations forward user-settable principal properties to PolarisPrincipal
Note: Authenticators are pluggable, so whether that happens in all environments is not 100% certain.
This is not a blocker, just a notice for awareness.
| PrincipalEntity principalEntity, Set<String> roles, Optional<String> token) { | ||
| return of( | ||
| principalEntity.getName(), principalEntity.getInternalPropertiesAsMap(), roles, token); | ||
| return of(principalEntity.getName(), mergeEntityProperties(principalEntity), roles, token); |
There was a problem hiding this comment.
heads up: 2026-04-26 dev-list thread on PolarisPrincipal's user attributes, @adutra raised that PolarisPrincipal was intentionally decoupled from PrincipalEntity (PR #2307) and suggested exposing the persisted entity via a SecurityIdentity attribute rather than widening getProperties(). This PR goes the opposite direction.
Description
Fixes #4291
PolarisPrincipal.of(PrincipalEntity, …)forwards only the entity's internal properties (e.g.client_id) and silently drops the user-defined properties supplied at principal creation. As a result, downstream consumers that readPolarisPrincipal.getProperties()never see user attributes likeregion=northamericaordepartment=finance, and policies written against them never match.Affected paths:
DefaultAuthenticator- constructs thePolarisPrincipalduring authentication.AuthenticatingAugmentor- copies the principal's properties intoQuarkusSecurityIdentityattributes.OpaPolarisAuthorizer) and Ranger (RangerUtils.getUserAttributes) consume these as user attributes for ABAC policy evaluation. The existing OPA test suite already builds principals likePolarisPrincipal.of("eve", Map.of("department","finance"), Set.of("auditor")), demonstrating the intended contract that the production path can't honor today.Reproduction confirmed both ways:
On
main(fix reverted):On this branch:
Checklist
CHANGELOG.md(if needed)site/content/in-dev/unreleased(if needed) — N/A, internal behavior fix; no user-facing config or doc surface affected.