diff --git a/ldapcherry/backend/__init__.py b/ldapcherry/backend/__init__.py index 1957589..5634ede 100644 --- a/ldapcherry/backend/__init__.py +++ b/ldapcherry/backend/__init__.py @@ -11,36 +11,107 @@ from ldapcherry.exceptions import MissingParameter class Backend: def __init__(self, config, logger, name, attrslist, key): + """ Initialize the backend + :param config: the configuration of the backend + :type config: dict {'config key': 'value'} + :param logger: the cherrypy error logger object + :type logger: python logger + :param name: id of the backend + :type name: string + :param attrslist: list of the backend attributes + :type attrslist: list of strings + :param key: the key attribute + :type key: string + """ raise Exception() def auth(self, username, password): + """ Check authentication against the backend + :param username: 'key' attribute of the user + :type username: string + :param password: password of the user + :type password: string + :rtype: boolean (True is authentication success, False otherwise) + """ return False def add_user(self, attrs): + """ Add a user to the backend + :param attrs: attributes of the user + :type attrs: dict ({: }) + """ pass def del_user(self, username): + """ Delete a user from the backend + :param username: 'key' attribute of the user + :type username: string + """ pass def set_attrs(self, username, attrs): + """ Set a list of attributes for a given user + :param username: 'key' attribute of the user + :type username: string + :param attrs: attributes of the user + :type attrs: dict ({: }) + """ pass def add_to_groups(self, username, groups): + """ Add a user to a list of groups + :param username: 'key' attribute of the user + :type username: string + :param groups: list of groups + :type groups: list of strings + """ pass def del_from_groups(self, username, groups): + """ Delete a user from a list of groups + :param username: 'key' attribute of the user + :type username: string + :param groups: list of groups + :type groups: list of strings + """ pass def search(self, searchstring): + """ Search backend for users + :param searchstring: the search string + :type searchstring: string + :rtype: dict of dict ( {: {: }} ) + """ return {} def get_user(self, username): + """ Get a user's attributes + :param username: 'key' attribute of the user + :type username: string + :rtype: dict ( {: } ) + """ return {} def get_groups(self, username): + """ Get a user's groups + :param username: 'key' attribute of the user + :type username: string + :rtype: list of groups + """ return [] def get_param(self, param, default=None): + """ Get a parameter in config (handle default value) + + :param param: name of the parameter to recover + :type param: string + :param default: the default value, raises an exception + if param is not in configuration and default + is None (which is the default value). + :type default: string or None + :rtype: the value of the parameter or the default value if + not set in configuration + """ if param in self.config: return self.config[param] elif default is not None: