Skip to content

Commit e644037

Browse files
committed
Rely on stac-auth-proxy helm options.
1 parent 1c275a9 commit e644037

5 files changed

Lines changed: 64 additions & 130 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Added support for annotations on the PgSTAC bootstrap job via `pgstacBootstrap.jobAnnotations` in values.yaml [#381](https://github.com/developmentseed/eoapi-k8s/pull/381)
1313
- Added load testing scripts [#373](https://github.com/developmentseed/eoapi-k8s/pull/373)
1414
- Added auth support to STAC Browser [#376](https://github.com/developmentseed/eoapi-k8s/pull/376)
15-
- Added support for custom filters configuration via `customFiltersFile` in values.yaml [#388](https://github.com/developmentseed/eoapi-k8s/pull/388)
15+
- Added support for stac-auth-proxy's helm chart authorization configuration [#388](https://github.com/developmentseed/eoapi-k8s/pull/388)
1616

1717
### Fixed
1818

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
"""
22
Sample custom filters for STAC Auth Proxy.
33
This file demonstrates the structure needed for custom collection and item filters.
4+
5+
Enable via:
6+
authorization:
7+
record:
8+
mode: "custom"
9+
custom:
10+
filtersFile: "data/stac-auth-proxy/custom_filters.py"
11+
12+
The chart automatically:
13+
- Creates ConfigMap and mounts this file
14+
- Sets COLLECTIONS_FILTER_CLS=stac_auth_proxy.custom_filters:CollectionsFilter
15+
- Sets ITEMS_FILTER_CLS=stac_auth_proxy.custom_filters:ItemsFilter
416
"""
517

618
import dataclasses
@@ -11,17 +23,32 @@
1123
class CollectionsFilter:
1224
"""Filter collections based on user permissions."""
1325

14-
async def __call__(self, context: dict[str, Any]) -> str:
15-
"""Return True if user can access this collection."""
16-
# Example: Allow all collections for authenticated users
26+
async def __call__(self, context: dict[str, Any]) -> str | dict[str, Any]:
27+
"""
28+
Return format:
29+
- CQL2-text string (simpler): "1=1" or "private = false"
30+
- CQL2-JSON dict (complex): {"op": "=", "args": [{"property": "owner"}, "user123"]}
31+
32+
Examples:
33+
- Allow all: return "1=1"
34+
- Restrict by user: return f"owner = '{context['token']['sub']}'"
35+
- Public only: return "private = false" if not context["token"] else "1=1"
36+
- Complex (dict): return {"op": "in", "args": [{"property": "id"}, ["col1", "col2"]]}
37+
"""
1738
return "1=1"
1839

1940

2041
@dataclasses.dataclass
2142
class ItemsFilter:
2243
"""Filter items based on user permissions."""
44+
"""Returns CQL2 filter for /search and /collections/{id}/items endpoints."""
2345

24-
async def __call__(self, context: dict[str, Any]) -> str:
25-
"""Return True if user can access this item."""
26-
# Example: Allow all items for authenticated users
46+
async def __call__(self, context: dict[str, Any]) -> str | dict[str, Any]:
47+
"""
48+
Examples:
49+
- Allow all: return "1=1"
50+
- Collection-based: return f"collection = '{context['collection_id']}'"
51+
- User-based: return f"properties.owner = '{context['token']['sub']}'"
52+
- Complex (dict): return {"op": "in", "args": [{"property": "collection"}, approved_list]}
53+
"""
2754
return "1=1"

charts/eoapi/templates/core/stac-auth-proxy-filters-configmap.yaml

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

charts/eoapi/tests/stac-auth-proxy-filters_test.yaml

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

charts/eoapi/values.yaml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -423,39 +423,39 @@ stac-auth-proxy:
423423
port: 8080
424424
resources: {}
425425
env:
426+
# OIDC_DISCOVERY_URL must be configured when enabling auth (required)
426427
ROOT_PATH: "/stac"
427428
OVERRIDE_HOST: "false"
429+
428430
# UPSTREAM_URL will be set dynamically in template to point to stac service
429-
# OIDC_DISCOVERY_URL must be configured when enabling auth
430-
# OIDC_DISCOVERY_URL must be configured when enabling auth
431-
# UPSTREAM_URL will be set dynamically in template to point to stac service
432-
#
433-
# Authentication filters settings:
434-
DEFAULT_PUBLIC: "true" # This enables standard profile for authentication filters
435-
# Alternatively with the following settings custom filters can be added
436-
# These must be mounted with extraVolumes/extraVolumeMounts (see below)
437-
# COLLECTIONS_FILTER_CLS: stac_auth_proxy.custom_filters:CollectionsFilter
438-
# ITEMS_FILTER_CLS: stac_auth_proxy.custom_filters:ItemsFilter
439-
440-
# Path to custom filters file (relative to chart root)
441-
# When extraVolumes is configured, a ConfigMap will be created from this file
442-
# customFiltersFile: "data/stac-auth-proxy/custom_filters.py"
443-
444-
# Additional volumes to mount (e.g., for custom filter files)
445-
extraVolumes: []
446-
# Example:
447-
# extraVolumes:
448-
# - name: filters
449-
# configMap:
450-
# name: stac-auth-proxy-filters
451-
# Additional volume mounts for the container
452-
extraVolumeMounts: []
453-
# Example:
454-
# extraVolumeMounts:
455-
# - name: filters
456-
# mountPath: /app/src/stac_auth_proxy/custom_filters.py
457-
# subPath: custom_filters.py
458-
# readOnly: true
431+
432+
# Authorization configuration
433+
# Uses stac-auth-proxy's native authorization settings
434+
authorization:
435+
# Route-level authorization controls API endpoint access
436+
route:
437+
mode: "default" # "default" (public reads, protected writes), "custom", or "disabled"
438+
# For custom mode, define publicEndpoints and privateEndpoints
439+
# publicEndpoints: {}
440+
# privateEndpoints: {}
441+
442+
# Record-level authorization filters collections/items visibility
443+
record:
444+
mode: "disabled" # "disabled" (default), "custom", or "opa"
445+
# For custom Python filters, specify the file path
446+
# custom:
447+
# filtersFile: "data/stac-auth-proxy/custom_filters.py"
448+
# For OPA-based filtering
449+
# opa:
450+
# url: "http://opa-service:8181"
451+
# policy: "stac/items/allow"
452+
453+
# For special cases, direct env variable configuration is possible
454+
# and takes precedence over authorization settings.
455+
# env:
456+
# DEFAULT_PUBLIC: "true"
457+
# COLLECTIONS_FILTER_CLS: "stac_auth_proxy.custom_filters:CollectionsFilter"
458+
# ITEMS_FILTER_CLS: "stac_auth_proxy.custom_filters:ItemsFilter"
459459

460460
vector:
461461
enabled: true

0 commit comments

Comments
 (0)