Hello,
I am using a custom login form to provide a customized authentication
method. I would like my users to be able to authenticate using Basic Auth
to access the service from a mobile application. However the problem is
that I did not find a way to have Basic Auth use my custom login method
without touching web2py source code.
BasicAuth is directly calling login_bare(). So I had to change the
implementation of login_bare() so that it can call a custom authentication
method (see implementation below). login_bare() is
calling get_user_basic(username, password) which behaves like get_user()
but takes username and password as parameters.
Is there a better way to achieve this? Otherwise, can we envision a
solution in Web2py similar to the one described to be able to use Basic
Auth with an alternate login method?
Thanks,
Damien
Note: The goal of this customized authentication method is to be able to
login the same user with multiple addresses and phone numbers as the login,
but a unique password.
def login_bare(self, username, password):
"""
logins user as specified by username (or email) and password
"""
if self.settings.login_form == self:
[existing login_bare() implementation]
else:
cas = self.settings.login_form
cas_user = cas.get_user_basic(username, password)
if cas_user:
cas_user[self.settings.passfield] = None
self.user = self.get_or_create_user(
self.settings.table_user._filter_fields(cas_user),
self.settings.update_fields)
return self.user
return False
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.