Skip to content

feat: allow customize filter paths #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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.

> [!IMPORTANT]
> [!IMPORTANT]
> **We would :heart: to hear from you!**
> 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.
> If you prefer to remain anonymous, you can email us at eoapi@developmentseed.org, and we'll be happy to post a summary on your behalf.
Expand Down Expand Up @@ -171,6 +171,10 @@ The application is configurable via environment variables.
- **Type:** Dictionary of keyword arguments used to initialize the class
- **Required:** No, defaults to `{}`
- **Example:** `{"field_name": "properties.organization"}`
- **`ITEMS_FILTER_PATH`**, Regex pattern used to identify request paths that require the application of the items filter
- **Type:** Regex string
- **Required:** No, defaults to `^(/collections/([^/]+)/items(/[^/]+)?$|/search$)`
- **Example:** `^(/collections/([^/]+)/items(/[^/]+)?$|/search$|/custom$)`
- **`COLLECTIONS_FILTER_CLS`**, CQL2 expression generator for collection-level filtering
- **Type:** JSON object with class configuration
- **Required:** No, defaults to `null` (disabled)
Expand All @@ -183,6 +187,10 @@ The application is configurable via environment variables.
- **Type:** Dictionary of keyword arguments used to initialize the class
- **Required:** No, defaults to `{}`
- **Example:** `{"field_name": "properties.organization"}`
- **`COLLECTIONS_FILTER_PATH`**, Regex pattern used to identify request paths that require the application of the collections filter
- **Type:** Regex string
- **Required:** No, defaults to `^/collections(/[^/]+)?$`
- **Example:** `^.*?/collections(/[^/]+)?$`

### Tips

Expand Down
2 changes: 2 additions & 0 deletions src/stac_auth_proxy/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ async def lifespan(app: FastAPI):
collections_filter=(
settings.collections_filter() if settings.collections_filter else None
),
collections_filter_path=settings.collections_filter_path,
items_filter_path=settings.items_filter_path,
)

app.add_middleware(
Expand Down
2 changes: 2 additions & 0 deletions src/stac_auth_proxy/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ class Settings(BaseSettings):

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

model_config = SettingsConfigDict(
env_nested_delimiter="_",
Expand Down
Loading