Ticket #4888: authentication.txt.diff

File authentication.txt.diff, 1.4 KB (added by Piotr Lewandowski <django@…>, 17 years ago)
  • authentication.txt

     
    959959---------------------------------
    960960
    961961An authentication backend is a class that implements two methods:
    962 ``get_user(id)`` and ``authenticate(**credentials)``.
     962``get_user(user_id)`` and ``authenticate(**credentials)``.
    963963
    964 The ``get_user`` method takes an ``id`` -- which could be a username, database
     964The ``get_user`` method takes an ``user_id`` -- which could be a username, database
    965965ID or whatever -- and returns a ``User`` object.
    966966
    967967The  ``authenticate`` method takes credentials as keyword arguments. Most of
    968968the time, it'll just look like this::
    969969
    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.
    973972
    974973But it could also authenticate a token, like so::
    975974
    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.
    979977
    980978Either way, ``authenticate`` should check the credentials it gets, and it
    981979should return a ``User`` object that matches those credentials, if the
Back to Top