refactor(auth): unify OIDC provisioning under shared default_tenant_mode policy

Drop the standalone OIDC_AUTH_DEFAULT_TENANT_MODE / oidc_auth.default_tenant_mode
knob so OIDC auto-provisioning and local password registration share the single
auth.default_tenant_mode policy (resolved by the callback handler). Repair
tenantless sessions by falling back to the first active membership on the login
happy path and stale-preference paths, allow tenantless PUT /auth/me/preferences,
clear the tenant snapshot on /auth/me responses without a tenant, and default the
frontend canCreateTenant capability to fail-closed until /auth/me confirms it.
This commit is contained in:
wizardchen
2026-07-13 18:26:18 +08:00
committed by lyingbug
parent ecf2c1fb9b
commit 87ba3fc2de
11 changed files with 64 additions and 41 deletions
+2
View File
@@ -85,6 +85,8 @@ func isTenantOptionalAPI(path, method string) bool {
switch {
case path == "/api/v1/auth/me" && (method == http.MethodGet || method == http.MethodPut):
return true
case path == "/api/v1/auth/me/preferences" && method == http.MethodPut:
return true
case path == "/api/v1/auth/logout" && method == http.MethodPost:
return true
case path == "/api/v1/auth/change-password" && method == http.MethodPost:
@@ -16,6 +16,7 @@ func TestTenantOptionalAPISurface(t *testing.T) {
}{
{http.MethodGet, "/api/v1/auth/me", true},
{http.MethodPut, "/api/v1/auth/me", true},
{http.MethodPut, "/api/v1/auth/me/preferences", true},
{http.MethodPost, "/api/v1/tenants", true},
{http.MethodGet, "/api/v1/me/invitations", true},
{http.MethodPost, "/api/v1/me/invitations/12/accept", true},