krb_utils: Simplify get_credentials

Previously, `get_credentials` raises either ValueError or re-raises
GSSError. The former makes the handling of this function more difficult
without a good reason.

With this change:
- `get_credentials` no longer handles exceptions by itself, but delegates
this to the callers (which already process GSS errors).
- `get_credentials_if_valid` doesn't raise any expected exceptions, but
return valid credentials (on the moment of calling) or None. This makes
it consistent with docs.

Related: https://pagure.io/freeipa/issue/8873
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
Stanislav Levin
2021-06-04 12:53:25 +03:00
committed by Alexander Bokovoy
parent 16ab690bf6
commit 0a169b1bea
3 changed files with 28 additions and 26 deletions

View File

@@ -913,6 +913,9 @@ class jsonserver_session(jsonserver, KerberosSession):
else:
return self.service_unavailable(environ, start_response, msg)
except CCacheError:
return self.need_login(start_response)
try:
response = super(jsonserver_session, self).__call__(environ, start_response)
finally: