mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-20 08:01:26 +02:00
scopes
This commit is contained in:
@ -163,15 +163,25 @@ class ScopesView(LoginRequiredMixin, TemplateView):
|
||||
|
||||
from oauth2_provider.models import Application
|
||||
from .scopes import PermissionScopes
|
||||
|
||||
scopes = PermissionScopes()
|
||||
|
||||
oidc = False
|
||||
context["scopes"] = {}
|
||||
all_scopes = scopes.get_all_scopes()
|
||||
for app in Application.objects.filter(user=self.request.user).all():
|
||||
available_scopes = scopes.get_available_scopes(app)
|
||||
available_scopes = PermissionScopes().get_available_scopes(app)
|
||||
context["scopes"][app] = OrderedDict()
|
||||
items = [(k, v) for (k, v) in all_scopes.items() if k in available_scopes]
|
||||
# items.sort(key=lambda x: (int(x[0].split("_")[1]), int(x[0].split("_")[0])))
|
||||
all_scopes = PermissionScopes().get_all_scopes(scopes=available_scopes)
|
||||
scopes = {}
|
||||
for scope in available_scopes:
|
||||
scopes[scope] = all_scopes[scope]
|
||||
# remove OIDC scope for sort
|
||||
if 'openid' in scopes:
|
||||
del scopes['openid']
|
||||
oidc = True
|
||||
items = [(k, v) for (k, v) in scopes.items()]
|
||||
items.sort(key=lambda x: (int(x[0].split("_")[1]), int(x[0].split("_")[0])))
|
||||
# add oidc if necessary
|
||||
if oidc:
|
||||
items.append(('openid', PermissionScopes().get_all_scopes(scopes=['openid'])['openid']))
|
||||
for k, v in items:
|
||||
context["scopes"][app][k] = v
|
||||
|
||||
|
Reference in New Issue
Block a user