The User Admin application lets a superuser add, delete, and manage Hue users and groups, and configure group permissions. Superusers can add users and groups individually, or import them from an LDAP directory. Group permissions define the Hue applications visible to group members when they log into Hue and the application features available to them.
To open the User Admin application, click your username in the top right navigation bar, then click Manage Users.
Read how to use LDAP or PAM pass-through authentication with Hive or Impala and impersonation.
To restrict which LDAP groups can log in, see Limit who can log in.
The User Admin application provides two levels of user privileges: superusers and users.
Superusers — The first user who logs into Hue after its initial installation becomes the first superuser. Superusers have permissions to perform administrative functions:
Users can change their name, e-mail address, and password and log in to Hue and run Hue applications, subject to the permissions provided by the Hue groups to which they belong.
Note:
Importing users from an LDAP directory does not import any password information. You must add passwords manually in order for a user to log in.
To add a user from an external LDAP directory:
Click Add/sync user.
If the user already exists in the User Admin, the user information in User Admin is synced with what is currently in the LDAP directory.
You can sync the Hue user database with the current state of the LDAP directory using the Sync LDAP users/groups function. This updates the user and group information for the already imported users and groups. It does not import any new users or groups.
With a command
Go to the Hue installation directory and run:
build/env/bin/hue changepassword [username]
When you omit the username, the command uses the currently logged in Unix user.
With the Hue shell
If a Hue administrator loses their password, use the Hue shell command. It is a wrapper around the Python interpreter that loads the libraries required to work with Hue. From the Hue installation directory, run:
build/env/bin/hue shell
The following script changes the password of a user named example. Run it in the Hue shell:
from django.contrib.auth.models import User
user = User.objects.get(username='example')
user.set_password('some password')
user.save()
You can also run a script file (here script.py) with input redirection:
build/env/bin/hue shell < script.py
With the Hue shell
To make a user a Hue admin, start the shell:
build/env/bin/hue shell
Then set these properties:
from django.contrib.auth.models import User
a = User.objects.get(username='hdfs')
a.is_staff = True
a.is_superuser = True
a.set_password('my_secret')
a.save()
With a command
If you do not remember the admin username, create a new Hue admin. You can then log in and change the password of another user in Hue:
build/env/bin/hue createsuperuser
Note: This works with the
AllowFirstUserDjangoBackendauthentication backend. It can differ with another backend.
Superusers can add and delete groups, configure group permissions, and assign users to group memberships.
You can add groups, and delete the groups you've added. You can also import groups from an LDAP directory.
To allow only the users of some LDAP groups to log in, set login_groups in the hue.ini:
[desktop]
[[ldap]]
login_groups=ldap_grp1,ldap_grp2,ldap_grp3
Permissions for Hue applications are granted to groups, with users gaining permissions based on their group membership. Group permissions define the Hue applications visible to group members when they log into Hue and the application features available to them.
A company would like to use the following LDAP users and groups in Hue:
Assuming the following access requirements:
To implement these requirements, import the users from LDAP by clicking Add/Sync LDAP user in Users.
Similarly, import the groups from LDAP by clicking Add/Sync LDAP group in Groups.
If the information of a previously imported user changed in LDAP, resynchronize it with the LDAP sync feature.
For team A, explicitly allow access to Beeswax in the Groups tab of the User Admin application.
Click the name of the team A group to edit its permissions. Select the beeswax.access permission and unselect the others.
For team B, follow the same steps. Unselect every permission except oozie.dashboard_jobs_access.
With explicit application-level permissions, the users see different applications. For example, Helen, who belongs to team B, only sees the Oozie dashboard.
To set the permissions of a group with a Bash script:
#!/usr/bin/env bash
set -eu
host="localhost"
port="8888"
credentials="/home/hadoop/hue-config/hue_access_admin.txt" # password file
user="admin"
protocol="http"
group_name="spark02-user"
permissions_id1="10" # jobbrowser.access
permissions_id2="18" # spark.access
list_of_users="members=10&members=9&members=4" # number here is an order number for a user in the list of users
password=$(sed -n 's/admin:\(.*\)/\1/p' "${credentials}")
curl ${protocol}://${host}:${port}/hue/accounts/login/?fromModal=true -o /dev/null -D - -c cookies.txt -s
x_csrftoken=$(grep csrftoken cookies.txt | cut -f 7)
curl -i -X POST ${protocol}://${host}:${port}/hue/accounts/login/?fromModal=true -d "username=${user}&password=${password}" -o /dev/null -D - -c cookies.txt -b cookies.txt -H "X-CSRFToken: ${x_csrftoken}" -s
x_csrftoken=$(grep csrftoken cookies.txt | cut -f 7)
curl -X POST ${protocol}://${host}:${port}/useradmin/groups/edit/${group_name} \
-d "csrfmiddlewaretoken=${x_csrftoken}&name=${group_name}&permissions=${permissions_id1}&permissions=${permissions_id2}&${list_of_users}&is_embeddable=true" \
-b cookies.txt -H "X-CSRFToken: ${x_csrftoken}"