@@ -129,87 +129,86 @@ the `encryption_*` and `ssl_*` options
129
129
directly to the constructor as keyword arguments, even though it is
130
130
required when they are placed in the environment file.
131
131
132
- Creating PAM or Native Credentials File (.irodsA)
133
- -------------------------------------------------
132
+ Creating a PAM or Native Authentication File
133
+ --------------------------------------------
134
134
135
- Two free functions exist which allow the user to create encoded authentication files
136
- for use in the client's iRODS login environment:
137
- ```
138
- irods.client_init.write_native_irodsA_file
139
- irods.client_init.write_pam_irodsA_file
140
- ```
141
-
142
- These functions can roughly be described as duplicating the function of iinit (from iCommands),
143
- once a valid irods_environment.json has already been created.
135
+ The following free functions may be used to create the authentication secrets files (called
136
+ ` .irodsA ` per the convention of iRODS's iCommands):
137
+ - ` irods.client_init.write_native_irodsA_file `
138
+ - ` irods.client_init.write_pam_irodsA_file `
144
139
145
- Each takes a cleartext password and writes an appropriately processed version of it
146
- into an .irodsA "password" or "secrets" in the appropriate location .
140
+ These functions can roughly be described as duplicating the function of ` iinit ` ,
141
+ provided that a valid ` irods_environment.json ` has already been created .
147
142
148
- That location is ~ /.irods/.irodsA) unless IRODS_AUTHENTICATION_FILE has
149
- been set with an alternate file path in the OS environment.
143
+ Each of the above functions can take a cleartext password and write an appropriately encoded
144
+ version of it into an authentication in the appropriate location. That location is
145
+ ` ~/.irods/.irodsA ` unless the environment variable IRODS_AUTHENTICATION_FILE has been set
146
+ in the command shell to dictate an alternative file path.
150
147
151
- As an example, for the ` native ` authentication scheme, it is simple to create the
152
- .irodsA file directly:
148
+ As an example, here we write a native ` .irodsA ` file using the first of the two functions. We
149
+ provide the one required argument, a password string entered - in this case - interactively at the
150
+ terminal.
153
151
154
152
``` bash
155
- $ echo ' { "irods_user_name":"rods", ... }' > ~ /.irods/irods_environment.json
156
- $ python -c " import irods.client_init, getpass
153
+ bash$ echo ' { "irods_user_name":"rods",
154
+ ... # other parameters as needed
155
+ }' > ~ /.irods/irods_environment.json
156
+ bash$ python -c " import irods.client_init, getpass
157
157
irods.client_init.write_native_irodsA_file(getpass.getpass('Enter iRODS password -> '))"
158
158
```
159
159
160
- If an .irodsA file already exists, it will be overwritten by default; however, if these functions'
161
- overwrite parameter is set to ` False ` , an exception of type ` irods.client_init.irodsA_already_exists `
162
- will be raised to warn of an older .irodsA file that might otherwise be overwritten.
160
+ By default, when an ` .irodsA ` file already exists, it will be overwritten. If however the
161
+ ` overwrite ` parameter is set to ` False ` , an exception of type ` irods.client_init.irodsA_already_exists `
162
+ is raised to warn of any older ` .irodsA ` file that might otherwise have been overwritten.
163
163
164
- Equivalently, we can issue the following command.
164
+ Equivalently to the above , we can issue the following command.
165
165
166
166
``` bash
167
- $ prc_write_irodsA.py native <<< " ${MY_CURRENT_IRODS_PASSWORD}"
167
+ bash $ prc_write_irodsA.py native <<< " ${MY_CURRENT_IRODS_PASSWORD}"
168
168
```
169
169
170
- The redirect may be left off, in which case the user is prompted for the iRODS password
171
- and echo of the keyboard input will be suppressed. (Regardless which technique is used,
172
- no password will be visible on the terminal during or after input.)
170
+ The redirect may of course be left off, in which case the user is prompted for the iRODS password
171
+ and echo of the keyboard input will be suppressed, in the style of ` iinit ` . Regardless
172
+ which technique is used, no password will be visible on the terminal during or after input.
173
173
174
174
For the ` pam_password ` scheme, typically SSL/TLS must first be enabled to avoid sending data related
175
175
to the password - or even sending the raw password itself - over a network connection in the clear.
176
176
177
- Thus, for ` pam_password ` authentication to work well, we should first ensure when setting up the
178
- client environment that the ` irods_environment.json ` file includes the appropriate
179
- SSL/TLS connection parameters. If present, ` iinit ` can be used to verify this condition is fulfilled,
180
- as of course its invocation would create a valid .irodsA from merely prompting the user for their
181
- PAM password
177
+ Thus for ` pam_password ` authentication to work well, we should first ensure, when setting up the
178
+ client environment, to include within ` irods_environment.json ` the appropriate SSL/TLS connection
179
+ parameters. In a pinch, ` iinit ` can be used to verify this prerequisite is fulfilled,
180
+ as its invocation would then create a valid .irodsA from merely prompting the user for their PAM password.
182
181
183
- But if we wish to use the Python client for this purpose instead, we can run :
182
+ Once again, this can also be done either using the free function directly :
184
183
185
184
``` python
186
185
irods.client_init.write_pam_irodsA_file(getpass.getpass(' Enter current PAM password -> ' ))
187
186
```
188
187
189
- Or from the Bash command shell, we simply run :
188
+ or from the Bash command shell:
190
189
191
190
``` bash
192
- $ prc_write_irodsA.py pam_password <<< " ${MY_CURRENT_PAM_PASSWORD}"
191
+ bash $ prc_write_irodsA.py pam_password <<< " ${MY_CURRENT_PAM_PASSWORD}"
193
192
```
194
193
195
- again leaving out the redirection if password prompting is preferable.
196
-
197
- As a final note, in the "pam_password" scheme the default SSL requirement can be disabled (for purposes
198
- of testing only):
194
+ As a final note, in the "pam_password" scheme the default SSL requirement can be disabled (preferably for
195
+ purposes of testing only!):
199
196
200
197
``` python
198
+ from irods.auth.pam_password import ENSURE_SSL_IS_ACTIVE
199
+
201
200
session = irods.session.iRODSSession(host = " localhost" , port = 1247 ,
202
201
user = " alice" , password = " test123" , zone = " tempZone" ,
203
202
authentication_scheme = " pam_password" )
204
203
205
- session.set_auth_option_for_scheme(' pam_password' , irods.auth.pam_password. ENSURE_SSL_IS_ACTIVE , False )
204
+ session.set_auth_option_for_scheme(' pam_password' , ENSURE_SSL_IS_ACTIVE , False )
206
205
207
206
# Do something with the session:
208
207
home = session.collections.get(' /tempZone/home/alice' )
209
208
```
210
209
211
- Note however that in future releases of iRODS it is possible that extra SSL checking could be
212
- implemented server-side, at which point, the above code could not be guaranteed to work.
210
+ Note, however, in future releases of iRODS it is possible that extra SSL checking could be
211
+ implemented server-side, at which point the above code could not be guaranteed to work.
213
212
214
213
Legacy (iRODS 4.2-compatible) PAM authentication
215
214
------------------------------------------------
0 commit comments