DEFAULT_AUTHENTICATION_CLASS: don't raise errors until every backend has checked the token #7867
Replies: 1 comment 1 reply
-
So the way this works is that an authentication class may either return None (in which case other backends will still be checked) or raise an error (in which case they won't). So, for example, if you have
It looks from a quick pass to me that you're using two different auth classes, both of which are making lookups against That's a bit of an awkward case because even if we do run them both, then if both fail it wouldn't be clear which exception we'd want to raise. I'm not sure what's best to do here. I'd assume someone else has already run into this before. You could potentially work around this with a custom auth class with an |
Beta Was this translation helpful? Give feedback.
-
We are using JWT for our backend auth and Oauth2 for external connections, the problem we have is that if one authentication backend raises an error it stops checking the others, so if I use Bearer prefix with a JWT token it will rise an error if it doesn't match but will stop looking to check if it matches with Oauth2 and vice versa.
Example:
Config:
This will raise a an error and won't check with the Oauth2 backend
Authorization: Bearer <Oauth2 token>
Example:
Config:
This will raise a an error and won't check with the JWT backend
Authorization: Bearer <JWT token>
Beta Was this translation helpful? Give feedback.
All reactions