Catch ValueError when trying to retrieve existing credentials

get_credentials() was changed to raise ValueError instead of
gssapi.exceptions.GSSError as part of the sweeper to clean up
expired credentials caches.

For WebUI users, this will prevent a 500 error if their
associated credentials cache is expired or missing.

https://pagure.io/freeipa/issue/8873

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Rob Crittenden 2021-06-03 14:17:56 -04:00 committed by Alexander Bokovoy
parent d8b8f54bce
commit 51fb9d61bb

View File

@ -175,7 +175,7 @@ def get_principal(ccache_name=None):
try:
creds = get_credentials(ccache_name=ccache_name)
return unicode(creds.name)
except gssapi.exceptions.GSSError as e:
except ValueError as e:
raise errors.CCacheError(message=unicode(e))
def get_credentials_if_valid(name=None, ccache_name=None):
@ -202,5 +202,5 @@ def get_credentials_if_valid(name=None, ccache_name=None):
return None
except gssapi.exceptions.ExpiredCredentialsError:
return None
except gssapi.exceptions.GSSError:
except ValueError:
return None