Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep empty member list for invalid groups #36

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions flask_multipass_cern.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_members(self):
}
try:
results = self.provider._fetch_all(api_session, f'/api/v1.0/Group/{name}/memberidentities/precomputed',
params)[0]
params, empty_if_404=True)[0]
except RequestException:
self.provider.logger.warning('Refreshing members failed for group %s', name)
if cached_results is not None:
Expand Down Expand Up @@ -528,9 +528,11 @@ def _fetch_identity_data(self, auth_info):
del data['id'] # id is always included
return data

def _fetch_all(self, api_session, endpoint, params, limit=None):
def _fetch_all(self, api_session, endpoint, params, limit=None, *, empty_if_404=False):
results = []
resp = api_session.get(self.authz_api_base + endpoint, params=params)
if empty_if_404 and resp.status_code == 404:
return [], 0
resp.raise_for_status()
data = resp.json()
total = data['pagination']['total']
Expand All @@ -540,6 +542,7 @@ def _fetch_all(self, api_session, endpoint, params, limit=None):
if not data['pagination']['next'] or (limit is not None and len(results) >= limit):
break
resp = api_session.get(self.authz_api_base + data['pagination']['next'])
# XXX we do not expect 404s here after the first one succeeded, so here we consider it a real error
resp.raise_for_status()
data = resp.json()
if limit is not None:
Expand Down