spelling: rotator
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
This commit is contained in:
parent
791ad900cb
commit
3f8fdbf314
@ -55,7 +55,7 @@ func defaultRotationStrategy(rotationFrequency, idTokenValidFor time.Duration) r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type keyRotater struct {
|
type keyRotator struct {
|
||||||
storage.Storage
|
storage.Storage
|
||||||
|
|
||||||
strategy rotationStrategy
|
strategy rotationStrategy
|
||||||
@ -69,10 +69,10 @@ type keyRotater struct {
|
|||||||
// The method blocks until after the first attempt to rotate keys has completed. That way
|
// The method blocks until after the first attempt to rotate keys has completed. That way
|
||||||
// healthy storages will return from this call with valid keys.
|
// healthy storages will return from this call with valid keys.
|
||||||
func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy, now func() time.Time) {
|
func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy, now func() time.Time) {
|
||||||
rotater := keyRotater{s.storage, strategy, now, s.logger}
|
rotator := keyRotator{s.storage, strategy, now, s.logger}
|
||||||
|
|
||||||
// Try to rotate immediately so properly configured storages will have keys.
|
// Try to rotate immediately so properly configured storages will have keys.
|
||||||
if err := rotater.rotate(); err != nil {
|
if err := rotator.rotate(); err != nil {
|
||||||
if err == errAlreadyRotated {
|
if err == errAlreadyRotated {
|
||||||
s.logger.Infof("Key rotation not needed: %v", err)
|
s.logger.Infof("Key rotation not needed: %v", err)
|
||||||
} else {
|
} else {
|
||||||
@ -86,7 +86,7 @@ func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-time.After(time.Second * 30):
|
case <-time.After(time.Second * 30):
|
||||||
if err := rotater.rotate(); err != nil {
|
if err := rotator.rotate(); err != nil {
|
||||||
s.logger.Errorf("failed to rotate keys: %v", err)
|
s.logger.Errorf("failed to rotate keys: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k keyRotater) rotate() error {
|
func (k keyRotator) rotate() error {
|
||||||
keys, err := k.GetKeys()
|
keys, err := k.GetKeys()
|
||||||
if err != nil && err != storage.ErrNotFound {
|
if err != nil && err != storage.ErrNotFound {
|
||||||
return fmt.Errorf("get keys: %v", err)
|
return fmt.Errorf("get keys: %v", err)
|
||||||
|
@ -57,7 +57,7 @@ func slicesEq(s1, s2 []string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestKeyRotater(t *testing.T) {
|
func TestKeyRotator(t *testing.T) {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
|
||||||
delta := time.Millisecond
|
delta := time.Millisecond
|
||||||
@ -73,7 +73,7 @@ func TestKeyRotater(t *testing.T) {
|
|||||||
Level: logrus.DebugLevel,
|
Level: logrus.DebugLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
r := &keyRotater{
|
r := &keyRotator{
|
||||||
Storage: memory.New(l),
|
Storage: memory.New(l),
|
||||||
strategy: defaultRotationStrategy(rotationFrequency, validFor),
|
strategy: defaultRotationStrategy(rotationFrequency, validFor),
|
||||||
now: func() time.Time { return now },
|
now: func() time.Time { return now },
|
||||||
|
Reference in New Issue
Block a user