Skip to content

Commit

Permalink
create custom TokenAuthentication class
Browse files Browse the repository at this point in the history
  • Loading branch information
xshapira committed Dec 27, 2023
1 parent 5cca509 commit c1d05cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Empty file added auth/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions auth/custom_token_auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from rest_framework import authentication


class TokenCookieAuthentication(authentication.TokenAuthentication):
def authenticate(self, request):
# Check for token in cookies first
token = request.COOKIES.get("authToken")

if token:
return self.authenticate_credentials(token)

# Otherwise check normal auth sources
return super().authenticate(request)

0 comments on commit c1d05cb

Please sign in to comment.