Area: API
Sub-Area: User Management
Applies to: OSS + Cloud
Issue
You or another admin changed your own DataHub role, for example from Admin to Reader, while testing user management. You can no longer manage roles, and you want your original role back.
You Might Be Asking
- How do I restore admin access after downgrading my role?
- Can I change my own role back?
- Can an old personal access token restore my admin rights?
- Can
datahub user upsertset a role? - How do I test role changes safely?
Cause
Only an Admin, or a user with the Manage Policies privilege, can view roles or change a user's role. If you lower your own role and hold neither, you lose that ability. If you try anyway, you get this error: "Unauthorized to assign roles. Please contact your DataHub administrator if this needs corrective action."
Two things do not work as recovery:
- A personal access token (PAT) carries its user's current privileges. A token created before the downgrade does not restore admin rights.
-
datahub user upserttakes only-f/--fileand--override-editable. The user YAML has no role field, so upsert cannot change a role.datahub user add --roleonly creates new users. It fails with "User with IDalready exists" for an existing user.
Solution
1. Ask another Admin, or a user with Manage Policies, to reassign the role. They can use either UI path:
- Go to Settings > Users & Groups > Users and pick the role from the drop-down on your row.
- Go to Settings > Permissions > Roles and click Add Users next to the role.
See Roles.
2. Or they can use GraphQL. The mutation is batchAssignRole(input: BatchAssignRoleInput!): Boolean. The input has roleUrn and actors. If roleUrn is undefined, the mutation removes the role. For example:
mutation {
batchAssignRole(input: {
roleUrn: "urn:li:dataHubRole:Editor",
actors: ["urn:li:corpuser:your_username"]
})
}
The caller must be an Admin or hold Manage Policies. Use the same call to assign any role. Choose the role in the UI if you are unsure of its urn.
3. Check other routes to the privilege. Permissions are additive. If you belong to a group that has a role, you inherit that role. If a policy grants you Manage Policies, you can still assign roles. See Roles and Policies.
4. If no Admin or Manage Policies holder is left in your organization:
- DataHub Cloud: Contact DataHub Support. DataHub Support can sign in to your instance as an admin. Support then gives the Admin role back to a user that you name.
- Self-hosted DataHub: Use the built-in
datahubroot user to recover access. Follow these steps:- If you removed the root user from
user.props, or setAUTH_JAAS_ENABLED=false, add the user back and turn password login on again. - Sign in as the
datahubroot user at the/loginpage of your DataHub URL. - Assign the role with step 1 or step 2.
- If you removed the root user from
A policy that you cannot edit gives the root user all platform privileges, including Manage Policies. DataHub applies this policy again at each deploy. The password of the root user comes from the user.props file. Deleting the "Data Hub" user in the UI does not disable this login. The root user has all platform privileges, so use it only to recover access. See Changing the default user credentials and Policies.
Preventing accidental role changes
- Do not use your own account to test role changes. Create a separate test user and change that user's role.
- To create a native test user with a role, run
datahub user add --id <id> --email <email> --display-name <name> --password --role Reader. The--rolevalue is Admin, Editor or Reader.--passwordprompts for hidden input. - To change the role of an existing user, use the UI or
batchAssignRole, not the CLI. - Keep at least two users who can assign roles.
- Self-hosted: Keep the credentials of the
datahubroot user in a safe place, and change the default password. This account is your recovery path if no admin is left.