#25187: Make request available in authentication backends
-------------------------------------+-------------------------------------
Reporter: Carl Meyer | Owner: Tim
| Graham <timograham@…>
Type: New feature | Status: closed
Component: contrib.auth | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Marti Raudsepp):
> It looks like CASBackend.authenticate() doesn't follow the advice in
the documentation, "The authenticate method takes credentials as keyword
arguments." Instead, it's taking positional arguments.
After further thought about this, I think you're mistaken.
`CASBackend.authenticate()` allows passing arguments as positional as well
as keyword. Even if it were changed to `authenticate(self, ticket=None,
service=None, request=None)` the change would break CASBackend. If it were
changed to take keyword-only arguments, after the change Django would
still fail to pass it the `request` argument that previously worked.
The actual problem here is that this change breaks the contract. The
documentation quote you provided suggests that arguments are always passed
as keyword arguments, but now it requires `request` to be the first
positional argument.
If Django code was changed to `inspect.getcallargs(backend.authenticate,
request=request, **credentials)`, you would retain the previous contract
of always passing keyword arguments and it would fix this issue as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/25187#comment:15>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.f1f0da727f72488af926f74a013429e7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.