Skip to content

Commit 8b3d3c9

Browse files
fix: allow queryables endpoints for collections (#204)
in my application, I have `/collections/{collectionId}/queryables` endpoints available but I want to make sure all `/collections/{collectionId}/...` endpoints are going through my opa filter, and for which I need to extract the path-parameter. It worked well for all my endpoints, except for the `.../queryables` endpoint because it was missing in the `request.extract_variables` method
1 parent 5aeee7c commit 8b3d3c9

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/stac_auth_proxy/utils/requests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def extract_variables(url: str) -> dict:
2020
we can't rely on the path parameters that FastAPI provides.
2121
"""
2222
path = urlparse(url).path
23-
# This allows either /items or /bulk_items, with an optional item_id following.
24-
pattern = r"^/collections/(?P<collection_id>[^/]+)(?:/(?:items|bulk_items)(?:/(?P<item_id>[^/]+))?)?/?$"
23+
# This allows either /queryables or /items or /bulk_items, with an optional item_id following.
24+
pattern = r"^/collections/(?P<collection_id>[^/]+)(?:/(?:items|bulk_items|queryables)(?:/(?P<item_id>[^/]+))?)?/?$"
2525
match = re.match(pattern, path)
2626
return {k: v for k, v in match.groupdict().items() if v} if match else {}
2727

tests/test_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
(
1616
("/collections/123", {"collection_id": "123"}),
1717
("/collections/123/items", {"collection_id": "123"}),
18+
("/collections/123/queryables", {"collection_id": "123"}),
1819
("/collections/123/bulk_items", {"collection_id": "123"}),
1920
("/collections/123/items/456", {"collection_id": "123", "item_id": "456"}),
2021
("/collections/123/bulk_items/456", {"collection_id": "123", "item_id": "456"}),

0 commit comments

Comments
 (0)