Skip to content

Commit 7794a0f

Browse files
authored
Merge pull request #149 from bkemper24/main
update Authentication documentation
2 parents da8fd5b + 8b08c1e commit 7794a0f

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

doc/source/getting-started.rst

100644100755
Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,19 @@ close it.
236236
Authentication
237237
==============
238238

239+
The SWAT package supports three types of authentication when connecting to the CAS server:
240+
241+
- Userid and Password
242+
- OAuth token
243+
- Kerberos ( binary protocol only )
244+
245+
Userid and Password
246+
~~~~~~~~~~~~~~~~~~~~~
247+
239248
While it is possible to put your username and password in the :class:`CAS` constructor,
240249
it's generally not a good idea to have a password in your code. To get around this issue,
241-
the :class:`CAS` class supports authinfo files. Authinfo files are a a file used to
242-
store username and password information for specified hostname and port. They are
250+
the :class:`CAS` class supports authinfo files. Authinfo files are a file used to
251+
store username and password information for specified hostname and port. They are
243252
protected by file permissions so that only you can read them. This allows you to set
244253
and protect your passwords in one place and have them used by all of your programs.
245254

@@ -256,7 +265,7 @@ Hostnames much match the hostname used in the :class:`CAS` constructor exactly.
256265
not do any DNS expanding of the names. So 'host1' and 'host1.my-company.com' are
257266
considered two different hosts.
258267

259-
Here is an exmaple for a user named 'user01' and password '!s3cret' on host
268+
Here is an example for a user named 'user01' and password '!s3cret' on host
260269
'cas.my-company.com' and port 12354::
261270

262271
host cas.my-company.com port 12354 user user01 password !s3cret
@@ -283,3 +292,71 @@ of a file explicitly using the ``authinfo=`` parameter.
283292
:suppress:
284293
285294
conn.close()
295+
296+
The username can also be specified using one of the following environment variables
297+
298+
- CAS_USER
299+
- CAS_USERNAME
300+
- CASUSER
301+
- CASUSERNAME
302+
303+
The password can be specified using one of the following environment variables
304+
305+
- CAS_TOKEN
306+
- CAS_PASSWORD
307+
- CASTOKEN
308+
- CASPASSWORD
309+
310+
.. note:: Userid and Password authentication will be deprecated in a future release.
311+
OAuth authentication should be used instead when possible.
312+
313+
OAuth Token
314+
~~~~~~~~~~~~~~~~~~~~~
315+
316+
Authentication to the CAS server can be performed by using an OAuth token.
317+
The OAuth token can be specified in the :class:`CAS` constructor using the password parameter.
318+
When specifying the OAuth token in the :class:`CAS` constructor, do not specify the username parameter.
319+
320+
.. ipython:: python
321+
:verbatim:
322+
323+
conn = swat.CAS('cas.my-company.com', 12354, password='...')
324+
325+
The OAuth token can also be specified using one of the following environment variables
326+
327+
- CAS_TOKEN
328+
- CAS_PASSWORD
329+
- CASTOKEN
330+
- CASPASSWORD
331+
332+
When using the HTTP protocol, the SWAT package can obtain an OAuth token on your behalf by
333+
specifying an authentication code in the :class:`CAS` constructor using the authcode parameter.
334+
335+
.. ipython:: python
336+
:verbatim:
337+
338+
conn = swat.CAS('https://my-cas-host.com:443/cas-shared-default-http/',
339+
authcode='...')
340+
341+
The authentication code can also be specified using one of the following environment variables
342+
343+
- CAS_AUTHCODE
344+
- VIYA_AUTHCODE
345+
- CASAUTHCODE
346+
- VIYAAUTHCODE
347+
348+
Kerberos
349+
~~~~~~~~~~~~~~~~~~~~~
350+
351+
The Kerberos Service Principal Name used by Viya 4 is different from the Kerberos Service Principal
352+
Name used by Viya 3.5.
353+
Releases of the SWAT package starting with 1.8.0 and later use the Viya 4 Service Principal Name.
354+
If you wish to connect to a Viya 3.5 CAS server using the SWAT package release 1.8.0 or later,
355+
you must use the CASSPN environment variable to specify the service principal name in the format
356+
recognized by Viya 3.5 . This value should start with 'sascas@' and be followed by the hostname.
357+
358+
.. ipython:: python
359+
:verbatim:
360+
361+
import os
362+
os.environ["CASSPN"] = "sascas@host"

0 commit comments

Comments
 (0)