Authentication backend iteration should not rely on TypeError for detection
|Reported by:||Ruy Asan||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
This line here is the problem area. Basically it means that if at any point during the authentication process a TypeError is raised (which is not exactly unlikely) django will simply eat that error, attempt to authenticate, mysteriously fail to to do so and then give the exasperated developer few clues as to why authentication didn't actually happen despite the lack of log messages or exceptions claiming otherwise.
Relying on such generic exceptions for what basically amounts to flow control (in essence all we're trying to do here is allow the backend to signal to django that it doesn't support these credentials) is, IMHO, asking for trouble.
Why can't we simply rely on returning None (as is already the case) or perhaps an explicit value or exception?
Yes this would be a backwards incompatible change but it can be stretched over several releases and warned against using deprecation messages as with other such changes.