Skip to content

Commit 7217777

Browse files
authored
add oauth support (#98)
* added token param for Session * read oauth token from profile * OIDCAuth draft * fixed unit tests read token cache optional [oauth] install * refactored oauth methods into classes * removed oauthlib dependency * ssl verification setting should apply to oauth requests * moved oauth code into Session for testing * doc fix * doc updates fixed error messages * test auth methods * cleanup docstrings and error messages * bugfix * cache tokens * dont cache tokens for password authentication * fix cache read/write * test token caching * mock filesystem calls * fix mocks * mock os.path calls * use packaging module to compare versions * use Session.as_swat() for performance uploads * refresh expired tokens from cache * refresh cassettes
1 parent b96e15b commit 7217777

16 files changed

+1140
-982
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Unreleased
22
----------
3-
-
3+
- `Session` now supports authorization using OAuth2 tokens. Use the `token=` parameter in the constructor when
4+
an existing access token token is known. Alternatively, ommitting the `username=` and `password=` parameters
5+
will now prompt the user for an auth code.
46

57
v1.5.9 (2021-06-09)
68
-------------------

doc/index.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ can be instantiated using simply the hostname:
270270

271271
>>> s = Session(hostname)
272272

273+
If a username and password are not provided, and the SAS Viya server has **not** been configured for Kerberos then
274+
**sasctl** will attempt to connect using OAuth2 authorization codes. In this situation, you may be prompted to open
275+
a URL in your browser, retrieve an authorization code, and then enter it before sasctl can connect.
273276

274277
The final method for supplying credentials is also simple and straight-forward: environment variables.
275278

@@ -278,7 +281,8 @@ The final method for supplying credentials is also simple and straight-forward:
278281
- :envvar:`SASCTL_SERVER_NAME`
279282
- :envvar:`SASCTL_USER_NAME`
280283
- :envvar:`SASCTL_PASSWORD`
281-
284+
- :envvar:`SASCTL_CLIENT_ID`
285+
- :envvar:`SASCTL_CLIENT_SECRET`
282286

283287

284288

@@ -374,6 +378,16 @@ The name of the user that will be used when creating the :class:`.Session` insta
374378

375379
Password for authentication to the SAS Viya server.
376380

381+
.. envvar:: SASCTL_CLIENT_ID
382+
383+
OAuth2 client ID used during authorization.
384+
385+
.. envvar:: SASCTL_CLIENT_SECRET
386+
387+
OAuth2 client secret used during authorization.
388+
389+
390+
377391

378392
Contributor Guide
379393
-----------------

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def get_file(filename):
4747
'scikit-learn',
4848
'requests',
4949
'six >= 1.11',
50+
'pyyaml',
51+
'packaging',
5052
'futures ; python_version <= "2.7"'
5153
],
5254
extras_require={

0 commit comments

Comments
 (0)