Skip to content

Commit 0530ea0

Browse files
authored
feat: allow customize filter paths (#58)
Support customizing filter paths. This comes in hand when doing something such as supporting dynamic prefixes for virtualized STAC catalogs.
1 parent 445f067 commit 0530ea0

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
STAC Auth Proxy is a proxy API that mediates between the client and your internally accessible STAC API to provide flexible authentication, authorization, and content-filtering mechanisms.
99

10-
> [!IMPORTANT]
10+
> [!IMPORTANT]
1111
> **We would :heart: to hear from you!**
1212
> Please [join the discussion](https://github.com/developmentseed/eoAPI/discussions/209) and let us know how you're using eoAPI! This helps us improve the project for you and others.
1313
> If you prefer to remain anonymous, you can email us at [email protected], and we'll be happy to post a summary on your behalf.
@@ -171,6 +171,10 @@ The application is configurable via environment variables.
171171
- **Type:** Dictionary of keyword arguments used to initialize the class
172172
- **Required:** No, defaults to `{}`
173173
- **Example:** `{"field_name": "properties.organization"}`
174+
- **`ITEMS_FILTER_PATH`**, Regex pattern used to identify request paths that require the application of the items filter
175+
- **Type:** Regex string
176+
- **Required:** No, defaults to `^(/collections/([^/]+)/items(/[^/]+)?$|/search$)`
177+
- **Example:** `^(/collections/([^/]+)/items(/[^/]+)?$|/search$|/custom$)`
174178
- **`COLLECTIONS_FILTER_CLS`**, CQL2 expression generator for collection-level filtering
175179
- **Type:** JSON object with class configuration
176180
- **Required:** No, defaults to `null` (disabled)
@@ -183,6 +187,10 @@ The application is configurable via environment variables.
183187
- **Type:** Dictionary of keyword arguments used to initialize the class
184188
- **Required:** No, defaults to `{}`
185189
- **Example:** `{"field_name": "properties.organization"}`
190+
- **`COLLECTIONS_FILTER_PATH`**, Regex pattern used to identify request paths that require the application of the collections filter
191+
- **Type:** Regex string
192+
- **Required:** No, defaults to `^/collections(/[^/]+)?$`
193+
- **Example:** `^.*?/collections(/[^/]+)?$`
186194

187195
### Tips
188196

src/stac_auth_proxy/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ async def lifespan(app: FastAPI):
141141
collections_filter=(
142142
settings.collections_filter() if settings.collections_filter else None
143143
),
144+
collections_filter_path=settings.collections_filter_path,
145+
items_filter_path=settings.items_filter_path,
144146
)
145147

146148
app.add_middleware(

src/stac_auth_proxy/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ class Settings(BaseSettings):
7474

7575
# Filters
7676
items_filter: Optional[ClassInput] = None
77+
items_filter_path: str = r"^(/collections/([^/]+)/items(/[^/]+)?$|/search$)"
7778
collections_filter: Optional[ClassInput] = None
79+
collections_filter_path: str = r"^/collections(/[^/]+)?$"
7880

7981
model_config = SettingsConfigDict(
8082
env_nested_delimiter="_",

0 commit comments

Comments
 (0)