@@ -23,8 +23,11 @@ def login(conn, **extra_opt):
23
23
_scheme = 'pam_password'
24
24
25
25
26
+ _logger = logging .getLogger (__name__ )
27
+
28
+
26
29
def authenticate_pam_password (conn , req ):
27
- logging . info ('----------- %s (begin)' , _scheme )
30
+ _logger . debug ('----------- %s (begin)' , _scheme )
28
31
29
32
# By design, we persist this "depot" object over the whole of the authentication
30
33
# exchange with the iRODS server as a means of sending password information to the
@@ -33,14 +36,14 @@ def authenticate_pam_password(conn, req):
33
36
# are authenticating without the help of iCommand-type client env/auth files.
34
37
_ = AuthStorage .create_temp_pw_storage (conn )
35
38
36
- pam_password_ClientAuthState (
39
+ _pam_password_ClientAuthState (
37
40
conn ,
38
41
scheme = _scheme
39
42
).authenticate_client (
40
43
initial_request = req
41
44
)
42
45
43
- logging . info ('----------- %s (end)' , _scheme )
46
+ _logger . debug ('----------- %s (end)' , _scheme )
44
47
45
48
46
49
def get_pam_password_from_stdin (file_like_object = None ):
@@ -61,30 +64,39 @@ def get_pam_password_from_stdin(file_like_object = None):
61
64
AUTH_PASSWORD_KEY = "a_pw"
62
65
63
66
64
- class pam_password_ClientAuthState (authentication_base ):
67
+ class _pam_password_ClientAuthState (authentication_base ):
68
+
69
+ # Client define
70
+ AUTH_CLIENT_AUTH_REQUEST = "pam_password_auth_client_request"
71
+
72
+ # Server define
73
+ AUTH_AGENT_AUTH_REQUEST = "auth_agent_auth_request"
65
74
66
75
def __init__ (self ,* _ ,check_ssl = True ,** _kw ):
67
76
super ().__init__ (* _ ,** _kw )
68
77
self .check_ssl = check_ssl
69
- self ._l = None
78
+ self ._list_for_request_result_return = None
70
79
71
80
def auth_client_start (self , request ):
72
81
73
- self ._l = request .pop (CLIENT_GET_REQUEST_RESULT , False )
82
+ # This list reference is popped and cached for the purpose of returning the request_result value
83
+ # to the caller upon request.
84
+ self ._list_for_request_result_return = request .pop (CLIENT_GET_REQUEST_RESULT , False )
74
85
75
86
if self .check_ssl :
76
87
if not isinstance (self .conn .socket , ssl .SSLSocket ):
77
- msg = 'Need to be connected via SSL.'
88
+ msg = "pam_password auth scheme requires secure communications (TLS/ SSL) with the server."
78
89
raise RuntimeError (msg )
79
90
80
91
resp = request .copy ()
81
92
82
- obj = resp .pop (FORCE_PASSWORD_PROMPT , None )
93
+ password_input_obj = resp .pop (FORCE_PASSWORD_PROMPT , None )
83
94
84
- if obj :
85
- obj = None if isinstance (obj ,(int ,bool )) else obj
86
- # Like with the C++ plugin, we offer the user a chance
87
- resp [AUTH_PASSWORD_KEY ] = get_pam_password_from_stdin (file_like_object = obj )
95
+ if password_input_obj :
96
+ if isinstance (password_input_obj ,(int ,bool )):
97
+ password_input_obj = None
98
+ # Like with the C++ plugin, we offer the user a chance to enter a password.
99
+ resp [AUTH_PASSWORD_KEY ] = get_pam_password_from_stdin (file_like_object = password_input_obj )
88
100
else :
89
101
# Password from .irodsA in environment.
90
102
if self .conn .account ._auth_file :
@@ -97,12 +109,6 @@ def auth_client_start(self, request):
97
109
resp [__NEXT_OPERATION__ ] = self .AUTH_CLIENT_AUTH_REQUEST
98
110
return resp
99
111
100
- # Client define
101
- AUTH_CLIENT_AUTH_REQUEST = "pam_password_auth_client_request"
102
-
103
- # Server define
104
- AUTH_AGENT_AUTH_REQUEST = "auth_agent_auth_request"
105
-
106
112
def pam_password_auth_client_request (self , request ):
107
113
server_req = request .copy ()
108
114
server_req [__NEXT_OPERATION__ ] = self .AUTH_AGENT_AUTH_REQUEST
@@ -113,14 +119,15 @@ def pam_password_auth_client_request(self, request):
113
119
depot = AuthStorage .get_temp_pw_storage (self .conn )
114
120
if depot :
115
121
if resp .get (STORE_PASSWORD_IN_MEMORY , None ):
122
+ # Prevent use of an .irodsA to store an encoded password.
116
123
depot .use_client_auth_file (None )
117
124
depot .store_pw (resp ["request_result" ])
118
125
else :
119
126
msg = "auth storage object was either not set, or allowed to expire prematurely."
120
127
raise RuntimeError (msg )
121
128
122
- if isinstance (self ._l ,list ):
123
- self ._l [:] = (resp ["request_result" ],)
129
+ if isinstance (self ._list_for_request_result_return ,list ):
130
+ self ._list_for_request_result_return [:] = (resp ["request_result" ],)
124
131
125
132
resp [__NEXT_OPERATION__ ] = self .perform_native_auth
126
133
return resp
0 commit comments