No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

dummy_auth.py 877B

12345678910111213141516171819202122232425
  1. #-*- coding: utf-8 -*-
  2. from Lodel.user import authentication_method, identification_method, UserIdentity
  3. from Lodel import logger
  4. @authentication_method
  5. def dummy_auth(identifier, proof):
  6. logger.info("User '%s' is trying to authenticate" % identifier)
  7. if identifier == proof:
  8. print("%s authenticated" % identifier)
  9. return UserIdentity(identifier, identifier, "User %s" % identifier, authenticated = True)
  10. else:
  11. logger.security("Authentication failed for user '%s'" % identifier)
  12. return False
  13. @identification_method
  14. def dummy_identify(client_infos):
  15. print("Trying to identify client with %s" % client_infos)
  16. if 'ip' in client_infos:
  17. ip = client_infos['ip']
  18. if ip in ['localhost', '127.0.0.1', 'local']:
  19. return UserIdentity(0, 'localuser', 'local user', identifier = True)
  20. return False