forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit 4b9c307 Author: Amir Hossein <77993374+Kamandlou@users.noreply.github.com> Date: Fri Sep 2 20:37:55 2022 +0430 trie: fix unhandled error in test (ethereum#25628) commit 0d68b6b Author: Seungbae Yu <dbadoy4874@gmail.com> Date: Sat Sep 3 00:48:26 2022 +0900 trie: fix typo in comment (ethereum#25667) commit 38e002f Author: Seungbae Yu <dbadoy4874@gmail.com> Date: Sat Sep 3 00:47:29 2022 +0900 rpc: check that "version" is "2.0" in request objects (ethereum#25570) The JSON-RPC spec requires the "version" field to be exactly "2.0", so we should verify that. This change is not backwards-compatible with sloppy client implementations, but I decided to go ahead with it anyway because the failure will be caught via the returned error. commit 90711ef Author: protolambda <proto@protolambda.com> Date: Fri Sep 2 17:40:41 2022 +0200 node, rpc: add JWT auth support in client (ethereum#24911) This adds a generic mechanism for 'dial options' in the RPC client, and also implements a specific dial option for the JWT authentication mechanism used by the engine API. Some real tests for the server-side authentication handling are also added. Co-authored-by: Joshua Gutow <jgutow@optimism.io> Co-authored-by: Felix Lange <fjl@twurst.com> commit 7f2890a Author: Martin Holst Swende <martin@swende.se> Date: Fri Sep 2 17:28:33 2022 +0200 eth/fetcher: throttle peers which deliver many invalid transactions (ethereum#25573) Co-authored-by: Felix Lange <fjl@twurst.com>
- Loading branch information
1 parent
674da29
commit c419435
Showing
20 changed files
with
672 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2022 The go-ethereum Authors | ||
// This file is part of the go-ethereum library. | ||
// | ||
// The go-ethereum library is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The go-ethereum library is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
package node | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"time" | ||
|
||
"github.com/ethereum/go-ethereum/rpc" | ||
"github.com/golang-jwt/jwt/v4" | ||
) | ||
|
||
// NewJWTAuth creates an rpc client authentication provider that uses JWT. The | ||
// secret MUST be 32 bytes (256 bits) as defined by the Engine-API authentication spec. | ||
// | ||
// See https://github.com/ethereum/execution-apis/blob/main/src/engine/authentication.md | ||
// for more details about this authentication scheme. | ||
func NewJWTAuth(jwtsecret [32]byte) rpc.HTTPAuth { | ||
return func(h http.Header) error { | ||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, jwt.MapClaims{ | ||
"iat": &jwt.NumericDate{Time: time.Now()}, | ||
}) | ||
s, err := token.SignedString(jwtsecret[:]) | ||
if err != nil { | ||
return fmt.Errorf("failed to create JWT token: %w", err) | ||
} | ||
h.Set("Authorization", "Bearer "+s) | ||
return nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.