Skip to content

The open alternative to Salesforce, designed for AI.

1.0 KB
Raw Blame
import { createGuardedEndpointRule } from '../utils/createGuardedEndpointRule';

export const RULE_NAME = 'graphql-resolvers-should-be-guarded';

export const rule = createGuardedEndpointRule({
  triggerDecorators: ['Query', 'Mutation', 'Subscription'],
  messageId: 'graphqlResolversShouldBeGuarded',
  description:
    'GraphQL root resolvers (Query, Mutation, Subscription) should declare the principals they accept with AuthPrincipalGuard({ ... }) or be explicitly marked as public (PublicEndpointGuard), and have permission guards (SettingsPermissionGuard or CustomPermissionGuard) to maintain our security model. AccessPolicyGuard covers both.',
  message:
    'All GraphQL resolvers must have an authentication guard (@UseGuards(AuthPrincipalGuard({ ... })) or PublicEndpointGuard) and permission guards (@UseGuards(..., SettingsPermissionGuard(PermissionFlagType.XXX)), CustomPermissionGuard for custom logic, or NoPermissionGuard for special cases like onboarding), or a single AccessPolicyGuard covering both.',
});