Skip to content

Commit df55e35

Browse files
committed
Improved stac-auth-proxy docs.
1 parent 4b37dc4 commit df55e35

File tree

2 files changed

+78
-157
lines changed

2 files changed

+78
-157
lines changed

charts/eoapi/values.yaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -424,32 +424,36 @@ stac-auth-proxy:
424424
resources: {}
425425
env:
426426
# OIDC_DISCOVERY_URL must be configured when enabling auth (required)
427+
# UPSTREAM_URL must be set to "http://<release-name>-stac:8080" (required)
427428
ROOT_PATH: "/stac"
428429
OVERRIDE_HOST: "false"
429-
# UPSTREAM_URL will be set dynamically in template to point to stac service
430430
#
431431
# Authentication filters settings:
432432
DEFAULT_PUBLIC: "true" # This enables standard profile for authentication filters
433-
# Alternatively with the following settings custom filters can be added
434-
# These must be mounted with extraVolumes/extraVolumeMounts (see below)
433+
#
434+
# To use custom filters, ALL THREE of the following are required:
435+
# 1. Set filter class environment variables (uncomment lines below)
436+
# 2. Set customFiltersFile path (see below)
437+
# 3. Configure extraVolumes and extraVolumeMounts (see below)
438+
#
435439
# COLLECTIONS_FILTER_CLS: stac_auth_proxy.custom_filters:CollectionsFilter
436440
# ITEMS_FILTER_CLS: stac_auth_proxy.custom_filters:ItemsFilter
437441

438442
# Path to custom filters file (relative to chart root)
439-
# When extraVolumes is configured, a ConfigMap will be created from this file
443+
# Creates a ConfigMap from this file - required for custom filters
440444
# customFiltersFile: "data/stac-auth-proxy/custom_filters.py"
441445

442-
# Additional volumes to mount (e.g., for custom filter files)
446+
# Volume referencing the ConfigMap - required for custom filters
443447
extraVolumes: []
444-
# Example:
448+
# Example (required for custom filters):
445449
# extraVolumes:
446450
# - name: filters
447451
# configMap:
448452
# name: stac-auth-proxy-filters
449-
#
450-
# Additional volume mounts for the container
453+
454+
# Volume mount making filters available to container - required for custom filters
451455
extraVolumeMounts: []
452-
# Example:
456+
# Example (required for custom filters):
453457
# extraVolumeMounts:
454458
# - name: filters
455459
# mountPath: /app/src/stac_auth_proxy/custom_filters.py

docs/stac-auth-proxy.md

Lines changed: 65 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -10,191 +10,108 @@ external_links:
1010

1111
# STAC Auth Proxy
1212

13-
## Solution Overview
13+
## Overview
1414

15-
We have implemented support for STAC Auth Proxy integration with eoAPI-K8S through service-specific ingress control. This feature allows the STAC service to be accessible only internally while other services remain externally available.
15+
STAC Auth Proxy integration allows the STAC service to be accessible only through an authenticated proxy while other eoAPI services remain externally available.
1616

17-
## Implementation Details
18-
19-
### 1. Service-Specific Ingress Control
20-
21-
Each service can now independently control its ingress settings via the values.yaml configuration:
22-
23-
```yaml
24-
stac:
25-
enabled: true
26-
ingress:
27-
enabled: false # Disable external ingress for STAC only
28-
29-
# Other services remain externally accessible
30-
raster:
31-
enabled: true
32-
ingress:
33-
enabled: true
34-
```
35-
36-
## Deployment Guide
17+
## Deployment
3718

3819
### 1. Configure eoAPI-K8S
3920

