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

ES256 support #170

Closed
wants to merge 6 commits into from
Closed

ES256 support #170

wants to merge 6 commits into from

Conversation

ivn-cote
Copy link
Contributor

@ivn-cote ivn-cote commented Sep 7, 2020

Description

This PR contains POC for ES256 support. ES256 is similar to RS256, but uses elliptic curve (EC) based crypto instead of RSA.

From implementation side, we've chosen jose library to convert JWK format to PEM because other libraries do not support EC keys.

I understand this library provides only RSA support for now, but I'd like to promote changes since library is part of JWT validation ecosystem, and plays a vital role as such on many projects. It means providing more general validation would be beneficial for the community.

References

https://github.com/auth0/node-jwks-rsa/issues?q=is%3Aissue+ec

Testing

More tests should be added.

  • This change adds test coverage for new/changed/fixed functionality

Checklist

  • I have added documentation for new/changed functionality in this PR or in auth0.com/docs
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not master

@ivn-cote ivn-cote requested a review from a team September 7, 2020 09:13
}
// if (!header || header.alg !== 'RS256') {
// return cb(null, null);
// }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this should be removed, then it should be removed, not commented out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for that, it was in not up to date branch I pushed first.

@@ -1,13 +1,14 @@
{
"name": "jwks-rsa",
"version": "1.9.0",
"version": "2.0.0-beta",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this would affect the auth0 release/package management, if we're changing version in their master branch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a proposal for now, I actually don't know the release process here and need a guidance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove the version proposal from the changeset.

@ivn-cote
Copy link
Contributor Author

@lbalmaceda @damieng @sandrinodimattia can I have your input here? Thank you!

Copy link
Contributor

@panva panva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json engines entry would be greatly valuable since the jose dependency does come with runtime requirements that should be made clear to the module's consumers.

Furthermore the whole implementation could be made way simpler, the rsa utils bundled can get removed and to get all the keys (not just RSA or EC ones, also OKP) all in one go, no need to duplicate code for each key type.

let jwks = JSON.parse(jwks_uri_response)
let keystore = jose.JWKS.asKeyStore(jwks, { ignoreErrors: true })
let signingKeys = keystore.all({ use: 'sig' }).map((key) => {
  return {
	kid: key.kid,
    get publicKey() { return key.toPEM(false) },
    getPublicKey() { return key.toPEM(false) },
    get keyObject() { return key.keyObject }
  }
})

package.json Outdated
"description": "Library to retrieve RSA public keys from a JWKS endpoint",
"main": "lib/index.js",
"types": "index.d.ts",
"dependencies": {
"@types/express-jwt": "0.0.42",
"axios": "^0.19.2",
"debug": "^4.1.0",
"jose": "^1.28.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jose@2 is already available

@davidpatrick
Copy link
Contributor

@ivn-cote thanks for taking the time to raise this PR. Would you be willing to contribute @panva's suggested improvements? We are currently evaluating whether setting the engine in a minor or major makes most sense for this library. Jose will bump us to Node 10 which more than likely will cut a new major for this library considering we still have about 15% of users on Node 8.x.

@ivn-cote
Copy link
Contributor Author

@davidpatrick yes I aim to apply: 1) jose@2, 2) updating engines, 3) keeping a major bump, 4) refactor the code proposal.

@ivn-cote ivn-cote mentioned this pull request Sep 29, 2020
2 tasks
@ivn-cote
Copy link
Contributor Author

@davidpatrick @panva I've updated the PR with the recommendations provided earlier.

@davidpatrick davidpatrick self-assigned this Oct 13, 2020
@davidpatrick davidpatrick self-requested a review October 13, 2020 03:23
@@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: circleci/node:10
- image: circleci/node:13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be testing with a matrix here, 10, 12, 14.

@@ -1,13 +1,14 @@
{
"name": "jwks-rsa",
"version": "1.9.0",
"version": "2.0.0-beta",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove the version proposal from the changeset.

@davidpatrick davidpatrick added this to the v2-Next milestone Oct 15, 2020
@davidpatrick
Copy link
Contributor

@ivn-cote I just wanted to give you a heads up that I'll be revisiting this PR after our last planned minor for 1.x.

@panva panva mentioned this pull request Dec 9, 2020
4 tasks
@davidpatrick davidpatrick removed this from the v2-Next milestone Jan 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants