Skip to content

Commit 5194a30

Browse files
committed
Add scope requirements
1 parent f076e59 commit 5194a30

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

runtime/eoapi/stac/eoapi/stac/app.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,28 @@ async def lifespan(app: FastAPI):
100100
extension = TiTilerExtension()
101101
extension.register(api.app, tiles_settings.titiler_endpoint)
102102

103+
for (method, path), scopes in {
104+
("POST", "/collections"): ["stac:collection:create"],
105+
("PUT", "/collections"): ["stac:collection:update"],
106+
("DELETE", "/collections/{collection_id}"): ["stac:collection:delete"],
107+
("POST", "/collections/{collection_id}/items"): ["stac:item:create"],
108+
("PUT", "/collections/{collection_id}/items/{item_id}"): ["stac:item:update"],
109+
("DELETE", "/collections/{collection_id}/items/{item_id}"): ["stac:item:delete"],
110+
}.items():
111+
api.add_route_dependencies(
112+
[
113+
{
114+
"path": app.router.prefix + path,
115+
"method": method,
116+
"type": "http",
117+
},
118+
],
119+
[Security(keycloak.scheme, scopes=scopes)],
120+
)
121+
103122

104123
@app.get("/index.html", response_class=HTMLResponse)
105-
async def viewer_page(
106-
request: Request, token: Annotated[str, Security(keycloak.scheme)]
107-
):
124+
async def viewer_page(request: Request):
108125
"""Search viewer."""
109126
return templates.TemplateResponse(
110127
"stac-viewer.html",

runtime/eoapi/stac/eoapi/stac/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class _ApiSettings(pydantic.BaseSettings):
2222
"fields",
2323
"pagination",
2424
"context",
25+
"transaction",
2526
]
2627

2728
@pydantic.validator("cors_origins")

0 commit comments

Comments
 (0)