authdev
This commit is contained in:
parent
434d59a7ba
commit
a41a5ad39a
|
@ -3,7 +3,7 @@ from functools import wraps
|
||||||
from cache.cache import get_cached_author_by_user_id
|
from cache.cache import get_cached_author_by_user_id
|
||||||
from resolvers.stat import get_with_stat
|
from resolvers.stat import get_with_stat
|
||||||
from services.schema import request_graphql_data
|
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
|
from utils.logger import root_logger as logger
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ async def check_auth(req):
|
||||||
- user_roles: list[str] - Список ролей пользователя.
|
- user_roles: list[str] - Список ролей пользователя.
|
||||||
"""
|
"""
|
||||||
token = req.headers.get("Authorization")
|
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_id = ""
|
||||||
user_roles = []
|
user_roles = []
|
||||||
if token:
|
if token:
|
||||||
|
@ -39,7 +43,7 @@ async def check_auth(req):
|
||||||
"variables": variables,
|
"variables": variables,
|
||||||
"operationName": operation,
|
"operationName": operation,
|
||||||
}
|
}
|
||||||
data = await request_graphql_data(gql)
|
data = await request_graphql_data(gql, url=auth_url)
|
||||||
if data:
|
if data:
|
||||||
logger.debug(data)
|
logger.debug(data)
|
||||||
user_data = data.get("data", {}).get(query_name, {}).get("claims", {})
|
user_data = data.get("data", {}).get(query_name, {}).get("claims", {})
|
||||||
|
|
|
@ -8,7 +8,6 @@ DB_URL = (
|
||||||
or "sqlite:///discoursio-db.sqlite3"
|
or "sqlite:///discoursio-db.sqlite3"
|
||||||
)
|
)
|
||||||
REDIS_URL = environ.get("REDIS_URL") or "redis://127.0.0.1"
|
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 ""
|
AUTH_URL = environ.get("AUTH_URL") or ""
|
||||||
GLITCHTIP_DSN = environ.get("GLITCHTIP_DSN")
|
GLITCHTIP_DSN = environ.get("GLITCHTIP_DSN")
|
||||||
DEV_SERVER_PID_FILE_NAME = "dev-server.pid"
|
DEV_SERVER_PID_FILE_NAME = "dev-server.pid"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user