Skip to content

Commit

Permalink
Authorize based on group membership if allowed_users is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgianaElena committed Apr 11, 2023
1 parent 4834c99 commit 039391c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion oauthenticator/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_user_groups(self, user_info):

async def user_is_authorized(self, auth_model):
user_info = auth_model["auth_state"][self.user_auth_state_key]
if self.allowed_groups:
if not self.allowed_users and (self.allowed_groups or self.admin_groups):
self.log.info(
f"Validating if user claim groups match any of {self.allowed_groups}"
)
Expand Down
2 changes: 1 addition & 1 deletion oauthenticator/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def user_is_authorized(self, auth_model):
403, f"Google account domain @{user_email_domain} not authorized."
)

if self.allowed_google_groups:
if not self.allowed_users and (self.allowed_google_groups or self.admin_google_groups):
google_groups = self._google_groups_for_user(user_email, user_email_domain)
if not google_groups:
return False
Expand Down
2 changes: 1 addition & 1 deletion oauthenticator/openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async def user_is_authorized(self, auth_model):
user_groups = set(auth_model['auth_state']['openshift_user']['groups'])
username = auth_model['name']

if self.allowed_groups or self.admin_groups:
if not self.allowed_users and (self.allowed_groups or self.admin_groups):
msg = f"username:{username} User not in any of the allowed/admin groups"
# User is authorized if either in allowed_groups or in admin_groups
if not self.user_groups_in_allowed_groups(
Expand Down

0 comments on commit 039391c

Please sign in to comment.