Skip to content

Commit bcad9b0

Browse files
committed
rename to coll_internal_access_dep
catch jwt exceptions block /internal/ access in frontend
1 parent 4485c6f commit bcad9b0

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

backend/btrixcloud/auth.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,11 @@ def create_custom_jwt_token(sub: str, data: dict[str, str]) -> str:
134134
def get_custom_jwt_token(request: Request) -> dict[str, str]:
135135
"""return data from custom jwt token"""
136136
token = request.query_params.get("auth_bearer") or ""
137-
payload = decode_jwt(token, [CUSTOM_AUTH_AUD])
138-
return payload
137+
try:
138+
return decode_jwt(token, [CUSTOM_AUTH_AUD])
139+
# pylint: disable=bare-except
140+
except:
141+
return {}
139142

140143

141144
# ============================================================================

backend/btrixcloud/colls.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,7 +1289,7 @@ def init_collections_api(
12891289
org_viewer_dep = orgs.org_viewer_dep
12901290
org_public = orgs.org_public
12911291

1292-
async def coll_access_dep(
1292+
async def coll_internal_access_dep(
12931293
coll_id: UUID, token_data: dict[str, str] = Depends(get_custom_jwt_token)
12941294
) -> UUID:
12951295
# first, check subject match collection id and type is collection
@@ -1396,7 +1396,9 @@ async def get_collection_replay(
13961396
tags=["collections"],
13971397
response_model=ResourcesOnly,
13981398
)
1399-
async def get_internal_replay(oid: UUID, coll_id: UUID = Depends(coll_access_dep)):
1399+
async def get_internal_replay(
1400+
oid: UUID, coll_id: UUID = Depends(coll_internal_access_dep)
1401+
):
14001402
return await colls.get_internal_replay_list(coll_id, oid)
14011403

14021404
@app.get(

frontend/frontend.conf.template

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ server {
7070
# serve a 404 page for /replay/ path, as that should be taken over by RWP
7171
location /replay/ {
7272
default_type application/json;
73-
return 404 "{\"error\": \"placeholder_for_replay\"}";
73+
return 404 "{\"detail\":\"placeholder_for_replay\"}";
7474
}
7575

7676
# used by docker only: k8s deployment handles /api directly via ingress
@@ -90,6 +90,10 @@ server {
9090
proxy_read_timeout 300;
9191
}
9292

93+
location ~* /internal/ {
94+
return 403 "{\"detail\":\"access_denied\"}";
95+
}
96+
9397
location ~* /watch/([^/]+)/([^/]+)/([^/]+)/ws {
9498
set $org $1;
9599
set $crawl $2;

0 commit comments

Comments
 (0)