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

INFOPLAT-1562 dynamic expiring auth headers #974

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

hendoxc
Copy link

@hendoxc hendoxc commented Dec 13, 2024

INFOPLAT-1560

What

Allows usage of dynamic auth headers by implementing grpc.PerRPCCredentials & setting as a DialOption on the otel client

Why

Makes tokens expire, in the case that one is leaked or intercepted.

  • someone can indeed steal a token, update the timestamp portion of the token, then try send data to the gateway endpoint, however since pubkey bytes + timestamp bytes are what's being signed, the signature part of the token is invalid, and will be rejected by the gateway
  • on the gateway, version 2 tokens have their timestamp part checked time.Now > timestamp > time.Now - serverTTL

Notes

Current users of the client can still configure static headers using the AuthHeaders field of beholder client Config. To enable dynamic headers they instead should configure AuthHeaderProvider

pkg/beholder/auth.go Outdated Show resolved Hide resolved
pkg/beholder/auth.go Outdated Show resolved Hide resolved
pkg/beholder/auth.go Outdated Show resolved Hide resolved
pkg/beholder/auth.go Outdated Show resolved Hide resolved
pkg/beholder/auth.go Outdated Show resolved Hide resolved
hendoxc and others added 6 commits December 17, 2024 11:14
- Adds function for signing publickey + timestamp.
- Adjusts `BuildAuthHeaders` to take variadic args allowing backwards compatibiilty

INFOPLAT-1559 Fixes some lint issues

INFOPLAT-1559 Handles edge case of negative timestamps

INFOPLAT-1559 Switches to exposing new function

- go recommended way to add extend a function
- added Config as 2nd arg as opposed to optional args

INFOPLAT-1559 Adjusts `authHeaderVersion2`

- minor refactor of test

INFOPLAT-1559 Tightens time range for test

Update pkg/beholder/auth.go

Co-authored-by: 4of9 <177086174+4of9@users.noreply.github.com>
- allows for dynamic headers auth tokens to be used in GRPC request headers
- auto refreshes the token on interval
…c `AuthHeaders`

Need this for migration of existing usage - current users of beholder can still use never verions while using static headers, but can make the switch across to setting `AuthHeaderProvider`
bit more clear conceptually
protects against concurrent calls of `refresh`

INFOPLAT-1560 Makes `refresh` thread safe
@hendoxc hendoxc dismissed stale reviews from cll-gg and 4of9 via f196c1a January 8, 2025 20:00
@hendoxc hendoxc force-pushed the INFOPLAT-1562-dynamic-expiring-auth-headers branch from f196c1a to 2bb5c5c Compare January 8, 2025 20:12

// authHeaderPerRPCredentials is a PerRPCCredentials implementation that provides the auth headers
type authHeaderPerRPCCredentials struct {
privKey ed25519.PrivateKey
Copy link
Contributor

Choose a reason for hiding this comment

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

Passing a private key around will make eventual isolation of the keystore difficult. If possible, I'd like to see us use the keystore directly here

…ble refresh

refersh mechanism is configurable such that it can be used in loops where gRPC calls back to the core node.

On the core node itself, the csa private key is accessible though the keystore, so we can just call `BuildAuthHeadersV2`
…com:smartcontractkit/chainlink-common into INFOPLAT-1562-dynamic-expiring-auth-headers
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.

6 participants