@@ -36,16 +36,63 @@ Other endpoints we hope to add in the near future:
3636
3737You can use pip to install cert_manager:
3838
39- ``` Shell
39+ ``` shell
4040pip install cert_manager
4141```
4242
43+ ## Authentication
44+
45+ Originally, Certificate Manager only allowed username and password, or client
46+ certificate and key as methods of authenticating to the REST API. However,
47+ OAuth2 is now supported via a completely different URL structure. This new model
48+ can be used by swapping out the ` Client ` class with ` OAuth2Client ` . You need to
49+ provide a Client ID and Client Secret to ` OAuth2Client ` , which you create via
50+ the UI in [ Sectigo] [ 2 ] . Information on how to create the Client ID and Client
51+ Secret can be found on
52+ [ How Do You Implement OAuth 2.0 for SCM] ( https://www.sectigo.com/knowledge-base/detail/implement-oauth-2-0-for-scm )
53+ page.
54+
55+ The following is an example of creating the ` OAuth2Client ` object:
56+
57+ ``` python
58+ from cert_manager import OAuth2Client
59+ client = OAuth2Client(
60+ client_id = " client-id-from-sectigo" , client_secret = " client-secret-from-sectigo" ,
61+ )
62+ ```
63+
64+ This client should then be usable by all of the existing classes in the library
65+ in place of the original. However, pay particular attention to the version of
66+ the API you are using for each class. Typically the version is ` v1 ` , but there
67+ isn't a consistent version across all endpoints. You may need to add
68+ ` api_version ` to many of the object instantiations for the API to work
69+ correctly. A complete API reference can be found on the
70+ [ SCM DevX] ( https://scm.devx.sectigo.com/reference/ ) site. This, for example, is
71+ the first code snippet in [ Examples] ( #examples ) rewritten for the new API
72+ infrastructure:
73+
74+ ``` python
75+ from cert_manager import Organization
76+ from cert_manager import OAuth2Client
77+ from cert_manager import SSL
78+
79+ client = OAuth2Client(
80+ client_id = " client-id-from-sectigo" , client_secret = " client-secret-from-sectigo" ,
81+ )
82+
83+ org = Organization(client = client)
84+ ssl = SSL(client = client, api_version = " v2" )
85+
86+ print (ssl.types)
87+ print (org.all())
88+ ```
89+
4390## Examples
4491
4592This is a simple example that just shows initializing the ` Client ` object and
4693using it to query the ` Organization ` and ` SSL ` endpoints:
4794
48- ``` Python
95+ ``` python
4996from cert_manager import Organization
5097from cert_manager import Client
5198from cert_manager import SSL
@@ -67,7 +114,7 @@ print(org.all())
67114The most common process you would do, however, is enroll and then collect a
68115certificate you want to order from the Certificate Manager:
69116
70- ``` Python
117+ ``` python
71118from time import sleep
72119
73120from cert_manager import Organization
@@ -128,7 +175,7 @@ To start a development environment, you should be able to just run the
128175to build a [ Docker] [ 4 ] container with all the dependencies for development
129176installed using [ Poetry] [ 3 ] .
130177
131- ``` Shell
178+ ``` shell
132179./dev.bash
133180```
134181
@@ -147,7 +194,7 @@ access token. We currently use
147194for this purpose. The following should generate the file using information from
148195GitHub:
149196
150- ``` Shell
197+ ``` shell
151198docker run -it --rm \
152199 -e CHANGELOG_GITHUB_TOKEN=' yourtokenhere' \
153200 -v " $( pwd) " :/working \
@@ -158,7 +205,7 @@ docker run -it --rm \
158205To generate the log for an upcoming release that has not yet been tagged, you
159206can run a command to include the upcoming release version. For example, ` 2.0.0 ` :
160207
161- ``` Shell
208+ ``` shell
162209docker run -it --rm \
163210 -e CHANGELOG_GITHUB_TOKEN=' yourtokenhere' \
164211 -v " $( pwd) " :/working \
@@ -179,14 +226,14 @@ version bumps as part of a PR, so you don't want to have [bump2version][6] tag
179226the version at the same time it does the commit as commit hashes may change.
180227Therefore, to bump the version a patch level, one would run the command:
181228
182- ``` Shell
229+ ``` shell
183230bump2version --verbose --no-tag patch
184231```
185232
186233Once the PR is merged, you can then checkout the new ` main ` branch and tag it
187234using the new version number that is now in ` .bumpversion.cfg ` :
188235
189- ``` Shell
236+ ``` shell
190237git checkout main
191238git pull --rebase
192239git tag 1.0.0 -m ' Bump version: 0.1.0 → 1.0.0'
0 commit comments