Authentication backend¶
Backend object¶
To implement your own authentication backend, you must inherit from AuthBackend object.
Put your authentication backend module in /opt/janua/custom/auth directory
Example with local backend:
class Local(AuthBackend):
def authenticate_admin(self, admin, password):
if not check_password(admin.password, password):
raise AuthError('Bad password for %s' % admin.login)
-
class
janua.auth.backend.AuthBackend(db)[source]¶ Authentication backend object and implement
authenticate_admin()method-
config= []¶ List of configuration parameters, each parameters specify:
- description: a short description
- name: key name to identify it in
Configtable - type: type of parameter, possible types: string, boolean, interger
- value: parameter’s value
Warning
Don’t put spaces in name as it will be converted to class attributes when backend object is instanciated
Example:
config = [ { 'description': 'Uri', 'name': 'ldap_uri', 'type': 'string', 'value': 'ldap://127.0.0.1:389' }, { 'description': 'Bind DN', 'name': 'ldap_bind_dn', 'type': 'string', 'value': 'uid=${login},ou=people,dc=organization,dc=com' }, { 'description': 'TLS support', 'name': 'ldap_tls_support', 'type': 'boolean', 'value': False } ]
-
help= None¶ Help in HTML format which will be displayed in web interface
Example:
help = """ LDAP configuration help <ul> <li>Uri: ldap uri</li> <li>Bind DN: user DN, where ${login} will be replaced with corresponding login</li> <li>TLS support: enable TLS connection</li> </ul> """
-
mail_template_creation= 'create_admin'¶ Mail template to use when an account is created to use this backend
-
authenticate_admin(admin, password)[source]¶ Authenticate users.
This method doesn’t return anything, so in case of authentication error, you must raise
janua.auth.AuthErrorexceptionParameters: - admin – admin database object (
janua.db.database.Admin) - password – user password
- admin – admin database object (
-