Skip to content

Commit

Permalink
fix(auth): add userinfo to authenticated user
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz committed Jan 13, 2023
1 parent c0b8dee commit 21ae809
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions document_merge_service/api/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ def __str__(self):


class AuthenticatedUser(AnonymousUser):
def __init__(self, username, groups):
self.username = username
def __init__(self, userinfo):
self.username = userinfo["sub"]
groups = []
if settings.OIDC_GROUPS_CLAIM:
groups = userinfo[settings.OIDC_GROUPS_CLAIM]
self.groups = groups
self.userinfo = userinfo

@property
def is_authenticated(self):
Expand Down Expand Up @@ -94,12 +98,8 @@ def authenticate(self, request):
timeout=settings.OIDC_BEARER_TOKEN_REVALIDATION_TIME,
)

groups = []
if settings.OIDC_GROUPS_CLAIM:
groups = userinfo[settings.OIDC_GROUPS_CLAIM]

return (
AuthenticatedUser(userinfo["sub"], groups),
AuthenticatedUser(userinfo),
token,
)

Expand Down

0 comments on commit 21ae809

Please sign in to comment.