harden auth gateway

This commit is contained in:
Eduardo Silva
2026-11-21 12:26:28 -03:00
parent dd81ff6318
commit 7fd1a4fbc3
12 changed files with 195 additions and 60 deletions
@@ -1,8 +1,9 @@
from dataclasses import dataclass
from auth_gateway.models.auth import OIDCMethodModel
from authlib.integrations.starlette_client import OAuth
from auth_gateway.models.auth import OIDCMethodModel
@dataclass
class OIDCIdentity:
@@ -45,6 +46,9 @@ class OIDCService:
if "userinfo" in token and isinstance(token["userinfo"], dict):
claims.update(token["userinfo"])
email = claims.get("email")
# An email the provider did not verify can be set by the user, so it must not pass the allowlists
if str(claims.get("email_verified", True)).lower() == "false":
email = None
subject = claims.get("sub")
return OIDCIdentity(subject=subject, email=email, claims=claims)