feat(auth): support tenantless provisioning and gated self-service workspace creation

Allow deployments to register users without auto-creating a personal tenant, expose creation policy via /auth/me, and guide tenantless accounts through a workspace onboarding flow.
This commit is contained in:
wizardchen
2026-07-13 18:04:14 +08:00
committed by lyingbug
parent 50b8c0a72e
commit ecf2c1fb9b
36 changed files with 1543 additions and 89 deletions
+21
View File
@@ -185,6 +185,27 @@ type RegisterRequest struct {
Username string `json:"username" binding:"required,min=2,max=50"`
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required,min=6"`
// TenantProvisioning is server-controlled registration context. It is
// deliberately excluded from JSON so a public caller cannot choose its
// own tenancy semantics. Empty preserves the historical behaviour and is
// treated as create_personal by UserService.Register.
TenantProvisioning TenantProvisioningMode `json:"-"`
}
// TenantProvisioningMode controls what UserService.Register does after it
// has validated the identity fields. Joining an existing tenant is
// orchestrated by the invitation handler because the invitation token is the
// authority for the target tenant and role.
type TenantProvisioningMode string
const (
TenantProvisioningCreatePersonal TenantProvisioningMode = "create_personal"
TenantProvisioningTenantless TenantProvisioningMode = "tenantless"
)
func (m TenantProvisioningMode) IsValid() bool {
return m == TenantProvisioningCreatePersonal || m == TenantProvisioningTenantless
}
// LoginResponse represents a login response