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

Generate JWT token using dynamic configuration #1192

Open
destructivecreator opened this issue Jan 10, 2024 · 0 comments
Open

Generate JWT token using dynamic configuration #1192

destructivecreator opened this issue Jan 10, 2024 · 0 comments

Comments

@destructivecreator
Copy link

Here is how I am generating a JWT token in my symfony application:
`public function createAccessToken(string $username, array $payload = []): array
{
$user = JWTUser::createFromPayload($username, $payload);

    $token = $this->jwtManager->createFromPayload($user, $payload);
    $payload = $this->jwtManager->parse($token);
    
    return [
        'token' => $token,
        'expireAt' => date(DATE_RFC3339_EXTENDED, $payload['exp'])
    ];
}`

I have set the configuration

lexik_jwt_authentication: secret_key: '%kernel.project_dir%/config/jwt/private.pem' public_key: '%kernel.project_dir%/config/jwt/public.pem' pass_phrase: '%env(JWT_PASSPHRASE)%' token_ttl: '%env(JWT_TTL)%'

and it all worked fine, until I have the need to generate a JWT token with dynamic configurations. Is it possible to achieve this somehow, I could not find anything in the documentation. I want to be able to pass the secret_ket and public_key + pass_phase in runtime ?

Ideas and workarounds are welcome :)

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