Skip to content

Commit a840234

Browse files
authored
docs(user-guide): Add route-level auth user guide (#80)
1 parent 5f00eca commit a840234

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ The application is configurable via environment variables.
111111
**Required:** No, defaults to the following:
112112
```json
113113
{
114+
"^/$": ["GET"],
114115
"^/api.html$": ["GET"],
115116
"^/api$": ["GET"],
116117
"^/docs/oauth2-redirect": ["GET"],

docs/user-guide/route-level-auth.md

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Route-Level Auth
2+
3+
Route-level authentication and authorization can provide a base layer of security for the simplest use cases. This typically looks like:
4+
5+
- the entire catalog being private, available only to authenticated users
6+
- most of the catalog being public, available to anonymous or authenticated users. However, a subset of endpoints (typically the [transactions extension](https://github.com/stac-api-extensions/transaction) endpoints) are only available to all or a subset of authenticated users
7+
8+
## Configuration Variables
9+
10+
Route-level authentication is controlled by three key environment variables:
11+
12+
- **[`DEFAULT_PUBLIC`](../../configuration/#default_public)**: Sets the default access policy for all endpoints
13+
- **[`PUBLIC_ENDPOINTS`](../../configuration/#public_endpoints)**: Marks endpoints as not requiring authentication (used only when `DEFAULT_PUBLIC=false`). By default, we keep the catalog root, OpenAPI spec, Swagger UI, Swagger UI auth redirect, and the proxy health endpoint as public. Note that these are all endpoints that don't serve actual STAC data; they only acknowledge the presence of a STAC catalog. This is defined by a mapping of regex path expressions to arrays of HTTP methods.
14+
- **[`PRIVATE_ENDPOINTS`](../../configuration/#private_endpoints)**: Marks endpoints as requiring authentication. By default, the transactions endpoints are all marked as private. This is defined by a mapping of regex path expressions to arrays of either HTTP methods or tuples of HTTP methods and space-separated required scopes.
15+
16+
> [!TIP]
17+
>
18+
> Users typically don't need to specify both `PRIVATE_ENDPOINTS` and `PUBLIC_ENDPOINTS`.
19+
20+
## Strategies
21+
22+
### Private by Default
23+
24+
Make the entire STAC API private, requiring authentication for all endpoints.
25+
26+
> [!NOTE]
27+
>
28+
> This is the out-of-the-box configuration of the STAC Auth Proxy.
29+
30+
**Configuration**
31+
32+
```bash
33+
# Set default policy to private
34+
DEFAULT_PUBLIC=false
35+
36+
# The default public endpoints are typically sufficient. Otherwise, they can be specified.
37+
# PUBLIC_ENDPOINTS='{ ... }'
38+
```
39+
40+
**Behavior**
41+
42+
- All endpoints require authentication by default
43+
- Only explicitly listed endpoints in `PUBLIC_ENDPOINTS` are accessible without authentication. By default, these are endpoints that don't reveal STAC data
44+
- Useful for internal or enterprise STAC APIs where all data should be protected
45+
46+
### Public by Default with Protected Write Operations
47+
48+
Make the STAC API mostly public for read operations, but require authentication for write operations (transactions extension).
49+
50+
**Configuration**
51+
52+
```bash
53+
# Set default policy to public
54+
DEFAULT_PUBLIC=true
55+
56+
# The default private endpoints are typically sufficient. Otherwise, they can be specified.
57+
# PRIVATE_ENDPOINTS='{ ... }'
58+
```
59+
60+
**Behavior**
61+
62+
- Read operations (GET requests) are accessible to everyone
63+
- Write operations require authentication
64+
- Default configuration matches this pattern
65+
- Ideal for public STAC catalogs where data discovery is open but modifications are restricted
66+
67+
### Authenticated Access with Scope-based Authorization
68+
69+
For a level of control beyond simple anonymous vs. authenticated status, the proxy can be configured so that path/method access requires JWTs containing particular permissions in the form of the [scopes claim](https://datatracker.ietf.org/doc/html/rfc8693#name-scope-scopes-claim).
70+
71+
**Configuration**
72+
73+
For granular permissions on a public API:
74+
75+
```bash
76+
# Set default policy to public
77+
DEFAULT_PUBLIC=true
78+
79+
# Require specific scopes for write operations
80+
PRIVATE_ENDPOINTS='{
81+
"^/collections$": [["POST", "collection:create"]],
82+
"^/collections/([^/]+)$": [["PUT", "collection:update"], ["PATCH", "collection:update"], ["DELETE", "collection:delete"]],
83+
"^/collections/([^/]+)/items$": [["POST", "item:create"]],
84+
"^/collections/([^/]+)/items/([^/]+)$": [["PUT", "item:update"], ["PATCH", "item:update"], ["DELETE", "item:delete"]],
85+
"^/collections/([^/]+)/bulk_items$": [["POST", "item:create"]]
86+
}'
87+
```
88+
89+
For role-based permissions on a private API:
90+
91+
```bash
92+
# Set default policy to private
93+
DEFAULT_PUBLIC=false
94+
95+
# Require specific scopes for write operations
96+
PRIVATE_ENDPOINTS='{
97+
"^/collections$": [["POST", "admin"]],
98+
"^/collections/([^/]+)$": [["PUT", "admin"], ["PATCH", "admin"], ["DELETE", "admin"]],
99+
"^/collections/([^/]+)/items$": [["POST", "editor"]],
100+
"^/collections/([^/]+)/items/([^/]+)$": [["PUT", "editor"], ["PATCH", "editor"], ["DELETE", "editor"]],
101+
"^/collections/([^/]+)/bulk_items$": [["POST", "editor"]]
102+
}'
103+
```
104+
105+
**Behavior**
106+
107+
- Users must be authenticated AND have the required scope(s)
108+
- Different HTTP methods can require different scopes
109+
- Scopes are checked against the user's JWT scope claim
110+
- Unauthorized requests receive a 403 Forbidden response
111+
112+
> [!TIP]
113+
>
114+
> Multiple scopes can be provided in a space-separated format, such as `["POST", "scope_a scope_b scope_c"]`. These scope requirements are applied with AND logic, meaning that the incoming JWT must contain all the mentioned scopes.

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ nav:
3131
- Overview: index.md
3232
- Installation and Running: installation-and-running.md
3333
- Configuration: configuration.md
34+
- User Guide:
35+
- Route-Level Auth: user-guide/route-level-auth.md
3436
- Architecture:
3537
- Middleware Stack: architecture/middleware-stack.md
3638
- Data Filtering: architecture/data-filtering.md

0 commit comments

Comments
 (0)