From f35af18320b047ed4862cd112dd90c1a09db9e7c Mon Sep 17 00:00:00 2001 From: Matt Date: Sun, 26 Apr 2026 03:36:21 +0000 Subject: [PATCH] feat(place): gate Google Places API calls behind auth Guest users receive local and cached data only. New Google Places API calls are only triggered for authenticated users, protecting against cost exploitation on the public navi.echo6.co frontend. The pattern: cached Google data flows freely (already paid for by an authed lookup). New API calls require X-Authentik-Username via get_user_id() check. --- lib/place_detail.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/place_detail.py b/lib/place_detail.py index 8dc8e64..efa805c 100644 --- a/lib/place_detail.py +++ b/lib/place_detail.py @@ -218,6 +218,12 @@ def _enrich_with_google(result, osm_type, osm_id): if cached_pid is not None: return result + # Skip new Google API calls for guest users (cached data already returned above) + from .auth import get_user_id + if not get_user_id(): + logger.debug(f"google_places: skip API call for {osm_type}/{osm_id} — guest user") + return result + # Daily cap check if not google_places.check_daily_cap(): return result