refactor(protocol): centralize tenants.* RPC method names as constants (#1371)

The tenants.* methods were the only RPC group without MethodXxx
constants in pkg/protocol/methods.go. Their wire names were hardcoded
as raw string literals across three call sites — router registration,
and the read/admin allowlists in the permission policy — which is
inconsistent with the other 147 methods and risks silent drift: a
typo in any allowlist string is not caught by the compiler and would
fail-closed (deny) at runtime, which is hard to diagnose.

Add MethodTenants{List,Get,Create,Update,UsersList,UsersAdd,
UsersRemove,Mine} and replace the method-identifier literals in
internal/permissions/policy.go and internal/gateway/methods/tenants.go
with the constants.

No behavior change — string values are identical. Human-facing error
labels and log prefixes in internal/http/tenants.go are intentionally
left as free-form text, matching the sibling HTTP handler convention.
This commit is contained in:
fastopencn authored and GitHub committed 2026-07-07 12:54:08 +07:00
1 parent b5895c0a05
commit 93eef5feac
3 files changed
+28 -16

No files matched your search

+12
View File
@@ -165,6 +165,18 @@ const (
MethodTeamsEventsList = "teams.events.list"
)
// Tenants (multi-tenant management)
const (
MethodTenantsList = "tenants.list"
MethodTenantsGet = "tenants.get"
MethodTenantsCreate = "tenants.create"
MethodTenantsUpdate = "tenants.update"
MethodTenantsUsersList = "tenants.users.list"
MethodTenantsUsersAdd = "tenants.users.add"
MethodTenantsUsersRemove = "tenants.users.remove"
MethodTenantsMine = "tenants.mine"
)
// API key management
const (
MethodAPIKeysList = "api_keys.list"