Skip to content

Commit

Permalink
Provide details for IdentityRetrievalFailed exception
Browse files Browse the repository at this point in the history
  • Loading branch information
tomako committed Nov 21, 2024
1 parent 8940483 commit 7f1d7ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flask_multipass/providers/authlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,5 @@ def get_identity_from_auth(self, auth_info):
identifier = auth_info.data.get(self.id_field)
if not identifier:
raise IdentityRetrievalFailed(f'Identifier ({self.id_field}) missing in authlib response',
provider=self)
details=auth_info.data, provider=self)
return IdentityInfo(self, identifier=identifier, **auth_info.data)
6 changes: 4 additions & 2 deletions flask_multipass/providers/saml.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ def get_identity_from_auth(self, auth_info):
identifier = auth_info.data.get(self.id_field)
if isinstance(identifier, list):
if len(identifier) != 1:
raise IdentityRetrievalFailed('Identifier has multiple elements', provider=self)
raise IdentityRetrievalFailed('Identifier has multiple elements',
details=identifier, provider=self)
identifier = identifier[0]
if not identifier:
raise IdentityRetrievalFailed('Identifier missing in saml response', provider=self)
raise IdentityRetrievalFailed('Identifier missing in saml response',
details=auth_info.data, provider=self)
return IdentityInfo(self, identifier=identifier, **auth_info.data)
3 changes: 2 additions & 1 deletion flask_multipass/providers/shibboleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ def __init__(self, *args, **kwargs):
def get_identity_from_auth(self, auth_info):
identifier = auth_info.data.get(self.id_field)
if not identifier:
raise IdentityRetrievalFailed('Identifier missing in shibboleth response', provider=self)
raise IdentityRetrievalFailed('Identifier missing in shibboleth response',
details=auth_info.data, provider=self)
return IdentityInfo(self, identifier=identifier, **auth_info.data)

0 comments on commit 7f1d7ee

Please sign in to comment.