Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom authentication backend #11

Open
TimOsahenru opened this issue Oct 14, 2024 · 0 comments
Open

Custom authentication backend #11

TimOsahenru opened this issue Oct 14, 2024 · 0 comments

Comments

@TimOsahenru
Copy link
Owner

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant