@@ -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" ,
0 commit comments