-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: adjust internal backend auth and add cache token
- Loading branch information
Showing
5 changed files
with
63 additions
and
18 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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
from mozilla_django_oidc.contrib.drf import OIDCAuthentication | ||
|
||
from retail.internal.backends import InternalOIDCAuthenticationBackend | ||
from retail.internal.backends import WeniOIDCAuthenticationBackend | ||
|
||
|
||
class InternalOIDCAuthentication(OIDCAuthentication): | ||
def __init__(self, backend=None): | ||
super().__init__(backend or InternalOIDCAuthenticationBackend()) | ||
super().__init__(backend or WeniOIDCAuthenticationBackend()) |
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
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 |
---|---|---|
@@ -1,8 +1,16 @@ | ||
from rest_framework import permissions | ||
|
||
|
||
class CanCommunicateInternally(permissions.BasePermission): | ||
class CanCommunicateInternally(permissions.IsAuthenticated): | ||
def has_permission(self, request, view): | ||
return request.user.user_permissions.filter( | ||
# Check if the user is authenticated | ||
user = request.user | ||
if not user.is_authenticated: | ||
return False | ||
|
||
# Check if the user has 'can_communicate_internally' permission | ||
has_internal_permission = user.user_permissions.filter( | ||
codename="can_communicate_internally" | ||
).exists() | ||
|
||
return has_internal_permission |
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
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