Přidaná centrální runtime konfigurace public URL, HTTPS a Google OAuth readiness v config.py (line 37).
Google OAuth přidaný jako volitelná další možnost přihlášení, bez nahrazení lokálního/Gitea loginu, v auth.py (line 128).
Default Google redirect URI se skládá z APPFACTORY_PORTAL_PUBLIC_URL + /auth/google/callback, bez hardcoded IP/localhost/domény.
Readiness JSON endpoint přidán na /portal/migration-readiness/auth-domain-config; vrací jen boolean hodnoty, žádné secrety, v migration_readiness.py (line 112).
UI sekce Auth & Domain Readiness přidaná do Migration Readiness v migration_readiness.py (line 41).
Audit event auth_domain_readiness.viewed se zapisuje při zobrazení readiness stránky v migration_readiness.py (line 133).
APPFACTORY_ENABLE_HTTPS se promítá i do secure session cookies v main.py (line 19).
This commit is contained in:
JiriUhlir
2026-06-08 11:21:29 +02:00
parent caeb7daf6f
commit 9916e4d833
4 changed files with 267 additions and 4 deletions
+55
View File
@@ -24,3 +24,58 @@ def read_env_value(key: str, default: str = "") -> str:
pass
return default
def read_env_bool(key: str, default: bool = False) -> bool:
value = read_env_value(key, "")
if value == "":
return default
return value.strip().lower() in {"1", "true", "yes", "on"}
def get_portal_public_url() -> str:
public_url = read_env_value("APPFACTORY_PORTAL_PUBLIC_URL", "").rstrip("/")
if public_url:
return public_url
domain = read_env_value("APPFACTORY_PORTAL_DOMAIN", "").strip()
if read_env_bool("APPFACTORY_ENABLE_HTTPS") and domain:
return f"https://{domain}"
return ""
def get_google_redirect_uri() -> str:
redirect_uri = read_env_value("GOOGLE_REDIRECT_URI", "").strip()
if redirect_uri:
return redirect_uri
public_url = get_portal_public_url()
if public_url:
return f"{public_url}/auth/google/callback"
return ""
def get_auth_domain_readiness() -> dict[str, bool]:
google_enabled = read_env_bool("GOOGLE_OAUTH_ENABLED")
google_client_id = read_env_value("GOOGLE_CLIENT_ID", "")
google_client_secret = read_env_value("GOOGLE_CLIENT_SECRET", "")
google_redirect_uri = get_google_redirect_uri()
return {
"portal_public_url_configured": bool(get_portal_public_url()),
"google_oauth_enabled": google_enabled,
"google_oauth_configured": bool(google_client_id and google_client_secret and google_redirect_uri),
"google_redirect_uri_configured": bool(google_redirect_uri),
"https_enabled": read_env_bool("APPFACTORY_ENABLE_HTTPS"),
}
def is_google_oauth_button_enabled() -> bool:
return bool(
read_env_bool("GOOGLE_OAUTH_ENABLED")
and read_env_value("GOOGLE_CLIENT_ID", "")
and read_env_value("GOOGLE_CLIENT_SECRET", "")
)