@@ -82,39 +82,43 @@ def __init__(self, pool, account):
8282 self ._server_version = self ._connect ()
8383 self ._disconnected = False
8484
85- scheme = self .account ._original_authentication_scheme
86-
87- # These variables are just useful diagnostics. The login_XYZ() methods should fail by
88- # raising exceptions if they encounter authentication errors.
89- auth_module = auth_type = ""
90-
91- if self .server_version >= (4 , 3 , 0 ):
92- auth_module = None
93- # use client side "plugin" module: irods.auth.<scheme>
94- irods .auth .load_plugins (subset = [scheme ])
95- auth_module = getattr (irods .auth , scheme , None )
96- if auth_module :
97- auth_module .login (self )
98- auth_type = auth_module .__name__
99- else :
100- # use legacy (iRODS pre-4.3 style) authentication
101- auth_type = scheme
102- if scheme == NATIVE_AUTH_SCHEME :
103- self ._login_native ()
104- elif scheme == GSI_AUTH_SCHEME :
105- self .client_ctx = None
106- self ._login_gsi ()
107- elif scheme == PAM_AUTH_SCHEME :
108- self ._login_pam ()
109- else :
110- auth_type = None
85+ if self .pool and not self .pool ._need_auth :
86+ return
11187
112- if not auth_type :
113- msg = f"Authentication failed: scheme = { scheme !r} , auth_type = { auth_type !r} , auth_module = { auth_module !r} , "
114- raise ValueError (msg )
88+ try :
89+ scheme = self .account ._original_authentication_scheme
90+
91+ # These variables are just useful diagnostics. The login_XYZ() methods should fail by
92+ # raising exceptions if they encounter authentication errors.
93+ auth_module = auth_type = ''
94+
95+ if self .server_version >= (4 ,3 ,0 ):
96+ auth_module = None
97+ # use client side "plugin" module: irods.auth.<scheme>
98+ irods .auth .load_plugins (subset = [scheme ])
99+ auth_module = getattr (irods .auth , scheme , None )
100+ if auth_module :
101+ auth_module .login (self )
102+ auth_type = auth_module .__name__
103+ else :
104+ # use legacy (iRODS pre-4.3 style) authentication
105+ auth_type = scheme
106+ if scheme == NATIVE_AUTH_SCHEME :
107+ self ._login_native ()
108+ elif scheme == GSI_AUTH_SCHEME :
109+ self .client_ctx = None
110+ self ._login_gsi ()
111+ elif scheme == PAM_AUTH_SCHEME :
112+ self ._login_pam ()
113+ else :
114+ auth_type = None
115115
116- self .create_time = datetime .datetime .now ()
117- self .last_used_time = self .create_time
116+ if not auth_type :
117+ msg = f"Authentication failed: scheme = { scheme !r} , auth_type = { auth_type !r} , auth_module = { auth_module !r} , "
118+ raise ValueError (msg )
119+ finally :
120+ self .create_time = datetime .datetime .now ()
121+ self .last_used_time = self .create_time
118122
119123 @property
120124 def server_version (self ):
0 commit comments