refactor(api-keys): update role handling and enhance API key restrictions

Change the default role for tenant API keys from 'admin' to 'owner' to align with the new authorization model. Update related tests to reflect this change, ensuring that API keys with the owner role are correctly denied access to management paths and system-admin routes. Introduce new tests to validate that API keys are properly restricted from accessing sensitive endpoints, reinforcing the security measures in place.
This commit is contained in:
wizardchen
2026-07-06 18:13:37 +08:00
committed by lyingbug
parent a6759d61b5
commit 1d1e1e3d25
7 changed files with 143 additions and 25 deletions
+1 -1
View File
@@ -576,7 +576,7 @@ func (h *TenantHandler) ResetAPIKey(c *gin.Context) {
result, err := h.apiKeyService.CreateAPIKey(ctx, interfaces.TenantAPIKeyCreateRequest{
TenantID: id,
Name: "Tenant API key",
Role: types.TenantRoleAdmin,
Role: types.TenantRoleOwner,
})
if err != nil {
if appErr, ok := errors.IsAppError(err); ok {