Skip to content

Commit 7787bcf

Browse files
working on improving the docs
1 parent 30aa098 commit 7787bcf

39 files changed

+384
-292
lines changed

docs/built-ins.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Built-in Auth Client Profile Injection
2+
3+
TODO: Document how applications may inject built-in auth client profiles for
4+
a smoother application user and developer experience.

docs/changelog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Changelog
22

3-
## 2.1.0 - 2025 TBD
3+
## 2.1.0 - 2025-??-??
44
- Initial public release targeting integration with the
55
[Planet Client for Python](https://github.com/planetlabs/planet-client-python).
66

7-
## [Unreleased: 2.0.*] - YYYY-MM-DD
7+
## [Unreleased: 2.0.*]
88
- All releases in the 2.0.X series are development releases, even if not
99
tagged as such. This work included some shakedowns of the release pipelines.

docs/configuration.md

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ AuthClient Configuration dictionaries may either be provided directly, or loaded
99
from disk when saved in a `Profile` (See below).
1010

1111
While it is possible to work directly with the lower level implementation
12-
classes, it is generally simpler to use the higher level management code in
13-
[planet_auth.Auth][], or the factory methods in [planet_auth.AuthClient][]
14-
and [planet_auth.AuthClientConfig][] to configure and instantiate instances.
15-
Directly using the lower level implementations should not be necessary in
16-
most cases.
12+
classes, it is generally simpler to organize the working set of objects
13+
with an [Auth Context][planet_auth.Auth] instance created from one of the
14+
factory methods in [planet_auth_utils.PlanetAuthFactory][]
1715

1816
A number of auth client implementations are provided. Clients should
1917
select the one most appropriate for their use case.
@@ -28,19 +26,13 @@ Configuration:
2826

2927
Profile Usage:
3028
```python linenums="1"
31-
from planet_auth import Auth
32-
33-
auth_ctx = Auth.initialize_from_profile(profile="_profile_name_")
29+
{% include 'snippets/auth-client-context-from-saved-profile.py' %}
3430
```
3531

3632

3733
Direct Usage:
3834
```python linenums="1"
39-
from planet_auth import Auth
40-
auth_ctx = Auth.initialize_from_config_dict(
41-
client_config={ ... content of auth_client.json ... },
42-
token_file="/my_token_file.json"
43-
)
35+
{% include 'snippets/auth-client-context-pl-legacy-direct.py' %}
4436
```
4537

4638
### OAuth Clients
@@ -54,18 +46,16 @@ Configuration:
5446

5547
Profile Usage:
5648
```python linenums="1"
49+
{% include 'snippets/auth-client-context-from-saved-profile.py' %}
50+
5751
from planet_auth import Auth
5852

5953
auth_ctx = Auth.initialize_from_profile(profile="_profile_name_")
6054
```
6155

6256
Direct Usage:
6357
```python linenums="1"
64-
from planet_auth import Auth
65-
auth_ctx = Auth.initialize_from_config_dict(
66-
client_config={ ... content of auth_client.json ... },
67-
token_file="/my_token_file.json"
68-
)
58+
{% include 'snippets/auth-client-context-oauth-direct.py' %}
6959
```
7060

7161
#### Auth Code with PKCE and Client Public Key

docs/examples-cli.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CLI Examples
2+
3+
## Embedding the `plauth` Command in Another `click` Program
4+
It is possible to embed the [`plauth`](/cli-plauth) command into other programs to
5+
present a unified experience that leverages the [planet_auth](/api)
6+
package for client authentication plumbing. This is done by using
7+
a special version of the command that is configured for embedding.
8+
9+
When using the embedded version of the command, the outer application
10+
must take on the responsibility of instantiating the auth context and
11+
handling command line options so that this context may be available
12+
to click commands that are outside the `plauth` root command.
13+
14+
```python linenums="1"
15+
{% include 'cli/embed-plauth-click.py' %}
16+
```

docs/examples-client.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Client Examples
2+
Client examples cover scenarios in which a program wishes to use
3+
the planet auth utilities as a client, obtaining credentials
4+
from authentication services so that they may be used to
5+
make authenticated requests to other network services.
6+
7+
## OAuth Client Authentication
8+
A custom auth client profile may be used to configure the AuthClient
9+
to use an arbitrary OAuth2 auth service to obtain access tokens for
10+
use with application APIs.
11+
See [Configuration and Profiles](/configuration) for more information
12+
on client types and profiles.
13+
14+
1. Create a `~/.planet/<profile_name>/auth_client.json` or `~/.planet/<profile_name>/auth_client.sops.json` file.
15+
For example, to create a custom profile named "my-custom-profile", create the following:
16+
```json linenums="1" title="~/.planet/my-custom-profile/auth_client.json"
17+
{% include 'auth-client-config/oauth-auth-code-grant-public-client.json' %}
18+
```
19+
2. Initialize the client library with the specified profile. Note: if the environment variable
20+
`PL_AUTH_PROFILE` is set, it will be detected automatically by [planet_auth_utils.PlanetAuthFactory][],
21+
and it will not be necessary to explicitly pass in the profile name:
22+
```python linenums="1"
23+
{% include 'auth-client/oauth/initialize-client-lib-on-disk-profile.py' %}
24+
```
25+
An alternative to creating a file on disk is to initialize_from_profile a client
26+
purely in memory. For some runtime environments where local storage may
27+
not be available or trusted, this may be more appropriate:
28+
```python linenums="1"
29+
{% include 'auth-client/oauth/initialize-client-lib-in-memory.py' %}
30+
```
31+
3. Perform initial login to obtain and save long term credentials, if required
32+
by the configured profile. An initial login is usually required for auth
33+
clients that act on behalf of a user and need to perform an interactive login.
34+
Clients configured for service operation may frequently skip this step:
35+
```python linenums="1"
36+
{% include 'auth-client/oauth/perform-oauth-initial-login.py' %}
37+
```
38+
4. Make authenticated requests:
39+
* Option 1 - Using `requests`:
40+
```python linenums="1"
41+
{% include 'auth-client/oauth/make-oauth-authenticated-requests-request.py' %}
42+
```
43+
* Option 2 - Using `httpx`:
44+
```python linenums="1"
45+
{% include 'auth-client/oauth/make-oauth-authenticated-httpx-request.py' %}
46+
```
47+
48+
## Performing a Device Login
49+
The procedure for performing initial user login on a UI limited device
50+
is slightly different. Rather than simply calling `login()`, it is necessary
51+
to initiate the process with a call to `device_login_initiate()`, display the
52+
returned information to the user so that the user may authorize the client
53+
asynchronously, and complete the process by calling `device_login_complete()`.
54+
This procedure only applies to clients that are permitted to use the
55+
Device Authorization OAuth flow.
56+
57+
```python linenums="1"
58+
{% include 'auth-client/oauth/perform-oauth-device-login.py' %}
59+
```
60+
61+
## Planet Legacy Authentication
62+
The proprietary Planet legacy authentication protocol is targeted for future
63+
deprecation. It should not be used for any new development.
64+
65+
### Initial Login
66+
```python linenums="1"
67+
{% include 'auth-client/planet-legacy/perform-legacy-initial-login.py' %}
68+
```
69+
70+
### Authenticated `requests` Call
71+
```python linenums="1"
72+
{% include 'auth-client/planet-legacy/make-legacy-authenticated-requests-request.py' %}
73+
```

docs/examples-installation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Installation
2+
3+
## Install from _PyPI.org_ using `pip`
4+
Install the required modules:
5+
```shell
6+
pip install planet-auth
7+
```

docs/examples-service.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Service Examples
2+
Service examples cover scenarios in which a program wishes to use
3+
the planet auth utilities as a service, verifying the authenticity
4+
of access credentials presented to the service by a client.
5+
6+
It should be noted that Services may also act as clients when making
7+
calls to other services. When a service is acting in such a capacity,
8+
the [Client Examples](./examples-client.md) apply.
9+
When the service is acting on behalf of itself, it is likely that
10+
a [OAuth2 Client Credentials](./configuration.md#client-credentials-with-client-secret)
11+
configuration applies.
12+
13+
When a service is acting on behalf of one of its clients...
14+
(TODO: cover this.)
15+
16+
## Verifying OAuth Clients
17+
The [planet_auth.OidcMultiIssuerValidator][] class is provided to assist with
18+
common OAuth client authentication scenarios. This class can be configured
19+
with a single authority for normal operations, and may optionally be configured
20+
with a secondary authorities. This allows for complex deployments such as
21+
the seamless migration between auth servers over time.
22+
23+
This utility class may be configured for entirely local token validation,
24+
or may be configured to check token validity against the OAuth token inspection
25+
endpoint. For most operations, local validation is expected to be used, as
26+
it is more performant, not needing to make blocking network calls, and more
27+
robust, not depending on external service availability. For high value operations,
28+
remote validation may be performed which checks whether the specific access
29+
token has been revoked.
30+
31+
Tokens are normally not long-lived. Token lifespans should be selected to
32+
strike a balance between security concerns and allow frequent use of local
33+
validation, and not overburden the token inspection endpoint.
34+
35+
Checking tokens against the OAuth token inspection endpoint does require the
36+
use of OAuth clients that are authorized to use the endpoint, and may not
37+
be available to anonymous clients, depending on the auth server configuration.
38+
39+
### Local Access Token Validation
40+
```python linenums="1" title="Basic usage of OidcMultiIssuerValidator. Validate access tokens locally."
41+
{% include 'service/flask--oidc-multi-issuer--local-only-validation.py' %}
42+
```
43+
44+
### Local and Remote Access Token Validation
45+
```python linenums="1" title="Advanced usage of OidcMultiIssuerValidator. Validate access tokens against OAuth inspection endpoints using custom auth clients."
46+
{% include 'service/flask--oidc-multi-issuer--local-and-remote-validation.py' %}
47+
```
48+
49+
## Verifying Planet Legacy Client
50+
This is not supported by this library.

docs/examples.md

Lines changed: 0 additions & 145 deletions
This file was deleted.

docs/examples/auth-client-config/oauth-auth-code-grant-confidential-client-pubkey.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"client_type": "oidc_auth_code_pubkey",
3-
"auth_server": "https://account.planet.com/oauth2/aus2enhwueFYRb50S4x7",
3+
"auth_server": "https://login.planet.com/",
44
"client_id": "your_client_id",
55
"client_privkey": "__private_key_literal_PEM__",
66
"client_privkey_file": "__path_to_private_key_PEM_file__",

docs/examples/auth-client-config/oauth-auth-code-grant-confidential-client-secret.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"client_type": "oidc_auth_code_secret",
3-
"auth_server": "https://account.planet.com/oauth2/aus2enhwueFYRb50S4x7",
3+
"auth_server": "https://login.planet.com/",
44
"client_id": "your_client_id",
55
"client_secret": "your_client_secret",
66
"redirect_uri": "your_client_redirect_url__if_needed",

docs/examples/auth-client-config/oauth-auth-code-grant-public-client.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"client_type": "oidc_auth_code",
3-
"auth_server": "https://account.planet.com/oauth2/aus2enhwueFYRb50S4x7",
3+
"auth_server": "https://login.planet.com/",
44
"client_id": "your_client_id",
55
"redirect_uri": "client_redirect_url_for_network_hosted_handler__if_needed",
66
"local_redirect_uri": "client_redirect_url_for_localhost_handler__if_needed",

0 commit comments

Comments
 (0)