1
0
mirror of https://gitlab.crans.org/bde/nk20 synced 2025-10-18 11:16:40 +02:00

Compare commits

..

1 Commits

Author SHA1 Message Date
quark
d2cc1b902d allows mask for Oauth2 2025-10-17 17:45:41 +02:00
3 changed files with 11 additions and 2 deletions

View File

@@ -39,7 +39,15 @@ class PermissionBackend(ModelBackend):
def permission_filter(membership_obj):
query = Q(pk=-1)
if 'mask' in request.GET:
try:
rank = int(request.GET['mask'])
except:
rank = 42
query &= Q(mask__rank__lte=rank)
for scope in request.auth.scope.split(' '):
if scope == "openid":
continue
permission_id, club_id = scope.split('_')
if int(club_id) == membership_obj.club_id:
query |= Q(pk=permission_id)

View File

@@ -10,6 +10,7 @@ from note_kfet.middlewares import get_current_request
from .backends import PermissionBackend
from .models import Permission
from django.utils.translation import gettext_lazy as _
class PermissionScopes(BaseScopes):
"""
@@ -32,7 +33,7 @@ class PermissionScopes(BaseScopes):
scopes = {f"{p.id}_{club.id}": f"{p.description} (club {club.name})"
for p in Permission.objects.all() for club in Club.objects.all()}
scopes['openid'] = "OpenID Connect"
scopes['openid'] = _("OpenID Connect (username and email)")
return scopes
def get_available_scopes(self, application=None, request=None, *args, **kwargs):

View File

@@ -4399,7 +4399,7 @@ msgstr "Géré par le BDE"
#: note_kfet/templates/base.html:231
msgid "Hosted by Cr@ns"
msgstr "Hébergé par le Cr@ns"
msgstr "Hébergé par le Cr@ans"
#: note_kfet/templates/base.html:273
msgid "The note is not available for now"