AuthKit

 

UsersReadOnly

Like the Users class except that user information is read only. All the information is obtained from the attributes self.usernames, self.passwords, self.roles, self.groups which are expected to be setup in __init__().

usernames should be a list of lowercase usernames passwords, groups should be a dictionary where the keys are lowercase usernames and the values are the corresponding lowercase group name or password. roles is similar to passwords and groups except values are lists of lowercase role names.


Methods

f __init__(self, data, encrypt=None) ...

f group_create(self, group) ...

Add a new group to the system

f group_delete(self, group) ...

Remove the group specified. Rasies an exception if the group is still in use. To delete the group and remove it from all existing users use group_delete_cascade()

f group_delete_cascade(self, group) ...

Remove the group specified and remove the group from any users who used it

f group_exists(self, group) ...

Returns True if the group exists, False otherwise. Groups are case insensitive.

f list_groups(self) ...

Returns a lowercase list of all groups ordered alphabetically

f list_roles(self) ...

Returns a lowercase list of all role names ordered alphabetically

f list_users(self) ...

Returns a lowecase list of all usernames ordered alphabetically

f role_create(self, role) ...

Add a new role to the system

f role_delete(self, role) ...

Remove the role specified. Rasies an exception if the role is still in use. To delete the role and remove it from all existing users use role_delete_cascade()

f role_delete_cascade(self, role) ...

Remove the role specified and remove the role from any users who used it

f role_exists(self, role) ...

Returns True if the role exists, False otherwise. Roles are case insensitive.

f user(self, username) ...

Returns a dictionary in the following format:

1
2
3
4
5
6
{
    'username': username,
    'group':    group,
    'password': password,
    'roles':    [role1,role2,role3... etc]
}

The role names are ordered alphabetically Raises an exception if the user doesn't exist.

f user_add_role(self, username, role, add_if_necessary=False) ...

Sets the user's role to the lowercase of role. If the role doesn't exist and add_if_necessary is True the role will also be added. Otherwise an AuthKitNoSuchRoleError will be raised. Raises an exception if the user doesn't exist.

f user_create(self, username, password, group=None) ...

Create a new user with the username, password and group name specified.

f user_delete(self, username) ...

Remove the user with the specified username

f user_exists(self, username) ...

Returns True if a user exists with the given username, False otherwise. Usernames are case insensitive.

f user_group(self, username) ...

Returns the group associated with the user or None if no group is associated. Raises an exception is the user doesn't exist.

f user_has_group(self, username, group) ...

Returns True if the user has the group specified, False otherwise. Raises an exception if the user doesn't exist.

f user_has_password(self, username, password) ...

Passwords are case sensitive. Returns True if the user has the password specified, False otherwise. Raises an exception if the user doesn't exist.

f user_has_role(self, username, role) ...

Returns True if the user has the role specified, False otherwise. Raises an exception if the user doesn't exist.

f user_password(self, username) ...

Returns the password associated with the user or None if no password exists. Raises an exception is the user doesn't exist.

f user_remove_group(self, username) ...

Sets the group to None for the user specified by username. Raises an exception if the user doesn't exist.

f user_remove_role(self, username, role) ...

Removes the role from the user specified by username. Raises an exception if the user doesn't exist.

f user_roles(self, username) ...

Returns a list of all the role names for the given username ordered alphabetically. Raises an exception if the username doesn't exist.

f user_set_group(self, username, group, add_if_necessary=False) ...

Sets the user's group to the lowercase of group or None. If the group doesn't exist and add_if_necessary is True the group will also be added. Otherwise an AuthKitNoSuchGroupError will be raised. Raises an exception if the user doesn't exist.

f user_set_username(self, username, new_username) ...

Sets the user's username to the lowercase of new_username. Raises an exception if the user doesn't exist or if there is already a user with the username specified by new_username.

See the source for more information.