🔐 Authentication Validator Blocks
Authentication validator blocks provide validation functions for authentication-related operations in Nodeblocks applications. These validators ensure proper authentication for protected routes and resources.
🎯 Overview
Authentication validator blocks are designed to:
- Validate authentication tokens before route access
- Support multiple authentication methods (Bearer tokens, cookies)
- Provide reusable authentication logic for route protection
- Handle authentication errors with proper error responses
📋 Authentication Validator Types
Token Validators
Validators that check and validate authentication tokens.
🔧 Available Authentication Validators
verifyAuthentication
Validates authentication using a provided authenticator function.
Purpose: Ensures the request is properly authenticated before proceeding with operations
Parameters:
authenticate
:Authenticator
- Authentication function to validate tokenspayload
:RouteHandlerPayload
- Contains request context and data
Returns: void
- Passes through if authentication succeeds
Throws: Any errors thrown by the authenticate
function (typically NodeblocksError for authentication failures)
Usage:
import { validators } from '@nodeblocks/backend-sdk';
const { verifyAuthentication } = validators;
// Usage in a route pipeline:
compose(verifyAuthentication(getBearerTokenInfo), protectedHandler);
🔗 Related Documentation
- Authentication Schema Blocks - Authentication data validation and contracts
- Authentication Handler Blocks - Authentication business logic functions
- Authentication Route Blocks - Authentication HTTP endpoint definitions
- Authentication Feature Blocks - Authentication composed features