mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-11-08 07:49:49 +01:00
Add test for oauth2 flow, add temporary ROPB for NoteApp #137
This commit is contained in:
@@ -12,6 +12,7 @@ from .models import Permission
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class PermissionScopes(BaseScopes):
|
||||
"""
|
||||
An OAuth2 scope is defined by a permission object and a club.
|
||||
@@ -83,8 +84,12 @@ class PermissionOAuth2Validator(OAuth2Validator):
|
||||
|
||||
valid_scopes = set()
|
||||
|
||||
# simple patch for have functionnal ROPB flow
|
||||
# TODO rewrite
|
||||
r = get_current_request()
|
||||
r.user = request.user
|
||||
for t in Permission.PERMISSION_TYPES:
|
||||
for p in PermissionBackend.get_raw_permissions(get_current_request(), t[0]):
|
||||
for p in PermissionBackend.get_raw_permissions(r, t[0]):
|
||||
scope = f"{p.id}_{p.membership.club.id}"
|
||||
if scope in scopes:
|
||||
valid_scopes.add(scope)
|
||||
|
||||
Reference in New Issue
Block a user