-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added auth and permission classes for auto auth
- Loading branch information
1 parent
d5a7689
commit 48971bf
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
This module provides a custom DRF Permission class for supporting the e2e | ||
testing. | ||
""" | ||
from django.conf import settings | ||
from rest_framework.permissions import BasePermission | ||
|
||
|
||
class IsE2eTestUser(BasePermission): | ||
""" | ||
Method that will ensure whether the requesting user is e2e | ||
test user or not | ||
""" | ||
def has_permission(self, request, view): | ||
# check whether requesting user is the e2e test user or not | ||
if request.user.username == settings.E2E_TEST_USER_USERNAME: | ||
return True | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters