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

feat: add key object v5 #365

Merged
merged 8 commits into from Nov 4, 2021
Merged

feat: add key object v5 #365

merged 8 commits into from Nov 4, 2021

Conversation

bshaffer
Copy link
Collaborator

@bshaffer bshaffer commented Nov 3, 2021

Modifications to POC PR #352

  • allow for Firebase\JWT\Key objects instead of using an array of $allowed_args. This is more secure because it ties a key to an algorithm
  • fully backwards compatible
  • updates documentation to only use recommended way
use Firebase\JWT\JWT;
use Firebase\JWT\Key;

// old
JWT::decode($jwt, $publicKey, ['RS256']);

// new
JWT::decode($jwt, new Key($publicKey, 'RS256'));

This prevents a certain kind of attack described in #351.
Releasing this as an optional feature in v5 will allow libraries to require 5.5^|6^ in composer when we make using the Key objects required in v6, and that will allow a smoother upgrade for everyone.

cc @paragonie-security

paragonie-security and others added 3 commits August 4, 2021 05:49
This aims to provide backwards compatibility by guessing the algorithm for a key based on the key's contents, but it will likely fail in corner cases.

If this is merged, users **SHOULD** be explicit about the algorithms they're using.

i.e. Instead of $keyAsString, pass in (new JWTKey($keyAsString, 'ES384'))
@google-cla

This comment has been minimized.

@google-cla google-cla bot added the cla: no label Nov 3, 2021
@google-cla

This comment has been minimized.

@google-cla

This comment has been minimized.

@google-cla

This comment has been minimized.

@google-cla

This comment has been minimized.

@paragonie-security
Copy link

paragonie-security commented Nov 3, 2021

@googlebot I consent.

@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 3, 2021
@bshaffer bshaffer merged commit bc0df64 into master Nov 4, 2021
@bshaffer bshaffer deleted the add-key-object-v5 branch November 4, 2021 16:15
@swiffer
Copy link

swiffer commented Dec 26, 2021

Providing algorithms as 3rd parameter is marked deprecated but still needs to be used when working with JWKs? Is this still true?

@bshaffer
Copy link
Collaborator Author

@swiffer no, it's not REQUIRED, it is possible to loop through the returned keys and create Key objects from them. This is the recommended way and i should probably update the docs with an example.

@swiffer
Copy link

swiffer commented Dec 26, 2021

@bshaffer as the keys array from the jwks is containing the alg for every key provided isn't it safe to rely on these and change the return value of parseKeySet to return Key objects directly?

@bshaffer
Copy link
Collaborator Author

@swiffer we can't change the return value without tagging a new major release, so the library won't be able to make that change until the next major version, which is the plan.

@swiffer
Copy link

swiffer commented Dec 26, 2021

Yes, have just figured that out this moment checking the pr for 6.0 - thanks a lot. Looking forward for the release!

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

Successfully merging this pull request may close these issues.

None yet

3 participants