Repository navigation
RANGER-5767: Do not assign header auth roles to users provisioned on behalf of others - #1371
Merged
Merged
Conversation
…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.
mneethiraj
reviewed
Nov 17, 2026
| * back to the default ROLE_USER. | ||
| */ | ||
| private List<String> getHeaderAuthRoles() { | ||
| private List<String> getHeaderAuthRoles(String username) { |
Contributor
There was a problem hiding this comment.
@kumaab - getHeaderAuthRoles() taking a username as parameter doesn't sound right.
mneethiraj
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
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.