Skip to content

Commit e128f99

Browse files
committed
ensure anonymous access is prevented
1 parent ddefe6f commit e128f99

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

applications/argocd/staging/applications/montandon-eoapi/stac-auth-proxy/montandon_filters.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ class CollectionsFilter:
5353
async def __call__(self, context: dict[str, Any]) -> str:
5454
jwt_payload: Optional[dict[str, Any]] = context.get("payload")
5555

56-
# Anonymous: only public collections
56+
# Anonymous: no data
5757
if not jwt_payload:
58-
return self.public_collections_filter
58+
logger.debug("Anonymous user, no collections permitted to be viewed")
59+
return "1=0"
5960

60-
# Superuser: no filter
61-
if jwt_payload.get(self.admin_claim) == 'true':
61+
# Superuser: all data
62+
if jwt_payload.get(self.admin_claim) == "true":
6263
logger.debug(
6364
f"Superuser detected for sub {jwt_payload.get('sub')}, "
6465
"no filter applied for collections"
@@ -164,8 +165,13 @@ async def _get_public_collections_ids(self) -> list[str]:
164165
async def __call__(self, context: dict[str, Any]) -> str:
165166
jwt_payload: Optional[dict[str, Any]] = context.get("payload")
166167

167-
# Superuser: no filter
168-
if jwt_payload and jwt_payload.get(self.admin_claim) == 'true':
168+
# Anonymous: no data
169+
if not jwt_payload:
170+
logger.debug("Anonymous user, no items permitted to be viewed")
171+
return "1=0"
172+
173+
# Superuser: all data
174+
if jwt_payload.get(self.admin_claim) == "true":
169175
logger.debug(
170176
f"Superuser detected for sub {jwt_payload.get('sub')}, "
171177
"no filter applied for items"

0 commit comments

Comments
 (0)