|
| 1 | +# Authorization configuration guide |
| 2 | + |
| 3 | +The chart provides two levels of authorization: |
| 4 | + |
| 5 | +1. **[Route-level authorization](https://developmentseed.org/stac-auth-proxy/user-guide/route-level-auth/)**: Controls which API endpoints are accessible and by whom |
| 6 | +2. **[Record-level authorization](https://developmentseed.org/stac-auth-proxy/user-guide/record-level-auth/)**: Filters collections and items based on user permissions |
| 7 | + |
| 8 | +## Route-Level Authorization |
| 9 | + |
| 10 | +Configure via `authorization.route` section in `values.yaml`. |
| 11 | + |
| 12 | +### Mode: `default` (Recommended) |
| 13 | + |
| 14 | +Public catalog with protected write operations. This is the most common configuration. |
| 15 | + |
| 16 | +```yaml |
| 17 | +authorization: |
| 18 | + route: |
| 19 | + mode: "default" |
| 20 | +``` |
| 21 | +
|
| 22 | +This automatically sets `DEFAULT_PUBLIC=true`, making all read endpoints public while requiring authentication for write operations. |
| 23 | + |
| 24 | +### Mode: `custom` |
| 25 | + |
| 26 | +Define specific public and private endpoints with custom rules. |
| 27 | + |
| 28 | +```yaml |
| 29 | +authorization: |
| 30 | + route: |
| 31 | + mode: "custom" |
| 32 | + publicEndpoints: |
| 33 | + "^/collections$": ["GET"] |
| 34 | + "^/search$": ["GET", "POST"] |
| 35 | + "^/api.html$": ["GET"] |
| 36 | + "^/healthz": ["GET"] |
| 37 | + privateEndpoints: |
| 38 | + "^/collections$": [["POST", "collection:create"]] |
| 39 | + "^/collections/([^/]+)$": [["PUT", "collection:update"], ["DELETE", "collection:delete"]] |
| 40 | + "^/collections/([^/]+)/items$": [["POST", "item:create"]] |
| 41 | +``` |
| 42 | + |
| 43 | +**Endpoint format:** |
| 44 | +- `publicEndpoints`: Maps regex paths to HTTP methods arrays |
| 45 | +- `privateEndpoints`: Maps regex paths to HTTP methods or `[method, scope]` tuples |
| 46 | + - Scopes define required OAuth2 scopes for the operation |
| 47 | + |
| 48 | +### Mode: `disabled` |
| 49 | + |
| 50 | +No route-level authorization applied. |
| 51 | + |
| 52 | +```yaml |
| 53 | +authorization: |
| 54 | + route: |
| 55 | + mode: "disabled" |
| 56 | +``` |
| 57 | + |
| 58 | +## Record-Level Authorization |
| 59 | + |
| 60 | +Configure via `authorization.record` section in `values.yaml`. |
| 61 | + |
| 62 | +### Mode: `disabled` (Default) |
| 63 | + |
| 64 | +No record-level filtering applied. All collections and items are visible to authenticated users. |
| 65 | + |
| 66 | +```yaml |
| 67 | +authorization: |
| 68 | + record: |
| 69 | + mode: "disabled" |
| 70 | +``` |
| 71 | + |
| 72 | +### Mode: `custom` |
| 73 | + |
| 74 | +Use Python filter classes to control visibility of collections and items. |
| 75 | + |
| 76 | +```yaml |
| 77 | +authorization: |
| 78 | + record: |
| 79 | + mode: "custom" |
| 80 | + custom: |
| 81 | + filtersFile: "data/custom_filters.py" |
| 82 | +``` |
| 83 | + |
| 84 | +This automatically: |
| 85 | +- Creates a ConfigMap from your Python file |
| 86 | +- Mounts it at `/app/src/stac_auth_proxy/custom_filters.py` |
| 87 | +- Sets `COLLECTIONS_FILTER_CLS=stac_auth_proxy.custom_filters:CollectionsFilter` |
| 88 | +- Sets `ITEMS_FILTER_CLS=stac_auth_proxy.custom_filters:ItemsFilter` |
| 89 | + |
| 90 | +Review the stac-auth-proxy [documentation for more information on custom filters](https://developmentseed.org/stac-auth-proxy/user-guide/record-level-auth/#custom-filter-factories). |
| 91 | + |
| 92 | +### Mode: `opa` |
| 93 | + |
| 94 | +Use Open Policy Agent for policy-based filtering. |
| 95 | + |
| 96 | +```yaml |
| 97 | +authorization: |
| 98 | + record: |
| 99 | + mode: "opa" |
| 100 | + opa: |
| 101 | + url: "http://opa-service:8181" |
| 102 | + policy: "stac/items/allow" |
| 103 | +``` |
| 104 | + |
| 105 | +This sets: |
| 106 | +- `ITEMS_FILTER_CLS=stac_auth_proxy.filters.opa:Opa` |
| 107 | +- `ITEMS_FILTER_ARGS='["http://opa-service:8181", "stac/items/allow"]'` |
| 108 | + |
| 109 | +## Some configuration examples |
| 110 | + |
| 111 | +### Example 1: Default for public catalog, protected writes |
| 112 | + |
| 113 | +```yaml |
| 114 | +authorization: |
| 115 | + route: |
| 116 | + mode: "default" |
| 117 | + record: |
| 118 | + mode: "disabled" |
| 119 | +``` |
| 120 | + |
| 121 | +### Example 2: Fully protected catalog |
| 122 | + |
| 123 | +```yaml |
| 124 | +authorization: |
| 125 | + route: |
| 126 | + mode: "custom" |
| 127 | + publicEndpoints: |
| 128 | + "^/healthz": ["GET"] |
| 129 | + privateEndpoints: |
| 130 | + "^/collections$": [["GET", "stac:read"], ["POST", "stac:write"]] |
| 131 | + "^/search$": [["GET", "stac:read"], ["POST", "stac:read"]] |
| 132 | + record: |
| 133 | + mode: "custom" |
| 134 | + custom: |
| 135 | + filtersFile: "data/custom_filters.py" |
| 136 | +``` |
| 137 | + |
| 138 | +## Direct configuration |
| 139 | + |
| 140 | +Existing charts using `env` variables directly continue to work: |
| 141 | + |
| 142 | +```yaml |
| 143 | +env: |
| 144 | + DEFAULT_PUBLIC: "false" |
| 145 | + PUBLIC_ENDPOINTS: '{"^/search$": ["GET"]}' |
| 146 | + PRIVATE_ENDPOINTS: '{"^/collections$": [["POST", "collection:create"]]}' |
| 147 | + ITEMS_FILTER_CLS: "custom.module:Filter" |
| 148 | +``` |
| 149 | + |
| 150 | +**Environment variables specified in `env` take precedence over `authorization` settings.** |
0 commit comments