Skip to content

Ability to have several public keys for JWT signature checking #544

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

Closed
wants to merge 2 commits into from
Closed

Ability to have several public keys for JWT signature checking #544

wants to merge 2 commits into from

Conversation

sebj54
Copy link
Contributor

@sebj54 sebj54 commented May 24, 2019

Here it is, as discussed in #540 :)

I see what you meant, the commented type in the function declaration is not pretty.
Tell me what you think of it, I'll do the docs before the merge.

@mevdschee
Copy link
Owner

the commented type in the function declaration is not pretty.

Yeah indeed, that is what I meant. I'm not sure how we should solve this.

@sebj54
Copy link
Contributor Author

sebj54 commented May 24, 2019

I'm not sure either, I looked for solutions in PHP's documentation but didn't find anything about mixed types. I presume it is a bad pattern 😁

The best solution I see is this one:

  1. Move the token deconstruction (string to array) in getClaims method.
  2. Get the kid in getClaims too
  3. Get the secret from property in that method too (and if it is an array, grab the correct key with kid)
  4. Pass the secret to getVerifiedClaims as a string, no matter if it is an array in the configuration

Plus, there is already this check in getClaims, which is also in getVerififedClaims:

if (!$secret) {
     return array();
}

Like this, we can get rid of the token deconstruction and early checks in getVerifiedClaims. We can even add a new method to get the secret from the array.

@sebj54
Copy link
Contributor Author

sebj54 commented May 27, 2019

Hi @mevdschee, I just pushed the updated code.
Tell me if it needs other improvements before merging!

@mevdschee
Copy link
Owner

Looks good to me.. I'll merge it soon and do a major version bump as I feel we may need to break BC in the middleware.. Thank you for your work!

@sebj54
Copy link
Contributor Author

sebj54 commented Jun 6, 2019

You're welcome!

The version bump sounds good to me as I changed a function signature.

@mevdschee
Copy link
Owner

mevdschee commented Sep 3, 2019

@sebj54 I would be very thankful if you would review/test the changes.

mevdschee added a commit that referenced this pull request Sep 3, 2019
Repository owner deleted a comment from sebj54 Sep 3, 2019
@mevdschee
Copy link
Owner

Thank you for your feedback

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

Successfully merging this pull request may close these issues.

2 participants