feat(ui): mejoras dashboard y entorno local con ngrok/ORCID sandbox
- Añade enlace Volver al inicio y márgenes max-w-7xl en dashboard y group - Corrige hora de última sincronización (UTC en formatDate) - Evita scroll horizontal en tabla de publicaciones - Soporta backend/.env.local y compose opcional para sandbox/ngrok - Cookie OAuth Secure en redirects HTTPS; README y .env.example
This commit is contained in:
@@ -19,8 +19,15 @@ from pydantic import Field, field_validator, model_validator
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
_ENV_PATH = Path(__file__).resolve().parents[2] / ".env"
|
||||
_ENV_DIR = Path(__file__).resolve().parents[2]
|
||||
_ENV_PATH = _ENV_DIR / ".env"
|
||||
_ENV_LOCAL_PATH = _ENV_DIR / ".env.local"
|
||||
|
||||
# Carga en cascada: `.env` (versionado en GitLab con valores de prod) y
|
||||
# opcionalmente `.env.local` (gitignored) para sandbox / ngrok en local.
|
||||
load_dotenv(dotenv_path=_ENV_PATH, override=False)
|
||||
if _ENV_LOCAL_PATH.is_file():
|
||||
load_dotenv(dotenv_path=_ENV_LOCAL_PATH, override=True)
|
||||
|
||||
|
||||
def _split_csv(value: str | List[str] | None) -> List[str]:
|
||||
|
||||
@@ -12,6 +12,7 @@ from __future__ import annotations
|
||||
import hmac
|
||||
import secrets
|
||||
from datetime import datetime, timezone
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from fastapi import HTTPException, status
|
||||
from starlette.requests import Request
|
||||
@@ -30,12 +31,18 @@ def generate_state() -> str:
|
||||
def attach_state_cookie(response: Response, state: str) -> None:
|
||||
"""
|
||||
Persiste el `state` en una cookie segura y devuelve el valor crudo.
|
||||
|
||||
`Secure` debe ser True en cualquier flujo HTTPS (p. ej. ngrok en local);
|
||||
no basta con `ENVIRONMENT=production`, o el navegador puede descartar
|
||||
la cookie y el callback fallará con «OAuth state missing».
|
||||
"""
|
||||
redirect_https = urlparse(settings.ORCID_REDIRECT_URI).scheme == "https"
|
||||
use_secure = settings.is_production or redirect_https
|
||||
response.set_cookie(
|
||||
key=settings.ORCID_OAUTH_STATE_COOKIE,
|
||||
value=state,
|
||||
max_age=settings.ORCID_OAUTH_STATE_TTL_SECONDS,
|
||||
secure=settings.is_production,
|
||||
secure=use_secure,
|
||||
httponly=True,
|
||||
samesite="lax",
|
||||
path="/",
|
||||
|
||||
Reference in New Issue
Block a user