Skip to content

Custom authentication backend #11

@TimOsahenru

Description

@TimOsahenru

Django provides a simple way to define your own authentication backends. An authentication backend is a class that provides the following two methods:

  • authenticate(): It takes the request object and user credentials as parameters. It has to return a user object that matches those credentials if the credentials are valid, or None oth- erwise. The request parameter is an HttpRequest object, or None if it’s not provided to the authenticate() function.
  • get_user(): It takes a user ID parameter and has to return a user object.

Creating a custom authentication backend is as simple as writing a Python class that implements both methods. Let’s create an authentication backend to allow users to authenticate on the site using their email address instead of their username.

Deliverables

  • Implementation should be done in the authentication.py file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions