๐ชช Identity Validator Blocks
Identity validator blocks provide validation functions for identity-related operations. These validators ensure proper access control for identity resources.
๐ฏ Overviewโ
Identity validator blocks are designed to:
- Validate self-access to identity resources
- Support identity-type based gating via common validators
๐ Identity Validator Typesโ
Access Control Validatorsโ
Validators that check permissions for identity resources.
๐ง Available Identity Validatorsโ
isSelfโ
Validates that the authenticated user is accessing their own identity resource.
Purpose: Ensures an identity can access only its own resources
Parameters:
identityIdPathInPayload: tuple path to target identityId in payload (e.g.['params', 'requestParams', 'identityId'])
Returns: void - Passes through if the target identityId matches the authenticated identity
Throws:
- NodeblocksError (401) with message "Invalid token"
- NodeblocksError (403) with message "Identity ID is required"
- NodeblocksError (403) with message "Identity ID does not match"
Usage:
import { validators } from '@nodeblocks/backend-sdk';
const { isSelf } = validators;
withRoute({
-- snip --
validators: [
isSelf(['params', 'requestParams', 'identityId'])
],
});
๐ Related Documentationโ
- Common Validators -
checkIdentityTypefor type-based access