21+
Disable external STAC ingress and configure root path:
22+
4023
```yaml
4124
# values.yaml for eoapi-k8s
4225
stac:
4326
enabled: true
27+
overrideRootPath: "" # No --root-path argument (proxy handles prefix)
4428
ingress:
45-
enabled: false # No external ingress for STAC
29+
enabled: false # Required: prevents unauthenticated direct access
4630

4731
# Other services remain externally accessible
4832
raster:
4933
enabled: true
5034
vector:
5135
enabled: true
52-
multidim:
53-
enabled: true
5436
```
5537
5638
### 2. Deploy STAC Auth Proxy
5739
58-
Deploy the stac-auth-proxy Helm chart in the same namespace:
40+
Configure stac-auth-proxy subchart to point to the STAC service:
5941
6042
```yaml
61-
# values.yaml for stac-auth-proxy
62-
backend:
63-
service: stac # Internal K8s service name
64-
port: 8080 # Service port
65-
66-
auth:
67-
# Configure authentication settings
68-
provider: oauth2
69-
# ... other auth settings
70-
```
71-
72-
### 3. Network Flow
73-
74-
```mermaid
75-
graph LR
76-
A[External Request] --> B[STAC Auth Proxy]
77-
B -->|Authentication| C[Internal STAC Service]
78-
D[External Request] -->|Direct Access| E[Raster/Vector/Other Services]
79-
```
80-
81-
## Testing
82-
83-
Verify the configuration:
84-
85-
```bash
86-
# Check that STAC paths are excluded
87-
helm template eoapi --set stac.ingress.enabled=false,stac.enabled=true -f values.yaml
88-
89-
# Verify other services remain accessible
90-
kubectl get ingress
91-
kubectl get services
92-
```
93-
94-
Expected behavior:
95-
- STAC service accessible only within the cluster
96-
- Other services (raster, vector, etc.) accessible via their ingress paths
97-
- Auth proxy successfully routing authenticated requests to STAC
98-
99-
## Troubleshooting
100-
101-
1. **STAC Service Not Accessible Internally**
102-
- Verify service is running: `kubectl get services`
103-
- Check service port matches auth proxy configuration
104-
- Verify network policies allow proxy-to-STAC communication
105-
106-
2. **Other Services Affected**
107-
- Confirm ingress configuration for other services
108-
- Check ingress controller logs
109-
- Verify service-specific settings in values.yaml
110-
111-
## Root Path Configuration for Direct Service Access
112-
113-
### Understanding usage of overrideRootPath with stac-auth-proxy
114-
115-
When deploying the eoAPI-K8S with the STAC service behind a stac-auth-proxy, you may want to configure the `stac.overrideRootPath` parameter to control how the FastAPI application handles root path prefixes. This is particularly useful when the auth proxy is responsible for managing the `/stac` path prefix.
116-
117-
When deploying stac-auth-proxy in front of the eoAPI service, you may need to configure the root path behavior to avoid URL conflicts. The `stac.overrideRootPath` parameter allows you to control how the STAC FastAPI application handles root path prefixes.
118-
119-
### Setting overrideRootPath to Empty String
120-
121-
For stac-auth-proxy deployments, you often want to set `stac.overrideRootPath` to an empty string:
122-
123-
```yaml
124-
# values.yaml for eoapi-k8s
125-
stac:
43+
# values.yaml
44+
stac-auth-proxy:
12645
enabled: true
127-
overrideRootPath: "" # Empty string removes --root-path argument
128-
ingress:
129-
enabled: false # Disable external ingress for STAC
46+
env:
47+
UPSTREAM_URL: "http://eoapi-stac:8080" # Replace 'eoapi' with your release name
48+
OIDC_DISCOVERY_URL: "https://your-auth-provider.com/.well-known/openid-configuration"
49+
ALLOWED_JWT_AUDIENCES: "https://your-api-audience.com" # Recommended: should match the audience configured in your identity provider for this API.
50+
ROOT_PATH: "/stac"
13051
```
13152
132-
**Important**: This configuration creates an **intentional inconsistency**:
133-
134-
- **Ingress routes**: Still configured for `/stac` (if ingress was enabled)
135-
- **FastAPI application**: Runs without any root path prefix (no `--root-path` argument)
136-
137-
### Why This Works for stac-auth-proxy
53+
For complete configuration options, see the [stac-auth-proxy configuration documentation](https://developmentseed.org/stac-auth-proxy/user-guide/configuration).
13854
139-
This behavior is specifically designed for stac-auth-proxy scenarios where:
55+
### 3. Authentication Policy
14056
141-
1. **stac-auth-proxy** receives requests via its own ingress and handles the `/stac` path prefix
142-
2. **stac-auth-proxy** filters requests managing the `/stac` prefix and forwards them directly to the STAC service without the path prefix
143-
3. **STAC service** responds from its internal service as if it's running at the root path `/`
144-
145-
### Configuration Examples
146-
147-
#### Standard Deployment (with ingress)
57+
Control which endpoints require authentication:
14858
14959
```yaml
150-
stac:
151-
enabled: true
152-
# Default behavior - uses ingress.path as root-path
153-
ingress:
154-
enabled: true
155-
path: "/stac"
60+
stac-auth-proxy:
61+
env:
62+
# Set a default policy: read operations (GET) are public, write operations (POST, PUT, PATCH, DELETE) require authentication
63+
DEFAULT_PUBLIC: "true" # This is "false" if not specified
64+
65+
# Alternatively, you may set your custom policies (JSON objects)
66+
PRIVATE_ENDPOINTS: |
67+
{
68+
"^/collections$": ["POST"],
69+
"^/collections/([^/]+)$": ["PUT", "PATCH", "DELETE"],
70+
"^/collections/([^/]+)/items$": ["POST"],
71+
"^/collections/([^/]+)/items/([^/]+)$": ["PUT", "PATCH", "DELETE"]
72+
}
73+
74+
PUBLIC_ENDPOINTS: |
75+
{
76+
"^/$": ["GET"],
77+
"^/conformance$": ["GET"],
78+
"^/healthz": ["GET"]
79+
}
15680
```
15781
158-
Result: FastAPI runs with `--root-path=/stac`
159-
160-
#### stac-auth-proxy Deployment
82+
Or, you can also create more complex custom filters (see [upstream documentation](https://developmentseed.org/stac-auth-proxy/user-guide/record-level-auth/#custom-filter-factories)). For this you will need to add the extra file and configure **all three** requirements:
16183
16284
```yaml
163-
stac:
164-
enabled: true
165-
overrideRootPath: "" # Empty string - no --root-path argument
166-
ingress:
167-
enabled: false # Access via auth proxy only
85+
stac-auth-proxy:
86+
# 1. Set filter class environment variables
87+
env:
88+
COLLECTIONS_FILTER_CLS: stac_auth_proxy.custom_filters:CollectionsFilter
89+
ITEMS_FILTER_CLS: stac_auth_proxy.custom_filters:ItemsFilter
90+
91+
# 2. Specify custom filters file path
92+
customFiltersFile: "data/stac-auth-proxy/custom_filters.py"
93+
94+
# 3. Configure volume mount
95+
extraVolumes:
96+
- name: filters
97+
configMap:
98+
name: stac-auth-proxy-filters
99+
extraVolumeMounts:
100+
- name: filters
101+
mountPath: /app/src/stac_auth_proxy/custom_filters.py
102+
subPath: custom_filters.py
103+
readOnly: true
168104
```
169105
170-
Result: FastAPI runs without `--root-path` argument
171-
172-
#### Custom Root Path
106+
**Note**: All three components are required. `customFiltersFile` creates the ConfigMap, `extraVolumes` references it, `extraVolumeMounts` loads it into the container.
173107

174-
```yaml
175-
stac:
176-
enabled: true
177-
overrideRootPath: "/api/v1/stac" # Custom path
178-
```
108+
## Root Path Behavior
179109

180-
Result: FastAPI runs with `--root-path=/api/v1/stac`
110+
### Why `overrideRootPath: ""`
181111

182-
### Request Flow with stac-auth-proxy
112+
stac-auth-proxy manages the `/stac` prefix and forwards requests without it to the STAC service. Setting `overrideRootPath: ""` removes the `--root-path` argument so FastAPI responds as if running at root `/`.
183113

184-
```mermaid
185-
graph LR
186-
A[Client Request: /stac/collections] --> B[stac-auth-proxy]
187-
B -->|Authentication & Authorization| C[Forward: /collections]
188-
C --> D[STAC Service: receives /collections]
189-
D --> E[Response: collections data]
190-
E --> B
191-
B --> A
114+
**Request flow**:
115+
```
116+
Client: /stac/collections → Proxy: /collections → STAC service receives: /collections
192117
```
193-
194-
## Additional Notes
195-
196-
- The solution leverages Kubernetes service discovery for internal communication
197-
- No changes required to the STAC service itself
198-
- Zero downtime deployment possible
199-
- Existing deployments without auth proxy remain compatible
200-
- The `overrideRootPath: ""` configuration is specifically for proxy scenarios

0 commit comments

Comments
 (0)