Expose jwtDecode to allow fastify-auth0-verify to use lookup/decode logic#178
Expose jwtDecode to allow fastify-auth0-verify to use lookup/decode logic#178climba03003 merged 1 commit intofastify:masterfrom
Conversation
Eomm
left a comment
There was a problem hiding this comment.
I think adding the decorator for this feature request is good and solve the replicated code and feature 👍🏽
It is not totally clear to me the additional level on the input options object ( options.decode, options.verify and options.sign ) since that argument should be already passed to the jwt module - could you check if it is needed?
Regarding the lines to update here: https://github.com/nearform/fastify-auth0-verify/blob/master/index.js#L153-L165
I would point out that it is necessary to give to the user an extra configuration setting here:
|
@Eomm Here is a quick diff for what I expect would be the integration: |
|
I am second guessing this PR now. I have been thinking through how we could make this non-breaking for fastify-auth0-verify, and I am not sure it is possible in the way I have it written. I might need to go back to the drawing board. We might want to expose lookupToken instead. I suppose the trade off is:
Thoughts @simoneb ? |
Not necessary. If we configure (and in a next major version of this plugin, we will add it by default)
I tried to figure out why this would be necessary, but I did not understand actually. |
|
@Eomm To make sure I understand, you are suggesting that upon fastify-jwt registration the user must pass in a value to enable the exposure of jwtDecode? fastify.register(require('fastify-jwt'), {
secret: 'supersecret',
jwtDecode: true
})If so this would absolutely work and is a great suggestion. We would not need to expose lookupToken if we went this direction. The three options I gave above are all ways to solve the breaking change issue, but I like your fourth option the best. |
|
Yes @markrzen , exactly. The only change is that the Could you add a |
|
@Eomm Works great for me. I will make those changes, update the README and do my best to update the types. Heads up on the types, I don't use TypeScript, so you will want to second guess my solution there :) |
It is not blocking, but it should not be too much hard to get inspiration from the other tests |
|
@Eomm Working on the final changes now. Should be ready shortly. |
|
@Eomm Sans rebase/squash/fixup, how does this look? |
Eomm
left a comment
There was a problem hiding this comment.
Almost done
We will need 2 approvals before merge
|
@Eomm The benchmark script doesn't seem to exist in the repo. Is this a typo on the PR template? |
cd9fa71 to
f56c6dd
Compare
|
@Eomm All set. Let me know if there is anything else. |
Expose
jwtDecodefunctionality, which includes the ability to change how the token is looked up, to enable fastify-auth0-verify to re-use this functionality, instead of re-write it.Checklist
npm run testandnpm run benchmarkand the Code of conduct