-
Couldn't load subscription status.
- Fork 837
client: Jwt token based auth for engine api #1723
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
Conversation
Codecov Report
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
I know this is probably not fair to ask but is there any way we can avoid adding adding |
ummm... reason to add express was to primarily intercept the requests as jayson seems to not provide middleware-ing capability. |
|
Could work, or as simple as just using the built in router capability to check the jwt on receipt using your preferred (dependency minimized jwt library) and then calling the right message handler |
method routing doesn't seem to provide handle on req or headers for jwt token to be extracted and validated. |
|
Does this |
unfortunately, the libraries' examples of building that context itself requires using express/connect to plug in a json body parser. If we totally want to avoid any extra dependency, we can catch inbuild's http req via http.createServer((req,res)=>{...}), collect data chunks, parse them (and validate the headers) and then call jayson's server.call to pass on the request for evaluation. Thats exactly what jayson is trying to do under the hood (minus the auth part): https://github.com/tedeh/jayson/blob/master/lib/utils.js#L138-L160 |
|
Hmm, okay. I still think we should consider minimizing the number of new dependencies we add in and lean on standard nodejs inbuilts where feasible, even if it is |
|
@acolytec3 appreciate you taking a look, jayson already uses express under the hood so it was already a transitive dependency, we just need to use it in this way to get deeper in the stack as the jayson readme suggests. I'll be reviewing this PR today and see if we can simplify at all based on your suggestion, but it might be needed in this case. (Edit: nvm I guess it doesn't use express by default as it's only in devDeps for jayson! My bad. I'll investigate if we can use @g11tech's suggestion to model after the internal util method.) |
|
Fair. I didn't look down the dependency tree so not to worry if it's already there. |
|
ok this looks pretty awesome! just went over all the code and had just a few things i included in some commits. i did try to connect to lodestar but i don't think i have the right command handy, i pulled and built this branch ChainSafe/lodestar#3777 - how should i run lodestar on kiln? our typical kintsugi run looked like this: i did have one question if it's possible to also do this auth with the websockets endpoint? i know some CL clients were communicating over ws regarding not using express, I'm sympathetic as a way to reduce our dep count, so @g11tech if you want to see if it's possible without writing too much boilerplate code we should definitely consider it. perhaps give your suggested route a try and see if it's doable within a few hours and report back. if it gets needlessly complicated and we find express provides enough value in exchange for the added dep bloat, then we can take that route. |
Thank you ❤️
yes this command would work, but lodestar master (and the above branch) is now incompatible with kintsugi because of kiln updates. However your merge-kiln PR can be reabased on top of this for interop with lodestar
let me dig into it
Yes I agree, swapped express with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! let's wait a few days before merging until we get either a new spec release or when your lodestar PR is merged, so it doesn't break current engine connections for devnet-4
|
@g11tech sorry i don't seem to be able to reopen this PR, but once i have merge-kiln-v2 branch up you can target that as base branch |
Kiln spec v2 has jwt based auth for the CL requests for engine methods with following validations
--jwt-secretparam for fileThis PR intends to implement the same.
TODOS: