Compare commits

...

1 Commits

Author SHA1 Message Date
Cal Corum
e86f9cfe8b fix: remove hardcoded Supabase service-role JWT (#3)
Replace hardcoded service_role JWT with SUPABASE_SERVICE_ROLE_KEY env var.
Service-role keys bypass row-level security; they must not be committed.

Closes #3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-21 01:33:10 -05:00

View File

@ -1,10 +1,12 @@
import os
from typing import Literal
import requests
from exceptions import logger, log_exception
_SUPABASE_KEY = os.environ["SUPABASE_SERVICE_ROLE_KEY"]
AUTH_TOKEN = {
"Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNucGhwbnV2aGp2cXprY2J3emRrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0NTgxMTc4NCwiZXhwIjoyMDYxMzg3Nzg0fQ.7dG_y2zU2PajBwTD8vut5GcWf3CSaZePkYW_hMf0fVg",
"apikey": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImNucGhwbnV2aGp2cXprY2J3emRrIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc0NTgxMTc4NCwiZXhwIjoyMDYxMzg3Nzg0fQ.7dG_y2zU2PajBwTD8vut5GcWf3CSaZePkYW_hMf0fVg",
"Authorization": f"Bearer {_SUPABASE_KEY}",
"apikey": _SUPABASE_KEY,
}
DB_URL = "https://cnphpnuvhjvqzkcbwzdk.supabase.co/rest/v1"
@ -15,7 +17,7 @@ def get_req_url(endpoint: str, params: list = None):
if params:
other_params = False
for x in params:
req_url += f'{"&" if other_params else "?"}{x[0]}={x[1]}'
req_url += f"{'&' if other_params else '?'}{x[0]}={x[1]}"
other_params = True
return req_url
@ -24,11 +26,11 @@ def get_req_url(endpoint: str, params: list = None):
def log_return_value(log_string: str, log_type: Literal["info", "debug"]):
if log_type == "info":
logger.info(
f'return: {log_string[:1200]}{" [ S N I P P E D ]" if len(log_string) > 1200 else ""}\n'
f"return: {log_string[:1200]}{' [ S N I P P E D ]' if len(log_string) > 1200 else ''}\n"
)
else:
logger.debug(
f'return: {log_string[:1200]}{" [ S N I P P E D ]" if len(log_string) > 1200 else ""}\n'
f"return: {log_string[:1200]}{' [ S N I P P E D ]' if len(log_string) > 1200 else ''}\n"
)