python - Django : Calling the authenticate method of a class that inherits from RemoteUserBackend -
i having difficulty customizing djangos authentication system. in scenario there no database , authentication happens through http request. there no tables read or write from.
this thread here deals pretty same case dealing not understand how user being created in example. read this django manual regarding remote_user
authentication.coming first link user posted code here.it consists of backend , user object
backend - inherit remoteuserbackend
from django.contrib.auth.backends import remoteuserbackend class myremoteuserbackend (remoteuserbackend): # create user object if not in database? create_unknown_user = false def get_user (self, user_id): user = somehow_create_an_instance_of (myuser, user_id) ---->a return user def authenticate (self, **credentials): check_credentials () user = somehow_create_an_instance_of (myuser, credentials) ---->b return user
then user:
from django.contrib.auth.models import user class myuser (user): def save (self): """saving db disabled""" pass objects = none # cannot use w/o local db username = "" # , other properties likewise. # they're defined model.charfield or similar, # , can't allow def get_group_permissions (self): """if don't make own permissions module, default use db. throw away""" return [] # likewise other permission defs def get_and_delete_messages (self): """messages stored in db. darn!""" return []
now question in view
def my_view(request): username = request.post['username'] password = request.post['password'] user = authenticate(username=username, password=password) if user not none: if user.is_active: login(request, user)
now how can have authenticate
method myremoteuserbackend
called in above code snippet , snippet mean somehow_create_an_instance_of
suggestions on great