From 6d436325c41ad8f7353b99e8771b46b63b81f23e Mon Sep 17 00:00:00 2001 From: Jordan Bradford <36420801+jrdnbradford@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:25:57 -0400 Subject: [PATCH] Use `include` and set `*_groups` to `None` --- oauthenticator/google.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/oauthenticator/google.py b/oauthenticator/google.py index 3faa8924..f06f6aca 100644 --- a/oauthenticator/google.py +++ b/oauthenticator/google.py @@ -105,7 +105,7 @@ def _userdata_url_default(self): """, ) - allow_nested_groups = Bool( + include_nested_groups = Bool( config=True, help=""" Include members of nested Google groups in `allowed_google_groups` and @@ -383,8 +383,8 @@ def _fetch_member_groups( member_email, user_email_domain, http=None, - checked_groups=set(), - processed_groups=set(), + checked_groups=None, + processed_groups=None, ): """ Return a set with the google groups a given user/group is a member of, including nested groups if allowed. @@ -397,6 +397,9 @@ def _fetch_member_groups( if not hasattr(self, 'service'): self.service = self._setup_service(user_email_domain, http) + checked_groups = checked_groups or set() + processed_groups = processed_groups or set() + resp = self.service.groups().list(userKey=member_email).execute() member_groups = { g['email'].split('@')[0] for g in resp.get('groups', []) if g.get('email') @@ -406,7 +409,7 @@ def _fetch_member_groups( checked_groups.update(member_groups) self.log.debug(f"Checked groups after update: {checked_groups}") - if self.allow_nested_groups: + if self.include_nested_groups: for group in member_groups: if group in processed_groups: continue