You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "iprithv (via GitHub)" <gi...@apache.org> on 2026/05/11 21:08:30 UTC

[PR] Include user-defined attributes when building PolarisPrincipal from Pโ€ฆ [polaris]

iprithv opened a new pull request, #4405:
URL: https://github.com/apache/polaris/pull/4405

   ## 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 read `PolarisPrincipal.getProperties()` never see user attributes like `region=northamerica` or `department=finance`, and policies written against them never match.
   
   Affected paths:
   - `DefaultAuthenticator` - constructs the `PolarisPrincipal` during authentication.
   - `AuthenticatingAugmentor` - copies the principal's properties into `QuarkusSecurityIdentity` attributes.
   - External authorizers - **OPA** (`OpaPolarisAuthorizer`) and **Ranger** (`RangerUtils.getUserAttributes`) consume these as user attributes for ABAC policy evaluation. The existing OPA test suite already builds principals like `PolarisPrincipal.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):
   ```
   PolarisPrincipalTest > ofPrincipalEntityExposesUserDefinedProperties()                          FAILED
   PolarisPrincipalTest > ofPrincipalEntityWithTokenExposesUserDefinedProperties()                 FAILED
   DefaultAuthenticatorTest > testUserDefinedPropertiesArePreservedOnAuthenticatedPrincipal()      FAILED
   ```
   
   On this branch:
   ```
   ./gradlew :polaris-core:check                                                BUILD SUCCESSFUL
   ./gradlew :polaris-runtime-service:test --tests "...service.auth.*"          BUILD SUCCESSFUL
   ./gradlew :polaris-runtime-service:spotlessCheck :checkstyleMain :checkstyleTest   BUILD SUCCESSFUL
   ```
   
   ## Checklist
   - [x] ๐Ÿ›ก๏ธ Don't disclose security issues! (contact security@apache.org)
   - [x] ๐Ÿ”— Clearly explained why the changes are needed, or linked related issues: Fixes #4291
   - [x] ๐Ÿงช Added/updated tests with good coverage, or manually tested (and explained how)
   - [x] ๐Ÿ’ก Added comments for complex logic
   - [x] ๐Ÿงพ Updated `CHANGELOG.md` (if needed)
   - [ ] ๐Ÿ“š Updated documentation in `site/content/in-dev/unreleased` (if needed) โ€” N/A, internal behavior fix; no user-facing config or doc surface affected.
   


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "iprithv (via GitHub)" <gi...@apache.org>.
iprithv commented on PR #4405:
URL: https://github.com/apache/polaris/pull/4405#issuecomment-4939765393

   Reopening with revised approach based on dev@ feedback: DefaultAuthenticator forwards user-defined properties into PolarisPrincipal (Dmitri's auth-layer direction), keeping PolarisPrincipal decoupled from PrincipalEntity.


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #4405: Include user-defined attributes when building PolarisPrincipal from PrincipalEntity
URL: https://github.com/apache/polaris/pull/4405


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #4405:
URL: https://github.com/apache/polaris/pull/4405#issuecomment-4686737601

   This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on PR #4405:
URL: https://github.com/apache/polaris/pull/4405#issuecomment-4426619271

   Thanks for your contribution, @iprithv !
   
   Please start a discussion for this change on the `dev` ML. Since it affect authentiction and authorization, a wide community review and consensus is advisable.


-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "dimas-b (via GitHub)" <gi...@apache.org>.
dimas-b commented on code in PR #4405:
URL: https://github.com/apache/polaris/pull/4405#discussion_r3227326129


##########
polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisPrincipal.java:
##########
@@ -34,35 +35,45 @@ public interface PolarisPrincipal extends Principal {
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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
+   * properties. If a key appears in both maps, the internal-property value wins, so that
+   * system-managed values (for example the {@code client_id}) cannot be shadowed by user input.
    *
    * @param principalEntity the principal entity representing the user or service
    * @param roles the set of roles associated with the principal
    */
   static PolarisPrincipal of(PrincipalEntity principalEntity, Set<String> roles) {
-    return of(
-        principalEntity.getName(),
-        principalEntity.getInternalPropertiesAsMap(),
-        roles,
-        Optional.empty());
+    return of(principalEntity, roles, Optional.empty());
   }
 
   /**
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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

Review Comment:
   nit: `the merger` is the actor who merges or the process of merging, but it's not the result, right? ๐Ÿค” 



##########
polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisPrincipal.java:
##########
@@ -34,35 +35,45 @@ public interface PolarisPrincipal extends Principal {
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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
+   * properties. If a key appears in both maps, the internal-property value wins, so that
+   * system-managed values (for example the {@code client_id}) cannot be shadowed by user input.
    *
    * @param principalEntity the principal entity representing the user or service
    * @param roles the set of roles associated with the principal
    */
   static PolarisPrincipal of(PrincipalEntity principalEntity, Set<String> roles) {
-    return of(
-        principalEntity.getName(),
-        principalEntity.getInternalPropertiesAsMap(),
-        roles,
-        Optional.empty());
+    return of(principalEntity, roles, Optional.empty());
   }
 
   /**
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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
+   * properties. If a key appears in both maps, the internal-property value wins, so that
+   * system-managed values (for example the {@code client_id}) cannot be shadowed by user input.
    *
    * @param principalEntity the principal entity representing the user or service
    * @param roles the set of roles associated with the principal
    * @param token the access token of the current user
    */
   static PolarisPrincipal of(
       PrincipalEntity principalEntity, Set<String> roles, Optional<String> token) {
-    return of(
-        principalEntity.getName(), principalEntity.getInternalPropertiesAsMap(), roles, token);
+    return of(principalEntity.getName(), mergeEntityProperties(principalEntity), roles, token);

Review 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.



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Include user-defined attributes when building PolarisPrincipal from PrincipalEntity [polaris]

Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #4405:
URL: https://github.com/apache/polaris/pull/4405#discussion_r3228967349


##########
polaris-core/src/main/java/org/apache/polaris/core/auth/PolarisPrincipal.java:
##########
@@ -34,35 +35,45 @@ public interface PolarisPrincipal extends Principal {
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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
+   * properties. If a key appears in both maps, the internal-property value wins, so that
+   * system-managed values (for example the {@code client_id}) cannot be shadowed by user input.
    *
    * @param principalEntity the principal entity representing the user or service
    * @param roles the set of roles associated with the principal
    */
   static PolarisPrincipal of(PrincipalEntity principalEntity, Set<String> roles) {
-    return of(
-        principalEntity.getName(),
-        principalEntity.getInternalPropertiesAsMap(),
-        roles,
-        Optional.empty());
+    return of(principalEntity, roles, Optional.empty());
   }
 
   /**
    * Creates a new instance of {@link PolarisPrincipal} from the given {@link PrincipalEntity} and
    * roles.
    *
-   * <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
+   * properties. If a key appears in both maps, the internal-property value wins, so that
+   * system-managed values (for example the {@code client_id}) cannot be shadowed by user input.
    *
    * @param principalEntity the principal entity representing the user or service
    * @param roles the set of roles associated with the principal
    * @param token the access token of the current user
    */
   static PolarisPrincipal of(
       PrincipalEntity principalEntity, Set<String> roles, Optional<String> token) {
-    return of(
-        principalEntity.getName(), principalEntity.getInternalPropertiesAsMap(), roles, token);
+    return of(principalEntity.getName(), mergeEntityProperties(principalEntity), roles, token);

Review 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. 



-- 
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: issues-unsubscribe@polaris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org