feat(auth): session login with per-domain scope

Cookie session with /auth/login, /auth/logout and /auth/me. Four accounts come from WEBAPI_USUARIOS (admin plus one per domain) and a second before_request answers 403 when an account asks for another domain.

The data suites run with WEBAPI_AUTH_REQUIRED=0; test_auth.py turns the lock back on and covers both hooks. The Dockerfile normalises the entrypoint so a Windows checkout still starts the container.
This commit is contained in:
Erick ivan
2026-11-19 09:35:25 -06:00
parent b1bbbc25b4
commit 084fe2e8d3
6 changed files with 398 additions and 3 deletions
+9 -1
View File
@@ -50,6 +50,11 @@ ENV MLFLOW_DISABLE_TELEMETRY=true DO_NOT_TRACK=true
ENV WEBAPI_REPORT_DIR=/data/reportes
ENV INDICADORES_DIR=/data/indicadores
ENV MLFLOW_DISABLE_AGENT_HINT=1
# Session login (webapi/blueprints/auth.py): the four demonstration accounts live
# in the code; WEBAPI_USUARIOS (JSON list, see .env.example) replaces them.
# Signs the session cookie: the same value in every worker and across restarts,
# or the login does not survive the next request.
ENV WEBAPI_SECRET_KEY=issteleon-dev-cambiar-en-produccion
# Without it the measure routes (/<domain>/indicadores, /<domain>/fhir) aren't
# registered. The entrypoint replaces it with one compiled against the
# deployment's engine when that engine isn't SQLite (webapi.dbt_manifest).
@@ -57,7 +62,10 @@ COPY --from=manifest /app/Transformation /app/Transformation
ENV DBT_MANIFEST=/app/Transformation/target/manifest.json
ENV TRANSFORMATION_DIR=/app/Transformation
RUN chmod +x /app/WebApi/docker-entrypoint.sh
# A checkout on Windows can bring the script with CRLF, and then the shebang
# is `#!/bin/sh\r`: the container would not start. Normalize it here so the
# image builds the same from any platform.
RUN sed -i 's/\r$//' /app/WebApi/docker-entrypoint.sh && chmod +x /app/WebApi/docker-entrypoint.sh
EXPOSE 5000
ENTRYPOINT ["/app/WebApi/docker-entrypoint.sh"]