0b73080bb8
Prevent low-privileged tenant members from reading raw API keys and infrastructure credentials via tenant profile, KV config, model/MCP/web search listings, and KB initialization config responses.
23 lines
612 B
Go
23 lines
612 B
Go
package dto
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/Tencent/WeKnora/internal/types"
|
|
)
|
|
|
|
// RoleFromContext returns the caller's tenant role from ctx.
|
|
func RoleFromContext(ctx context.Context) types.TenantRole {
|
|
return types.TenantRoleFromContext(ctx)
|
|
}
|
|
|
|
// CanViewIntegrationSecrets is true for Admin+ (includes Owner).
|
|
func CanViewIntegrationSecrets(ctx context.Context) bool {
|
|
return RoleFromContext(ctx).HasPermission(types.TenantRoleAdmin)
|
|
}
|
|
|
|
// CanViewTenantAPIKey is true for Owner+ only.
|
|
func CanViewTenantAPIKey(ctx context.Context) bool {
|
|
return RoleFromContext(ctx).HasPermission(types.TenantRoleOwner)
|
|
}
|