Skip to content

Commit

Permalink
translate special scope map
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
  • Loading branch information
BeryJu committed Jun 26, 2022
1 parent abe06bf commit 797e713
Show file tree
Hide file tree
Showing 2 changed files with 343 additions and 245 deletions.
15 changes: 9 additions & 6 deletions authentik/providers/oauth2/views/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from deepmerge import always_merger
from django.http import HttpRequest, HttpResponse
from django.http.response import HttpResponseBadRequest
from django.utils.translation import gettext_lazy as _
from django.views import View
from structlog.stdlib import get_logger

Expand Down Expand Up @@ -39,15 +40,17 @@ def get_scope_descriptions(self, scopes: list[str]) -> list[PermissionDict]:
# GitHub Compatibility Scopes are handled differently, since they required custom paths
# Hence they don't exist as Scope objects
special_scope_map = {
SCOPE_GITHUB_USER: ("GitHub Compatibility: Access your User Information"),
SCOPE_GITHUB_USER_READ: ("GitHub Compatibility: Access your User Information"),
SCOPE_GITHUB_USER_EMAIL: ("GitHub Compatibility: Access you Email addresses"),
SCOPE_GITHUB_ORG_READ: ("GitHub Compatibility: Access your Groups"),
SCOPE_AUTHENTIK_API: ("authentik API Access on behalf of your user"),
SCOPE_GITHUB_USER: _("GitHub Compatibility: Access your User Information"),
SCOPE_GITHUB_USER_READ: _("GitHub Compatibility: Access your User Information"),
SCOPE_GITHUB_USER_EMAIL: _("GitHub Compatibility: Access you Email addresses"),
SCOPE_GITHUB_ORG_READ: _("GitHub Compatibility: Access your Groups"),
SCOPE_AUTHENTIK_API: _("authentik API Access on behalf of your user"),
}
for scope in scopes:
if scope in special_scope_map:
scope_descriptions.append(PermissionDict(id=scope, name=special_scope_map[scope]))
scope_descriptions.append(
PermissionDict(id=scope, name=str(special_scope_map[scope]))
)
return scope_descriptions

def get_claims(self, token: RefreshToken) -> dict[str, Any]:
Expand Down

0 comments on commit 797e713

Please sign in to comment.