fc64751f4e
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.
28 lines
764 B
Go
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))
|
|
}
|