feat(tenant): implement tenant creation limit and error handling

Added a new configuration option to limit the number of tenants a non-superuser can create via self-service. Introduced a new error type for handling cases where users exceed this limit, returning a 429 status code. Updated the tenant creation and update handlers to enforce this limit and provide appropriate feedback to users. Additionally, refactored the tenant update request structure to ensure only mutable fields are allowed.

Refs: #1303
This commit is contained in:
wizardchen
2026-05-16 10:37:25 +08:00
committed by lyingbug
parent 29dc99ae79
commit 7d030a6f6a
7 changed files with 497 additions and 698 deletions
+13
View File
@@ -110,6 +110,19 @@ func NewConflictError(message string) *AppError {
}
}
// NewTooManyRequestsError creates a 429 error, used by quota-style
// guards (e.g. per-user self-service tenant creation cap).
func NewTooManyRequestsError(message string) *AppError {
if message == "" {
message = "too many requests"
}
return &AppError{
Code: ErrTooManyRequests,
Message: message,
HTTPCode: http.StatusTooManyRequests,
}
}
// NewInternalServerError creates an internal server error
func NewInternalServerError(message string) *AppError {
if message == "" {