diff --git a/services/auth.py b/services/auth.py index 81d8230c..8c501f4a 100644 --- a/services/auth.py +++ b/services/auth.py @@ -3,7 +3,7 @@ from functools import wraps from cache.cache import get_cached_author_by_user_id from resolvers.stat import get_with_stat from services.schema import request_graphql_data -from settings import ADMIN_SECRET +from settings import ADMIN_SECRET, AUTH_URL from utils.logger import root_logger as logger @@ -22,6 +22,10 @@ async def check_auth(req): - user_roles: list[str] - Список ролей пользователя. """ token = req.headers.get("Authorization") + host = req.headers.get('host', '') + auth_url = AUTH_URL + if host == 'testing.dscrs.site' or host == 'localhost': + auth_url = "https://auth.dscrs.site/graphql" user_id = "" user_roles = [] if token: @@ -39,7 +43,7 @@ async def check_auth(req): "variables": variables, "operationName": operation, } - data = await request_graphql_data(gql) + data = await request_graphql_data(gql, url=auth_url) if data: logger.debug(data) user_data = data.get("data", {}).get(query_name, {}).get("claims", {}) diff --git a/settings.py b/settings.py index 968962e6..a2a18efb 100644 --- a/settings.py +++ b/settings.py @@ -8,7 +8,6 @@ DB_URL = ( or "sqlite:///discoursio-db.sqlite3" ) REDIS_URL = environ.get("REDIS_URL") or "redis://127.0.0.1" -API_BASE = environ.get("API_BASE") or "" AUTH_URL = environ.get("AUTH_URL") or "" GLITCHTIP_DSN = environ.get("GLITCHTIP_DSN") DEV_SERVER_PID_FILE_NAME = "dev-server.pid"