Skip to content

RANGER-5767: Do not assign header auth roles to users provisioned on behalf of others - #1371

Merged
kumaab merged 5 commits into
apache:masterfrom
kumaab:ranger_5767
Nov 18, 2026
Merged

kumaab merged 5 commits into
apache:masterfrom
kumaab:ranger_5767

Conversation

@kumaab

@kumaab kumaab commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

When header-based authentication is enabled, auto-provisioned external
users were assigned the roles from the current request's trusted-proxy
token. Creating a service with default policies that reference
not-yet-existing users therefore granted those users the creating
user's roles (e.g. ROLE_SYS_ADMIN).

getHeaderAuthRoles() now takes the username being provisioned and only
returns header roles when it matches the authenticated principal.
Other users fall back to ROLE_USER and are created without the
elevated system session.

How was this patch tested?

brought up Ranger Admin in Docker on Postgres with header-based authentication enabled (X-Forwarded-User).

Using only the header, an admin (ROLE_SYS_ADMIN) created two HDFS services whose default policies referenced seven users that didn't exist yet. They were referenced through the username config, default.policy.users, and a custom default-policy.N.policyItem.M.users entry.

All seven users were auto-created with only ROLE_USER, and none inherited the admin's role. One of them was refused (403) when it tried to create a service.

The fix also holds with the roles header enabled. When an admin whose role came from X-Forwarded-Roles: RANGER_ROLE_ADMIN creates a service, every user it references in default policies is created as ROLE_USER. Header roles are still applied when a caller provisions itself.

…behalf of others

    When header-based authentication is enabled, auto-provisioned external
    users were assigned the roles from the current request's trusted-proxy
    token. Creating a service with default policies that reference
    not-yet-existing users therefore granted those users the creating
    user's roles (e.g. ROLE_SYS_ADMIN).

    getHeaderAuthRoles() now takes the username being provisioned and only
    returns header roles when it matches the authenticated principal.
    Other users fall back to ROLE_USER and are created without the
    elevated system session.
@kumaab kumaab self-assigned this Nov 17, 2026
@kumaab
kumaab requested a review from mneethiraj November 17, 2026 17:29
* back to the default ROLE_USER.
*/
private List<String> getHeaderAuthRoles() {
private List<String> getHeaderAuthRoles(String username) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kumaab - getHeaderAuthRoles() taking a username as parameter doesn't sound right.

@kumaab
kumaab merged commit 457512d into apache:master Nov 18, 2026
4 checks passed
@kumaab
kumaab deleted the ranger_5767 branch November 18, 2026 00:57
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.

3 participants