Expand description
PDK Contracts Library
Library for validating client credentials against Anypoint Platform API contracts in Flex Gateway custom policies.
§Highlights
ContractValidator: periodic polling and incremental updates from the platform with a local cache for synchronousauthenticateandauthorizedecisions- Authorization via
client_idand authentication viaclient_id/client_secret - Helpers to parse HTTP Basic Auth credentials
§Primary types
ContractValidator: periodic polling + local cache validationClientData: resolved client metadata for successful validationsbasic_auth_credentials: parse the HTTP BasicAuthorizationheaderBasicAuthError
§Readiness and polling cadence
- Use
ContractValidator::is_readyto check if contracts have been pulled and cached locally. - Call
ContractValidator::update_contractsperiodically. During startup, invoke it everyContractValidator::INITIALIZATION_PERIOD. After initialization, invoke it everyContractValidator::UPDATE_PERIOD.
Structs§
- Client
Data - The information regarding the client that was authenticated or authorized.
- Client
Id - Represents a client ID credential.
- Client
Secret - Represents a client secret credential. This type ensures secure memory management by zeroing memory on drop. Debug printing is safe since the internal representation is hidden.
- Contract
Validator - The object that will collect the contracts and provide the functionality to validate incoming requests.
Enums§
- Authentication
Error - Error returned when authentication fails.
- Authorization
Error - Error returned when authorization fails.
- Basic
Auth Error - Error returned when basic_auth_credentials() fails.
- Update
Error - Error returned when updating contracts fails.
Functions§
- basic_
auth_ credentials - Extracts a pair of credentials from a Basic-Auth header.