Skip to content

Commit b3c00d7

Browse files
d-w-moorealanking
authored andcommitted
[#518] preserve login_<auth-type> internally generated exceptions
1 parent 98d74c5 commit b3c00d7

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

irods/connection.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ def __init__(self, pool, account):
6363
self._disconnected = False
6464

6565
scheme = self.account._original_authentication_scheme
66-
auth_type = ''
66+
67+
# These variables are just useful diagnostics. The login_XYZ() methods should fail by
68+
# raising exceptions if they encounter authentication errors.
69+
auth_module = auth_type = ''
6770

6871
if self.server_version >= (4,3,0):
72+
auth_module = None
6973
# use client side "plugin" module: irods.auth.<scheme>
7074
irods.auth.load_plugins(subset=[scheme])
7175
auth_module = getattr(irods.auth, scheme, None)
@@ -75,19 +79,18 @@ def __init__(self, pool, account):
7579
else:
7680
# use legacy (iRODS pre-4.3 style) authentication
7781
auth_type = scheme
78-
try:
79-
if scheme == NATIVE_AUTH_SCHEME:
80-
self._login_native()
81-
elif scheme == GSI_AUTH_SCHEME:
82-
self.client_ctx = None
83-
self._login_gsi()
84-
elif scheme == PAM_AUTH_SCHEME:
85-
self._login_pam()
86-
except:
82+
if scheme == NATIVE_AUTH_SCHEME:
83+
self._login_native()
84+
elif scheme == GSI_AUTH_SCHEME:
85+
self.client_ctx = None
86+
self._login_gsi()
87+
elif scheme == PAM_AUTH_SCHEME:
88+
self._login_pam()
89+
else:
8790
auth_type = None
8891

8992
if not auth_type:
90-
msg = "Authentication failed: scheme = {scheme!r}, auth_type = {auth_type!r}".format(**locals())
93+
msg = "Authentication failed: scheme = {scheme!r}, auth_type = {auth_type!r}, auth_module = {auth_module!r}, ".format(**locals())
9194
raise ValueError(msg)
9295

9396
self.create_time = datetime.datetime.now()
@@ -464,15 +467,13 @@ def _login_pam(self):
464467
# Login using PAM password from .irodsA
465468
try:
466469
self._login_native()
467-
except (ex.CAT_PASSWORD_EXPIRED, ex.CAT_INVALID_USER, ex.CAT_INVALID_AUTHENTICATION):
470+
except (ex.CAT_PASSWORD_EXPIRED, ex.CAT_INVALID_USER, ex.CAT_INVALID_AUTHENTICATION) as exc:
468471
time_to_live_in_hours = cfg.legacy_auth.pam.time_to_live_in_hours
469472
if cfg.legacy_auth.pam.password_for_auto_renew:
470473
new_pam_password = cfg.legacy_auth.pam.password_for_auto_renew
471474
# Fall through and retry the native login later, after creating a new PAM password
472475
else:
473-
message = ('Time To Live has expired for the PAM password, and no new password is given in ' +
474-
'legacy_auth.pam.password_for_auto_renew. Please run iinit.')
475-
raise RuntimeError(message)
476+
raise exc
476477
else:
477478
# Login succeeded, so we're within the time-to-live and can return without error.
478479
return

0 commit comments

Comments
 (0)