Skip to content

Commit

Permalink
Add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaraphael committed Oct 18, 2023
1 parent 2b7955a commit 324d4ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cerulean_cloud/cloud_run_tipg/.env.tipg
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ TIPG_TABLE_CONFIG__public_slick__DATETIMECOL="slick_timestamp"
TIPG_TABLE_CONFIG__public_slick_plus__DATETIMECOL="slick_timestamp"
TIPG_MAX_FEATURES_PER_QUERY=50000
TIPG_DB_EXCLUDE_TABLES='["public.aoi_user", "public.filter", "public.frequency", "public.magic_link", "public.subscription", "public.user", "public.slick_to_source", "public.source", "public.source_infra", "public.source_type", "public.source_vessel"]'
TIPG_DB_EXCLUDE_FUNCTIONS='["public.get_slicks_by_source", "public.get_slicks_by_aoi_or_source"]'
TIPG_DB_EXCLUDE_FUNCTIONS='["public.get_slicks_by_source", "public.get_slicks_by_aoi_or_source"]'
SECRET_API_KEY="XXX_SECRET_API_KEY"
12 changes: 11 additions & 1 deletion cerulean_cloud/cloud_run_tipg/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,23 @@ async def dispatch(self, request: Request, call_next):
Returns:
Response: The outgoing FastAPI response object.
"""

print(
"XXX os.environ.get(SECRET_API_KEY)",
os.environ.get("SECRET_API_KEY", "NO SECRET KEY FOUND!!!"),
)
print("XXX request", request)
print("XXX request.headers.get('X-API-Key')", request.headers.get("X-API-Key"))
table = extract_table_from_request(request)
print("XXX table", table)
excluded_collections = get_env_list("TIPG_DB_EXCLUDE_TABLES") + get_env_list(
"TIPG_DB_EXCLUDE_FUNCTIONS"
)
print("XXX excluded_collections", excluded_collections)
if table in excluded_collections:
print("XXX table in excluded_collections", table)
api_key = request.headers.get("X-API-Key")
if api_key != "XXX_SECRET_API_KEY":
if api_key != os.environ.get("SECRET_API_KEY", "XXX_SECRET_API_KEY"):
raise HTTPException(
status_code=403, detail="Access to table restricted"
)
Expand Down

0 comments on commit 324d4ff

Please sign in to comment.