James Gardner: Home > Work > Code > UserManager > 0.5.0 > API Documentation

UserManager v0.5.0 documentation

API Documentation

class usermanager.service.BaseUserService(module, connection_name='database', encrypt=None)
static config(flow, name)
class usermanager.service.PostgresqlUserService(module, connection_name='database', encrypt=None)
static create(flow, name, config=None)
class usermanager.service.ProxyingAttributeDict(flow, module, oself, *k, **p)
class usermanager.service.SQLiteUserService(module, connection_name='database', encrypt=None)
class usermanager.service.UserService(module, connection_name='database', encrypt=None)
start(flow, key)

Contains the core objects used by the other drivers.

Tips for implementers:

  • By having a connection_name attribute on the service you should be able to use the same service object with different types of drivers. For example an LDAP driver might use a the connection service service.ldap so by specifying ldap as the connection name when instantiating the service, you can access the LDAP connection as service[service[name].connection_name] and thus use the un-modified service.
  • Could do with read connections as well as write connections?

ToDo

  • Change the connect and release functions to use the service instead of self
exception usermanager.driver.base.NoSuchGroupError
exception usermanager.driver.base.NoSuchRoleError
exception usermanager.driver.base.NoSuchUserError
exception usermanager.driver.base.NotSupportedError
exception usermanager.driver.base.UserManagerError
usermanager.driver.base.md5(password, secret='')

Need a UserService which maps these functions and also has the encrypt function and a connection_name attribute which represents the key under which the connection is made.

usermanager.driver.postgresql.create_tables(service, drop_first=False, name='user')
usermanager.driver.postgresql.group_create(service, group, name='user')
Add a new group to the system
usermanager.driver.postgresql.group_delete(service, group, name='user')
Remove the group specified. Rasies an exception if the group is still in use. To delete the group and remove it from all existing authkit_user use group_delete_cascade()
usermanager.driver.postgresql.group_exists(service, group, name='user')
Returns True if the group exists, False otherwise. Groups are case insensitive.
usermanager.driver.postgresql.list_groups(service, name='user')
Returns a lowercase list of all authkit_group ordered alphabetically
usermanager.driver.postgresql.list_roles(service, name='user')
Returns a lowercase list of all roll names ordered alphabetically
usermanager.driver.postgresql.list_users(service, name='user')
Returns a lowecase list of all usernames ordered alphabetically
usermanager.driver.postgresql.role_create(service, role, name='user')
Add a new role to the system
usermanager.driver.postgresql.role_delete(service, role, name='user')
Remove the role specified. Rasies an exception if the role is still in use. To delete the role and remove it from all existing authkit_user use role_delete_cascade()
usermanager.driver.postgresql.role_exists(service, role, name='user')
Returns True if the role exists, False otherwise. Roles are case insensitive.
usermanager.driver.postgresql.user(service, username, name='user')

Returns a dictionary in the following format:

{
    'username': username,
    'group':    group,
    'password': password,
    'authkit_role':    [role1,role2,role3... etc]
}

Role names are ordered alphabetically Raises an exception if the user doesn’t exist.

usermanager.driver.postgresql.user_add_role(service, username, role, auto_add_role=False, name='user')
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 NoSuchRoleError will be raised. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_create(service, username, password, group=None, name='user', encrypt=<function _nothing at 0x27c7410>)
Create a new user with the username, password and group name specified.
usermanager.driver.postgresql.user_delete(service, username, name='user')
Remove the user with the specified username
usermanager.driver.postgresql.user_exists(service, username, name='user')
Returns True if a user exists with the given username, False otherwise. Usernames are case insensitive.
usermanager.driver.postgresql.user_group(service, username, name='user')
Returns the group associated with the user or None if no group is associated. Raises an exception is the user doesn’t exist.
usermanager.driver.postgresql.user_has_group(service, username, group, name='user')
Returns True if the user has the group specified, False otherwise. The value for group can be None to test that the user doesn’t belong to a group. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_has_password(service, username, password, name='user', encrypt=<function _nothing at 0x27c7410>)
Returns True if the user has the password specified, False otherwise. Passwords are case sensitive. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_has_role(service, username, role, name='user')
Returns True if the user has the role specified, False otherwise. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_password(service, username, name='user')
Returns the password associated with the user or None if no password exists. Raises an exception is the user doesn’t exist.
usermanager.driver.postgresql.user_remove_group(service, username, name='user')
Sets the group to None for the user specified by username. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_remove_role(service, username, role, name='user')
Removes the role from the user specified by username. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_roles(service, username, name='user')
Returns a list of all the role names for the given username ordered alphabetically. Raises an exception if the username doesn’t exist.
usermanager.driver.postgresql.user_set_group(service, username, group, auto_add_group=False, name='user')
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 a NoSuchGroupError will be raised. Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_set_password(service, username, new_password, encrypt=<function _nothing at 0x27c7410>, name='user')
Sets the user’s password. Should be plain text, will be encrypted using encrypt(). Raises an exception if the user doesn’t exist.
usermanager.driver.postgresql.user_set_username(service, username, new_username, name='user')
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.
James Gardner: Home > Work > Code > UserManager > 0.5.0 > API Documentation