# Configuration In order to simplify the setup of the library, we provide the class `Lcobucci\JWT\Configuration`. It's meant for: * Configuring the default algorithm (signer) and key(s) to be used * Configuring the default set of validation constraints * Providing custom implementation for the [extension points](extending-the-library.md) * Retrieving components (encoder, decoder, parser, validator, and builder) ## Initialisation The `Lcobucci\JWT\Signer\Key\InMemory` object is used for symmetric/asymmetric signature. To initialise it, you can pass the key content as a plain text: ```php setBuilderFactory( static function (ClaimsFormatter $formatter): Builder { // This assumes `MyCustomBuilder` is an existing class return new MyCustomBuilder(new JoseEncoder(), $formatter); } ); ``` ### Parser It configures how the token parser should be created. It's useful when you want to provide a [custom Parser](extending-the-library.md#parser). ```php setParser(new MyParser()); ``` ### Validator It configures how the token validator should be created. It's useful when you want to provide a [custom Validator](extending-the-library.md#validator). ```php setValidator(new MyValidator()); ``` ### Validation constraints It configures which are the base constraints to be used during validation. ```php setValidationConstraints( new SignedWith($configuration->signer(), $configuration->signingKey()), new StrictValidAt(SystemClock::fromUTC()), new IssuedBy('https://api.my-awesome-company.com') ); ``` ## Retrieve components Once you've made all the necessary configuration you can pass the configuration object around your code and use the getters to retrieve the components: These are the available getters: * `Lcobucci\JWT\Configuration#builder()`: retrieves the token builder (always creating a new instance) * `Lcobucci\JWT\Configuration#parser()`: retrieves the token parser * `Lcobucci\JWT\Configuration#signer()`: retrieves the signer * `Lcobucci\JWT\Configuration#signingKey()`: retrieves the key for signature creation * `Lcobucci\JWT\Configuration#verificationKey()`: retrieves the key for signature verification * `Lcobucci\JWT\Configuration#validator()`: retrieves the token validator * `Lcobucci\JWT\Configuration#validationConstraints()`: retrieves the default set of validation constraints