• 851 views
  • 0 comments
  • loading...

auth.settings.login_methods

auth.settings.login_methods is a list of authentication methods that are executed sequentially. By default it is set to  auth.settings.login_methods = [auth]

When an alternate method is appended, for example basic_auth, Auth first tries to log in the visitor based on the content of auth_user, and when this fails, it tries the next method in the list. If a method succeeds in logging in the visitor, and if auth.settings.login_methods[0]==auth, Auth takes the following actions:

  •     if the user does not exist in auth_user, a new user is created and the username/email and passwords are stored.
  •     if the user does exist in auth_user but the new accepted password does not match the old stored password, the old password is replaced with the new one (notice that passwords are always stored hashed unless specified otherwise).


















from gluon.contrib.login_methods.ldap_auth import ldap_auth

auth.settings.login_methods = [auth, ldap_auth(mode='ad',
bind_dn='USERNAME',
bind_pw='PASSWORD',
manage_groups=False,
manage_user=True,
user_firstname_attrib='cn:1',
user_lastname_attrib='cn:2',
server='SERVERNAME',
user_mail_attrib='mail',
base_dn='dc=DC,dc=DOMAIN',
logging_level='error',
db=db)]

# Example
from gluon.contrib.login_methods.basic_auth import basic_auth
auth.settings.login_methods.append(
basic_auth('https://basic.example.com'))

Examples

loading...


Comments

loading...

Powered by
Web2py

Hosted on
www.pythonanywhere.com
(affiliated link)