Previous Page Next Page

Q&A

Q.Is there a way to retrieve all of a user's permissions?
A.Yes. The User.get_all_permissions() function returns a list of permission strings that represent the user's permissions.
Q.Is there a way to control what happens during authentication to customize verification?
A.Yes. You can specify your own authentication backend by adding it to the AUTHENTICATION_BACKENDS setting in the settings.py file. Django applies the backends in the order they are listed in the setting. The backend must be in the Python path. The backend needs to define an authenticate() function that checks the credentials and returns a User object on success and None on failure. For example:
from django.contrib.auth.models import User, check_password
class custBackend:
    def authenticate(self, username, password):
        #validation code
        . . .
        if authenticated:
            return user
        else:
        return None

Previous Page Next Page