mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-01 19:10:12 +03:00
Pass request to authenticate_credentials in TokenAuthentication
It may help if you need to filter tokens based on information from request. E.g. in multi-tenant application request may contain current tenant object.
This commit is contained in:
parent
9d001cd84c
commit
d824ab677b
|
@ -189,9 +189,9 @@ class TokenAuthentication(BaseAuthentication):
|
|||
msg = _('Invalid token header. Token string should not contain invalid characters.')
|
||||
raise exceptions.AuthenticationFailed(msg)
|
||||
|
||||
return self.authenticate_credentials(token)
|
||||
return self.authenticate_credentials(token, request)
|
||||
|
||||
def authenticate_credentials(self, key):
|
||||
def authenticate_credentials(self, key, request=None):
|
||||
model = self.get_model()
|
||||
try:
|
||||
token = model.objects.select_related('user').get(key=key)
|
||||
|
|
Loading…
Reference in New Issue
Block a user