Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants