Skip to content

Commit e253747

Browse files
authored
Merge pull request #60 from liquidz00/cred-providers
Credential Providers Refactoring
2 parents cbb641a + 57a3d40 commit e253747

File tree

13 files changed

+418
-155
lines changed

13 files changed

+418
-155
lines changed

.github/workflows/main_pr_tests.yaml

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ jobs:
3434
- name: Tests
3535
run: make test
3636

37-
exp-integration-tests:
38-
continue-on-error: true
39-
runs-on: ubuntu-latest
40-
steps:
41-
- name: Checkout
42-
uses: actions/checkout@v3
43-
44-
- name: Setup Python
45-
uses: actions/setup-python@v4
46-
with:
47-
python-version: '3.9'
48-
cache: 'pip'
49-
50-
- name: Install
51-
run: make install
52-
53-
- name: Run Integration Tests
54-
run: make test-all
55-
env:
56-
JAMF_PRO_HOST: ${{ vars.JAMF_PRO_HOST }}
57-
JAMF_PRO_CLIENT_ID: ${{ vars.JAMF_PRO_CLIENT_ID }}
58-
JAMF_PRO_CLIENT_SECRET: ${{ vars.JAMF_PRO_CLIENT_SECRET }}
37+
# exp-integration-tests:
38+
# continue-on-error: true
39+
# runs-on: ubuntu-latest
40+
# steps:
41+
# - name: Checkout
42+
# uses: actions/checkout@v3
43+
44+
# - name: Setup Python
45+
# uses: actions/setup-python@v4
46+
# with:
47+
# python-version: '3.9'
48+
# cache: 'pip'
49+
50+
# - name: Install
51+
# run: make install
52+
53+
# - name: Run Integration Tests
54+
# run: make test-all
55+
# env:
56+
# JAMF_PRO_HOST: ${{ vars.JAMF_PRO_HOST }}
57+
# JAMF_PRO_CLIENT_ID: ${{ vars.JAMF_PRO_CLIENT_ID }}
58+
# JAMF_PRO_CLIENT_SECRET: ${{ vars.JAMF_PRO_CLIENT_SECRET }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
A client library for the Jamf Pro APIs and webhooks.
44

55
```python
6-
from jamf_pro_sdk import JamfProClient, BasicAuthProvider
6+
from jamf_pro_sdk import JamfProClient, ApiClientCredentialsProvider
77

88
client = JamfProClient(
99
server="dummy.jamfcloud.com",
10-
credentials=BasicAuthProvider("username", "password")
10+
credentials=ApiClientCredentialsProvider("client_id", "client_secret")
1111
)
1212

1313
all_computers = client.pro_api.get_computer_inventory_v1()

docs/_static/api-keychain.png

35.7 KB
Loading

docs/_static/user-keychain.png

34.7 KB
Loading

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
pygments_style = "default"
5757
pygments_dark_style = "material"
5858

59-
# html_static_path = ["_static"]
59+
html_static_path = ["_static"]
6060

6161
html_theme = "furo"
6262

docs/reference/credentials.rst

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,43 @@
33
Credentials Providers
44
=====================
55

6-
API Client Providers
7-
--------------------
6+
The Jamf Pro SDK has two primary types of credential providers: **API Client Credentials** and **User Credentials**.
87

9-
These credentials providers use Jamf Pro API clients for API authentication.
8+
API Client Credentials Provider
9+
-------------------------------
10+
11+
Use Jamf Pro `API clients <https://developer.jamf.com/jamf-pro/docs/client-credentials>`_ for API authentication.
1012

1113
.. autoclass:: jamf_pro_sdk.clients.auth.ApiClientCredentialsProvider
1214
:members:
1315

14-
Basic Auth Providers
15-
--------------------
16+
User Credentials Provider
17+
-------------------------
1618

17-
These credentials providers use a username and password for API authentication.
19+
User credential providers use a username and password for API authentication.
1820

19-
.. autoclass:: jamf_pro_sdk.clients.auth.BasicAuthProvider
21+
.. autoclass:: jamf_pro_sdk.clients.auth.UserCredentialsProvider
2022
:members:
2123

22-
.. autoclass:: jamf_pro_sdk.clients.auth.PromptForCredentials
23-
:members:
24+
Utilities for Credential Providers
25+
----------------------------------
2426

25-
.. autoclass:: jamf_pro_sdk.clients.auth.LoadFromKeychain
26-
:members:
27+
These functions return an instantiated credentials provider of the specified type.
2728

28-
.. autoclass:: jamf_pro_sdk.clients.auth.LoadFromAwsSecretsManager
29-
:members:
29+
Prompt for Credentials
30+
^^^^^^^^^^^^^^^^^^^^^^
31+
32+
.. autofunction:: jamf_pro_sdk.clients.auth.prompt_for_credentials
33+
34+
Load from AWS Secrets Manager
35+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
36+
37+
.. autofunction:: jamf_pro_sdk.clients.auth.load_from_aws_secrets_manager
38+
39+
Load from Keychain
40+
^^^^^^^^^^^^^^^^^^
41+
42+
.. autofunction:: jamf_pro_sdk.clients.auth.load_from_keychain
3043

3144
Access Token
3245
------------

docs/user/advanced.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ A :class:`~jamf_pro_sdk.clients.auth.CredentialsProvider` is an interface for th
88

99
The following example does not accept a username or password and retrieves a token from a DynamoDB table in an AWS account (it is assumed an external process is managing this table entry).
1010

11+
.. code-block:: python
12+
1113
>>> import boto3
1214
>>> from jamf_pro_sdk.clients.auth import CredentialsProvider
1315
>>> from jamf_pro_sdk.models.client import AccessToken
@@ -35,13 +37,17 @@ The SDK's clients provide curated methods to a large number of Jamf Pro APIs. No
3537

3638
Here is the built-in method for getting a computer from the Classic API:
3739

40+
.. code-block:: python
41+
3842
>>> computer = client.classic_api.get_computer_by_id(1)
3943
>>> type(computer)
4044
<class 'jamf_pro_sdk.models.classic.computers.Computer'>
4145
>>>
4246
4347
The same operation can be performed by using the :meth:`~jamf_pro_sdk.clients.JamfProClient.classic_api_request` method directly:
4448

49+
.. code-block:: python
50+
4551
>>> response = client.classic_api_request(method='get', resource_path='computers/id/1')
4652
>>> type(response)
4753
<class 'requests.models.Response'>
@@ -59,12 +65,12 @@ Here is a code example using :meth:`~jamf_pro_sdk.clients.JamfProClient.concurre
5965

6066
.. code-block:: python
6167
62-
from jamf_pro_sdk import JamfProClient, BasicAuthProvider
68+
from jamf_pro_sdk import JamfProClient, ApiClientCredentialsProvider
6369
6470
# The default concurrency setting is 10.
6571
client = JamfProClient(
6672
server="jamf.my.org",
67-
credentials=BasicAuthProvider("oscar", "j@mf1234!")
73+
credentials=ApiClientCredentialsProvider("client_id", "client_secret")
6874
)
6975
7076
# Get a list of all computers, and then their IDs.

docs/user/classic_api.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ Assume this client has been instantiated for the examples shown below.
114114
115115
.. code-block:: python
116116
117-
>>> from jamf_pro_sdk import JamfProClient, BasicAuthProvider
117+
>>> from jamf_pro_sdk import JamfProClient, ApiClientCredentialsProvider
118118
>>> client = JamfProClient(
119119
... server="jamf.my.org",
120-
... credentials=BasicAuthProvider("oscar", "j@mf1234!")
120+
... credentials=ApiClientCredentialsProvider("client_id", "client_secret")
121121
... )
122122
>>>
123123

0 commit comments

Comments
 (0)