-
Notifications
You must be signed in to change notification settings - Fork 24
INFOPLAT 2963 beholder rotating auth headers loop impl #1609
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
Open
hendoxc
wants to merge
25
commits into
main
Choose a base branch
from
INFOPLAT-2963-beholder-rotating-auth-headers-loop-impl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a94c75b
INFOPLAT-2963 Adds TTL to loop config
hendoxc 76d8492
INFOPLAT-2963 Wires up `Keystore` as `Signer` impl for beholder headers
hendoxc 0ca9acd
Deferred signer
hendoxc 243ee13
Makes lazy signer an interface
hendoxc a8180d8
Removes keystore mentions from loop server
hendoxc 54deac7
Uses Initial provided headers to the lazy signer
hendoxc 0f81da9
Makes configuration more clear
hendoxc 303df4c
Simplify server beholder auth config
hendoxc d48f7b2
Adjust `Signer` interface to use `keyID string`
hendoxc 6d982fc
Example of setting signer
hendoxc 2abd8cf
`fmt`
hendoxc addb026
Sort `Auth` fields
hendoxc fa3d656
Reduces stuttering in interface
hendoxc 743b596
Address comments
hendoxc 716eed0
Sets config mechanism dependent on authheadertll
hendoxc b087dad
Merge branch 'main' into INFOPLAT-2963-beholder-rotating-auth-headers…
hendoxc 2b77990
Wire up beholder client in relayer
hendoxc 08a8370
Merge branch 'INFOPLAT-2963-beholder-rotating-auth-headers-loop-impl'…
hendoxc 7a0497f
Merge branch 'main' into INFOPLAT-2963-beholder-rotating-auth-headers…
hendoxc 2cf0fcf
Simply setting signer
hendoxc 6b1456f
Merge branch 'INFOPLAT-2963-beholder-rotating-auth-headers-loop-impl'…
hendoxc e0b201d
Updates `SetSigner` comment
hendoxc 6781ddd
Removes deferred beholder signer wire up
hendoxc b2413bd
Merge branch 'main' into INFOPLAT-2963-beholder-rotating-auth-headers…
hendoxc 8f9ed7a
Fixes merge conflict
hendoxc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
package beholder | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"sync" | ||
) | ||
|
||
type LazySigner interface { | ||
hendoxc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Sign(ctx context.Context, keyID string, data []byte) ([]byte, error) | ||
SetSigner(signer Signer) | ||
HasSigner() bool | ||
} | ||
hendoxc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// lazyKeystoreSigner is a thread-safe wrapper that allows the keystore | ||
// to be set after the signer is created. This enables beholder to start | ||
// with rotating auth configured, but the actual keystore can be injected later. | ||
type lazySigner struct { | ||
mu sync.RWMutex | ||
Signer | ||
} | ||
|
||
func NewLazySigner() LazySigner { | ||
return &lazySigner{mu: sync.RWMutex{}, Signer: nil} | ||
} | ||
hendoxc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// Sign implements the beholder.Signer interface | ||
func (l *lazySigner) Sign(ctx context.Context, keyID string, data []byte) ([]byte, error) { | ||
l.mu.RLock() | ||
defer l.mu.RUnlock() | ||
|
||
if l.Signer == nil { | ||
return nil, fmt.Errorf("keystore not yet available for signing") | ||
} | ||
|
||
return l.Signer.Sign(ctx, keyID, data) | ||
} | ||
|
||
// SetKeystore updates the underlying keystore. This is thread-safe and can be | ||
// called at any time, even after beholder has been initialized. | ||
func (l *lazySigner) SetSigner(signer Signer) { | ||
l.mu.Lock() | ||
defer l.mu.Unlock() | ||
l.Signer = signer | ||
} | ||
|
||
// HasKeystore returns true if a keystore has been set | ||
func (l *lazySigner) HasSigner() bool { | ||
l.mu.RLock() | ||
defer l.mu.RUnlock() | ||
return l.Signer != nil | ||
} |
This file contains hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.