Skip to content

Commit e9754fc

Browse files
committed
feat: Update README
1 parent 6e5f8a1 commit e9754fc

1 file changed

Lines changed: 55 additions & 8 deletions

File tree

docs/README.md

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,63 @@ Other endpoints we hope to add in the near future:
3636

3737
You can use pip to install cert_manager:
3838

39-
```Shell
39+
```shell
4040
pip 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

4592
This is a simple example that just shows initializing the `Client` object and
4693
using it to query the `Organization` and `SSL` endpoints:
4794

48-
```Python
95+
```python
4996
from cert_manager import Organization
5097
from cert_manager import Client
5198
from cert_manager import SSL
@@ -67,7 +114,7 @@ print(org.all())
67114
The most common process you would do, however, is enroll and then collect a
68115
certificate you want to order from the Certificate Manager:
69116

70-
```Python
117+
```python
71118
from time import sleep
72119

73120
from cert_manager import Organization
@@ -128,7 +175,7 @@ To start a development environment, you should be able to just run the
128175
to build a [Docker][4] container with all the dependencies for development
129176
installed using [Poetry][3].
130177

131-
```Shell
178+
```shell
132179
./dev.bash
133180
```
134181

@@ -147,7 +194,7 @@ access token. We currently use
147194
for this purpose. The following should generate the file using information from
148195
GitHub:
149196

150-
```Shell
197+
```shell
151198
docker run -it --rm \
152199
-e CHANGELOG_GITHUB_TOKEN='yourtokenhere' \
153200
-v "$(pwd)":/working \
@@ -158,7 +205,7 @@ docker run -it --rm \
158205
To generate the log for an upcoming release that has not yet been tagged, you
159206
can run a command to include the upcoming release version. For example, `2.0.0`:
160207

161-
```Shell
208+
```shell
162209
docker 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
179226
the version at the same time it does the commit as commit hashes may change.
180227
Therefore, to bump the version a patch level, one would run the command:
181228

182-
```Shell
229+
```shell
183230
bump2version --verbose --no-tag patch
184231
```
185232

186233
Once the PR is merged, you can then checkout the new `main` branch and tag it
187234
using the new version number that is now in `.bumpversion.cfg`:
188235

189-
```Shell
236+
```shell
190237
git checkout main
191238
git pull --rebase
192239
git tag 1.0.0 -m 'Bump version: 0.1.0 → 1.0.0'

0 commit comments

Comments
 (0)