python - Django authenticating using non django user -
i have write django application / website gets of it's data third party rest server. means i'm not using of default django orm models, , reading rest requests. seems working fine, since i'm able call methods on rest server , list of objects, display objects, update, add , delete objects ...
but need users log in django site / application, since registered , logged in users should able see data. of course users handled third party rest server, , not created django orm.
the rest api has methods / create user , check if user / password combination valid. wondering how should use within django application / website.
i guess won't able use request.user.is_authenticated since that's remote rest api should validate. have read remote_user can't seem find examples on how set remoteuserbackend suit needs.
anyone here has suggestions or point me in right direction?
i sugest write own authentication-backend.
you take credentials, authenticate on rest, informations need create django usermodel object , return that. ofc not saved or loaded own database. newly created object.
class mybackend(object): def authenticate(self, username=none, password=none, token=none): if token: # token auth on rest elif username , password: # normal auth on rest else: return none # read django docs user model django.contrib.auth.models import user myuser = user() myuser.username = name_from_rest myuser.set_password(pw_from_rest) myuser.save() return myuser ...
i have never done nor know if work. how try it, if not save user in db.
Comments
Post a Comment