Ticket #4888: authentication.txt.diff
File authentication.txt.diff, 1.4 KB (added by , 17 years ago) |
---|
-
authentication.txt
959 959 --------------------------------- 960 960 961 961 An authentication backend is a class that implements two methods: 962 ``get_user( id)`` and ``authenticate(**credentials)``.962 ``get_user(user_id)`` and ``authenticate(**credentials)``. 963 963 964 The ``get_user`` method takes an `` id`` -- which could be a username, database964 The ``get_user`` method takes an ``user_id`` -- which could be a username, database 965 965 ID or whatever -- and returns a ``User`` object. 966 966 967 967 The ``authenticate`` method takes credentials as keyword arguments. Most of 968 968 the time, it'll just look like this:: 969 969 970 class MyBackend: 971 def authenticate(self, username=None, password=None): 972 # Check the username/password and return a User. 970 def authenticate(self, username=None, password=None): 971 # Check the username/password and return a User. 973 972 974 973 But it could also authenticate a token, like so:: 975 974 976 class MyBackend: 977 def authenticate(self, token=None): 978 # Check the token and return a User. 975 def authenticate(self, token=None): 976 # Check the token and return a User. 979 977 980 978 Either way, ``authenticate`` should check the credentials it gets, and it 981 979 should return a ``User`` object that matches those credentials, if the