refactor: update role handling in security and permissions modules, and change hub-net to non-external in docker-compose

This commit is contained in:
2026-04-29 22:08:37 -05:00
parent 1bda94d470
commit f10fee9bc3
5 changed files with 52 additions and 34 deletions

View File

@@ -144,6 +144,16 @@ class LicenseValidationMiddleware(BaseHTTPMiddleware):
# Fallback para flujos SSO cuando el override no viaja en header.
tenant_override = request.cookies.get("sso_tenant_id") or request.cookies.get("sso_tenant_pub")
# TenantMiddleware (corre antes) ya resolvió el token y dejó tenant en user_info.
# Sin esto, Swagger/curl sin cookies SSO llaman verify-license sin contexto y el Hub
# puede devolver 401 aunque /auth/me con el mismo Bearer responda 200.
if not tenant_override:
user_info = getattr(request.state, "user_info", None)
if isinstance(user_info, dict):
tid = user_info.get("tenant_id")
if tid is not None and str(tid).strip() != "":
tenant_override = str(tid)
hub_headers = {"Authorization": f"Bearer {token}"}
if tenant_override:
hub_headers["X-Tenant-Override"] = str(tenant_override)