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 engine api-compatible bearer token generation #2529

Merged
merged 3 commits into from
Aug 2, 2023

Conversation

Rjected
Copy link
Contributor

@Rjected Rjected commented Jul 28, 2023

Motivation

I was looking for a way to easily make engine API calls using ethers-rs / cast, and realized that there is no JWT signing / encoding, the token would have to be generated elsewhere, before using Authorization::Bearer.

Solution

This adds code used by lighthouse to communicate with an EL's engine API:
https://github.com/sigp/lighthouse/blob/dfcb3363c757671eb19d5f8e519b4b94ac74677a/beacon_node/execution_layer/src/engine_api/auth.rs#L132

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

Comment on lines 304 to 307
/// Returns a reference to the underlying byte array.
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Needs a way to get the underlying bytes back

Suggested change
/// Returns a reference to the underlying byte array.
pub fn as_bytes(&self) -> &[u8] {
&self.0
}
/// Returns a reference to the underlying byte array.
pub fn as_bytes(&self) -> &[u8; JWT_SECRET_LENGTH] {
&self.0
}
pub fn into_bytes(self) ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, added

@DaniPopes DaniPopes merged commit 4edbe5d into gakonst:master Aug 2, 2023
19 checks passed
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.

None yet

3 participants