Files
Enterprise-Knowledge-Base/internal/handler/dto/role.go
T
wizardchen fc64751f4e fix(security): close init config and parser-check redaction gaps
Strip model base URLs from viewer-accessible initialization config
responses and merge redacted parser secrets before engine check overrides
so admin test flows keep working after masked GET responses.
2026-07-02 14:41:42 +08:00

28 lines
764 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)
}
// RoleCanViewTenantAPIKey is true for Owner+ only.
func RoleCanViewTenantAPIKey(role types.TenantRole) bool {
return role.HasPermission(types.TenantRoleOwner)
}
// CanViewTenantAPIKey is true for Owner+ only.
func CanViewTenantAPIKey(ctx context.Context) bool {
return RoleCanViewTenantAPIKey(RoleFromContext(ctx))
}