Expand description
PDK Contracts Lib
Library for validating client credentials against Anypoint Platform API contracts in Flex Gateway custom policies. It periodically fetches contracts from the platform and keeps a local cache to enable fast authentication and authorization decisions within the policy request path.
§Highlights
- Local contracts cache with concurrency-safe updates
- Periodic polling and incremental updates from the platform
- Authorization via
client_idand authentication viaclient_id/client_secret - Helpers to parse HTTP Basic Auth credentials
§Primary types
ContractValidator: contracts fetch/update plusauthenticateandauthorizeClientData: 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 ContractValidator::authenticate() fails.
- Authorization
Error - Error returned when ContractValidator::authorize() fails.
- Basic
Auth Error - Error returned when basic_auth_credentials() fails.
- Update
Error - Error returned when ContractValidator::update_contracts() fails.
Functions§
- basic_
auth_ credentials - Extracts a pair of credentials from a Basic-Auth header.