Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional_public_keys as strings? #1253

Open
nuryagdym opened this issue Nov 14, 2024 · 1 comment
Open

additional_public_keys as strings? #1253

nuryagdym opened this issue Nov 14, 2024 · 1 comment

Comments

@nuryagdym
Copy link

nuryagdym commented Nov 14, 2024

I see that additional_public_keys can only be files:

if (!$key || !is_file($key) || !is_readable($key)) {
throw new \RuntimeException(sprintf('Additional public key "%s" does not exist or is not readable. Did you correctly set the "lexik_jwt_authentication.additional_public_keys" configuration key?', $key));
}

For public_keys are on the hand we can use string values.

I work on a project where using files for secrets are not supported, so I have to use plain texts for secrets.

Can we add support for plain strings for additional keys? I can work on the PR if you think the change is meaningful.

Sure, I can also override key loader, but still maybe someone will have the same issue.

@nuryagdym
Copy link
Author

nuryagdym commented Nov 14, 2024

seems like there is an old open PR #1008 .

Overriding key loader is not a clean solution because I also needed override service lexik_jwt_authentication.jws_provider.lcobucci, which means lexik jwt configs will be in 2 different places.

Here is how I did it:

  1. created App\Security\RawKeyLoader class that extends Lexik\Bundle\JWTAuthenticationBundle\Services\KeyLoader\RawKeyLoader
    custom_jwt_key_loader:
        class: App\Security\RawKeyLoader
        parent: lexik_jwt_authentication.key_loader.raw

    custom_jws_provider:
        class: Lexik\Bundle\JWTAuthenticationBundle\Services\JWSProvider\LcobucciJWSProvider
        arguments:
            $keyLoader: '@custom_jwt_key_loader'
            $signatureAlgorithm: 'RS256'
            $ttl: '%env(ACCESS_TOKEN_TTL)%'
            $clockSkew: 0

    lexik_jwt_authentication.jws_provider.lcobucci:
        alias: "custom_jws_provider"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant