Fix user delete flow 5
This commit is contained in:
@@ -205,6 +205,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
|
|||||||
if payload.get("service"):
|
if payload.get("service"):
|
||||||
base_context["service"] = payload["service"]
|
base_context["service"] = payload["service"]
|
||||||
base_context["type"] = "service"
|
base_context["type"] = "service"
|
||||||
|
base_context["role"] = "service"
|
||||||
logger.debug(f"Service authentication: {payload['service']}")
|
logger.debug(f"Service authentication: {payload['service']}")
|
||||||
|
|
||||||
return base_context
|
return base_context
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ async def verify_tenant_access(
|
|||||||
):
|
):
|
||||||
"""Verify if user has access to tenant - Called by Gateway"""
|
"""Verify if user has access to tenant - Called by Gateway"""
|
||||||
# Check if this is a service request
|
# Check if this is a service request
|
||||||
if user_id in ["training-service", "data-service", "forecasting-service"]:
|
if user_id in ["training-service", "data-service", "forecasting-service", "auth-service"]:
|
||||||
# Services have access to all tenants for their operations
|
# Services have access to all tenants for their operations
|
||||||
return TenantAccessResponse(
|
return TenantAccessResponse(
|
||||||
has_access=True,
|
has_access=True,
|
||||||
@@ -295,6 +295,7 @@ async def get_user_tenants(
|
|||||||
_admin_check = Depends(require_admin_role),
|
_admin_check = Depends(require_admin_role),
|
||||||
db: AsyncSession = Depends(get_db)
|
db: AsyncSession = Depends(get_db)
|
||||||
):
|
):
|
||||||
|
|
||||||
"""Get all tenant memberships for a user (admin only)"""
|
"""Get all tenant memberships for a user (admin only)"""
|
||||||
try:
|
try:
|
||||||
user_uuid = uuid.UUID(user_id)
|
user_uuid = uuid.UUID(user_id)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ServiceAuthenticator:
|
|||||||
"sub": f"{self.service_name}-service",
|
"sub": f"{self.service_name}-service",
|
||||||
"user_id": f"{self.service_name}-service",
|
"user_id": f"{self.service_name}-service",
|
||||||
"email": f"{self.service_name}-service@internal",
|
"email": f"{self.service_name}-service@internal",
|
||||||
"type": "access",
|
"type": "service",
|
||||||
"exp": token_expires_at,
|
"exp": token_expires_at,
|
||||||
"iat": current_time,
|
"iat": current_time,
|
||||||
"iss": f"{self.service_name}-service",
|
"iss": f"{self.service_name}-service",
|
||||||
|
|||||||
Reference in New Issue
Block a user