kumaab opened a new pull request, #1400:
URL: https://github.com/apache/ranger/pull/1400
## What changes were proposed in this pull request?
- **Role names in the header**
- Accept the external names `authz-role-admin`, `authz-role-auditor`,
`authz-role-user`, `authz-role-key-admin` and `authz-role-key-admin-auditor`.
- Accept scoped names, where the part before the first `:` is ignored (for
example `<namespace>:authz-role-admin`).
- Keep accepting Ranger's internal role names (`ROLE_SYS_ADMIN` and so on).
- Ignore unrecognized values and log a warning.
- **Check the header on every request** `RangerHeaderPreAuthFilter`
re-authenticates a trusted-proxy session when the username or the roles in the
header change. It leaves other authentication types (password, Kerberos, SSO)
alone.
- **Session-scoped role, not persisted**
- `SessionMgr` works out one effective role from the header, with
precedence `ROLE_SYS_ADMIN > ROLE_ADMIN_AUDITOR > ROLE_USER`, and stores it on
`UserSessionBase`.
- KMS roles in the header are ignored, the same as for config super-users.
- When the role changes mid-session, the session's roles and module
permissions are refreshed and the admin flags are reset.
- If the request has no roles header, the user's DB roles are used as
before.
- **Module permissions**. For a session role from the header, the session
gets the union of the user's DB module permissions and that role's default
modules. Key Manager is excluded. XUserMgr.hasAccessToModule checks the
session's modules.
- **The UI reflects the session role, for the session user only**
- The user's own profile (`mapXXPortalUserToVXPortalUser`,
gjUserToUserProfile) shows the session's role and modules.
- User search and user-info access checks (XUserREST.searchXUsers,
hasAccessToGetUserInfo) use the session role of the logged-in user.
- Other users' profiles still show their DB roles.
- **Provisioning**. Auto-provisioned users are always created with
`ROLE_USER`. The header role is never persisted, including for users
provisioned on behalf of someone else, for example a service account calling
the API for another user.
- **Supporting changes**. A new `XXModuleDefDao.findByModuleNames` and the
named query `XXModuleDef.findByModuleNames` look up only the session's modules.
## Compatibility
No change when `ranger.admin.authn.header.enabled=false`, or for password,
Kerberos, SSO and SAML logins. The new logic only applies to trusted-proxy
sessions that carry a role from the header.
## How was this patch tested?
Unit tests in `TestRangerHeaderPreAuthFilter`, `TestSessionMgr` and
`TestUserMgr`.
Tested on a deployment with header-based authentication. The cases were:
- first-login roles;
- several roles collapsing to the highest one;
- KMS roles being ignored;
- promotion and demotion mid-session;
- falling back to DB roles when there's no roles header;
- the role not leaking to other users' profiles;
- the same user in two sessions with different roles.
--
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]