Добавлена поддержка авторизации через макс
All checks were successful
Build And Push / publish (push) Successful in 4m5s
All checks were successful
Build And Push / publish (push) Successful in 4m5s
This commit is contained in:
@ -5,7 +5,7 @@ import tempfile
|
||||
import uuid
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
from typing import Any, Literal
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from apps.esia.scopes import SCOPES
|
||||
@ -62,13 +62,19 @@ def sign_params(params: dict[str, Any]):
|
||||
return base64.urlsafe_b64encode(client_secret).decode('utf-8')
|
||||
|
||||
|
||||
def get_url():
|
||||
def get_url(platform: Literal['max', 'app']):
|
||||
timestamp = datetime.now(UTC).strftime('%Y.%m.%d %H:%M:%S %z').strip()
|
||||
state = str(uuid.uuid4())
|
||||
redirect_uri = (
|
||||
settings.ESIA_REDIRECT_URI
|
||||
if platform == 'app'
|
||||
else settings.ESIA_MAX_REDIRECT_URI
|
||||
)
|
||||
|
||||
params = {
|
||||
'client_id': settings.ESIA_CLIENT_ID,
|
||||
'client_secret': '',
|
||||
'redirect_uri': settings.ESIA_REDIRECT_URI,
|
||||
'redirect_uri': redirect_uri,
|
||||
'response_type': RESPONSE_CODE,
|
||||
'state': state,
|
||||
'timestamp': timestamp,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import secrets
|
||||
from logging import getLogger
|
||||
from typing import Literal
|
||||
|
||||
from fastapi import APIRouter
|
||||
from sqlmodel import select
|
||||
@ -23,8 +24,8 @@ router = APIRouter(
|
||||
|
||||
|
||||
@router.get('/login', response_model=s.LoginURL)
|
||||
async def login():
|
||||
url = get_url()
|
||||
async def login(platform: Literal['max', 'app'] = 'app'):
|
||||
url = get_url(platform)
|
||||
return s.LoginURL(url=url)
|
||||
|
||||
|
||||
|
||||
@ -49,6 +49,8 @@ class Settings(BaseSettings):
|
||||
ESIA_CONTAINER_THUMBPRINT: str = Field(default='')
|
||||
ESIA_PROXY: str | None = Field(default=None)
|
||||
|
||||
ESIA_MAX_REDIRECT_URI: str = Field(default='')
|
||||
|
||||
# Vitacore
|
||||
VITACORE_BASE_URL: str = Field(
|
||||
default='https://gist-cws.ezdrav.ru:8899/MP_API'
|
||||
|
||||
Reference in New Issue
Block a user