Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added __pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/_service.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/_service.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/auth.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/auth.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/client.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/client.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/database.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/database.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/edge_functions.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/edge_functions.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/init.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/init.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/realtime.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/realtime.cpython-312.pyc
Binary file not shown.
Binary file added __pycache__/storage.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/storage.cpython-312.pyc
Binary file not shown.
20 changes: 10 additions & 10 deletions _service.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import json
from typing import Any, Dict, Optional
import os

import requests
from django.conf import settings
import logging

logger = logging.getLogger(" apps.supabase_home")
Expand Down Expand Up @@ -44,23 +44,23 @@ class SupabaseService:
"""

def __init__(self):
# Get configuration from settings
self.base_url = settings.SUPABASE_URL
self.anon_key = settings.SUPABASE_ANON_KEY
self.service_role_key = settings.SUPABASE_SERVICE_ROLE_KEY
# Get configuration from environment variables
self.base_url = os.getenv("SUPABASE_URL", "")
self.anon_key = os.getenv("SUPABASE_ANON_KEY", "")
self.service_role_key = os.getenv("SUPABASE_SERVICE_ROLE_KEY", "")

# Validate required settings
if not self.base_url:
logger.error("SUPABASE_URL is not set in settings")
raise ValueError("SUPABASE_URL is not set in settings")
logger.error("SUPABASE_URL is not set in environment variables")
raise ValueError("SUPABASE_URL is not set in environment variables")

if not self.anon_key:
logger.error("SUPABASE_ANON_KEY is not set in settings")
raise ValueError("SUPABASE_ANON_KEY is not set in settings")
logger.error("SUPABASE_ANON_KEY is not set in environment variables")
raise ValueError("SUPABASE_ANON_KEY is not set in environment variables")

if not self.service_role_key:
logger.warning(
"SUPABASE_SERVICE_ROLE_KEY is not set in settings. Admin operations will not work."
"SUPABASE_SERVICE_ROLE_KEY is not set in environment variables. Admin operations will not work."
)

def _get_headers(
Expand Down
9 changes: 5 additions & 4 deletions init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.conf import settings
import logging
import sys
from backend.utils.sensitive import load_environment_files
# Import the environment file loader
from app.core.utils.sensitive import load_environment_files
import os

# Load environment variables
Expand Down Expand Up @@ -53,7 +53,8 @@ def initialize_supabase() -> Client:

# Check for required environment variables
supabase_url = os.getenv("SUPABASE_URL")
supabase_key = os.getenv("SUPABASE_ANON_KEY")
# Use service role key for backend operations to bypass RLS
supabase_key = os.getenv("SUPABASE_SERVICE_ROLE_KEY") or os.getenv("SUPABASE_ANON_KEY")

print(f"Supabase URL: {supabase_url}") # Added print statement to show the URL

Expand All @@ -63,7 +64,7 @@ def initialize_supabase() -> Client:
raise ValueError(error_msg)

if not supabase_key:
error_msg = "SUPABASE_ANON_KEY is not set in environment variables"
error_msg = "SUPABASE_SERVICE_ROLE_KEY or SUPABASE_ANON_KEY is not set in environment variables"
logger.error(error_msg)
raise ValueError(error_msg)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pytest
from pathlib import Path
from utils.sensitive import load_environment_files
from apps.supabase_home.tests._verify_supabase_connection import run_verification
from app.core.third_party_integrations.supabase_home.tests._verify_supabase_connection import run_verification
import uuid

# Add the backend directory to the Python path
Expand Down
2 changes: 1 addition & 1 deletion tests/test_edge_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from apps.supabase_home.edge_functions import SupabaseEdgeFunctionsService
from app.core.third_party_integrations.supabase_home.edge_functions import SupabaseEdgeFunctionsService


class TestSupabaseEdgeFunctionsService:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from django.conf import settings

# Import the service classes from their respective modules
from apps.supabase_home.auth import SupabaseAuthService
from apps.supabase_home.storage import SupabaseStorageService
from apps.supabase_home.database import SupabaseDatabaseService
from app.core.third_party_integrations.supabase_home.auth import SupabaseAuthService
from app.core.third_party_integrations.supabase_home.storage import SupabaseStorageService
from app.core.third_party_integrations.supabase_home.database import SupabaseDatabaseService

# Load environment variables for tests
load_environment_files()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
import os

from apps.supabase_home._service import SupabaseService, SupabaseAPIError, SupabaseError
from app.core.third_party_integrations.supabase_home._service import SupabaseService, SupabaseAPIError, SupabaseError



Expand Down