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
+16 -5
View File
@@ -24,11 +24,12 @@ const (
ErrValidation ErrorCode = 1010
// Tenant related error codes (2000-2099)
ErrTenantNotFound ErrorCode = 2000
ErrTenantAlreadyExists ErrorCode = 2001
ErrTenantInactive ErrorCode = 2002
ErrTenantNameRequired ErrorCode = 2003
ErrTenantInvalidStatus ErrorCode = 2004
ErrTenantNotFound ErrorCode = 2000
ErrTenantAlreadyExists ErrorCode = 2001
ErrTenantInactive ErrorCode = 2002
ErrTenantNameRequired ErrorCode = 2003
ErrTenantInvalidStatus ErrorCode = 2004
ErrTenantCreationDisabled ErrorCode = 2005
// Agent related error codes (2100-2199)
ErrAgentMissingThinkingModel ErrorCode = 2100
@@ -184,6 +185,16 @@ func NewTenantInactiveError() *AppError {
}
}
// NewTenantCreationDisabledError reports a deployment-policy denial for
// ordinary self-service tenant creation.
func NewTenantCreationDisabledError() *AppError {
return &AppError{
Code: ErrTenantCreationDisabled,
Message: "self-service tenant creation is disabled; join a workspace by invitation",
HTTPCode: http.StatusForbidden,
}
}
// Agent related errors
func NewAgentMissingThinkingModelError() *AppError {
return &AppError{