Opened 2 years ago

Last modified 2 years ago

#34032 closed Cleanup/optimization

Base authentication Backend should raise NotImplemented on needed methods — at Version 1

Reported by: Dre Westcook Owned by: nobody
Component: contrib.auth Version: 4.0
Severity: Normal Keywords: authentication
Cc: Vishal Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Dre Westcook)

Hi all,

Recently I've been trying my hand at creating alternative sign on methods for a django system and I've found the whole process fairly clean.

However I did reach bit of a time waste when my "code that should work, doesn't" -- in my login view, I would authenticate() and login() properly, but with a redirect response I would be an AnonymousUser immediately after.

After two days of debugging and re-reading docs, I found that I missed out a fairly critical sentence: "Authentication backends implements two required methods". -- my authentication backend (of which I was replacing the default) - did not implement get_user() so we would use the default BaseBackend.get_user() which is to return None.

To me, it wasn't quite obvious why the authentication system needs to implement get_user ( as i'd want to just get the user by pk like any other) so this was a little bit of time wasting that I feel could be made a bit more obvious.

Some ideas:

Happy for some thoughts/feedback/pushback. This was just a painpoint for me while developing.

Perhaps it needs to be highlighted in the documentation?

Change History (1)

comment:1 by Dre Westcook, 2 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top