Compare commits
2 Commits
43c6788934
...
304764f9b7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
304764f9b7 | ||
|
|
8acb7471f6 |
11
jobposting/permissions.py
Normal file
11
jobposting/permissions.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from rest_framework.permissions import BasePermission
|
||||||
|
|
||||||
|
class ClientCredentialPermission(BasePermission):
|
||||||
|
def has_permission(self, request, view):
|
||||||
|
if request.auth is None:
|
||||||
|
return False
|
||||||
|
grant_type = request.auth.application.get_authorization_grant_type_display()
|
||||||
|
if request.user is None and grant_type == 'Client credentials':
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
@ -3,7 +3,7 @@ from rest_framework.response import Response
|
|||||||
from jobposting.models import JobListing, SkillLevels, CompanyLogo, Skill
|
from jobposting.models import JobListing, SkillLevels, CompanyLogo, Skill
|
||||||
from core.models import MyUser, AnonymousUserData
|
from core.models import MyUser, AnonymousUserData
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from izaac.permissions import ClientCredentialPermission
|
from jobposting.permissions import ClientCredentialPermission
|
||||||
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope
|
from oauth2_provider.contrib.rest_framework import TokenHasReadWriteScope
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user