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

Multiple JWT signers not working as expected #147

Open
Samsv77 opened this issue Jun 23, 2023 · 1 comment
Open

Multiple JWT signers not working as expected #147

Samsv77 opened this issue Jun 23, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Samsv77
Copy link

Samsv77 commented Jun 23, 2023

Describe the bug

I am building an app that accepts 2 different JWTs for authentication, 1 that is generated by the app itself, 1 that is generated by an external entity.
As a result I am using 2 signers,

app.jwt.signers.use(.hs256(key: authSecret))    // For local app auth 
app.jwt.signers.use(.es256(key: .public(pem: ecdsaPublicKey))   // For external entity JWT auth

Per Vapor doc it should work, my app should accept either JWT and authenticate
But in reality it is only using the 1st signer, or whichever is set to default. If the 1st signer fail to validate the JWT, authentication fails with the error: signature verification failed
If I declare the ECDSA signer 1st, I can only validate JWTs with this signer, other JWTs will fail with the error signature verification failed

Is it a bug or expected behavior ?
If expected behavior, how can I accept 2 different JWTs ?

Note: I also tried with kid, but this expects the external entity to generate a JWT with the kid as well.

Expected behavior

Vapor should loop through the signers and verify the JWT.
Authentication should succeed if any of the signer is able to verify the JWT, and fail only if none of the signers can verify.

Environment

  • Vapor Framework version: 4.67.3 - 4.77.0
  • JWT version: 4.2.1
@0xTim
Copy link
Member

0xTim commented Feb 21, 2024

@ptoffy something to check - don't need to wait on the beta for it but we should check before the 5.0 actual release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants