#950·jwt

\Lcobucci\JWT\Configuration::forSymmetricSigner should set up validations.

Author: SamMousaCreated Oct 27, 2022Updated Apr 17, 2024

When using a configuration object it makes sense to me to set up constraints when using helpers like forSymmetricSigner.

php
public static function forSymmetricSigner(
        Signer $signer,
        Key $key,
        ?Encoder $encoder = null,
        ?Decoder $decoder = null
    ): self {
        $result new self(
            $signer,
            $key,
            $key,
            $encoder,
            $decoder
        );
        $result->validationConstraints[] = new SignedWith($signer, $key);
        return $result;
    }

Of course this will then need to be kept in sync when someone calls setSigner later... So additional point: we should make Configuration immutable.