Skip to content

Commit 29e7636

Browse files
committed
Cleanup
1 parent 765e9a2 commit 29e7636

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

examples/opa/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ docker compose -f docker-compose.yaml -f examples/opa/docker-compose.yaml up
2424
-H "Content-Type: application/json" \
2525
-d '{"input":{"payload": {"sub": "user1"}}}'
2626
{"result":"1=1"}
27-
```
27+
```

src/stac_auth_proxy/filters/opa.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ async def __call__(self, context: dict[str, Any]) -> str:
2929
"""Generate a CQL2 filter for the request."""
3030
if cached_result := self.cache.get(context):
3131
return cached_result
32+
result = await self._fetch(context)
33+
self.cache.set(context, result)
34+
return result
35+
36+
async def _fetch(self, context: dict[str, Any]) -> str:
37+
"""Fetch the CQL2 filter from OPA."""
3238
response = await self.client.post(
3339
f"/v1/data/{self.decision}",
3440
json={"input": context},
3541
)
36-
result = response.raise_for_status().json()["result"]
37-
self.cache.set(context, result)
38-
return result
42+
return response.raise_for_status().json()["result"]

uv.lock

Lines changed: 0 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)