Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
3f8fdbf3
Commit
3f8fdbf3
authored
4 years ago
by
Josh Soref
Browse files
Options
Downloads
Patches
Plain Diff
spelling: rotator
Signed-off-by:
Josh Soref
<
jsoref@users.noreply.github.com
>
parent
791ad900
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/rotation.go
+5
-5
5 additions, 5 deletions
server/rotation.go
server/rotation_test.go
+2
-2
2 additions, 2 deletions
server/rotation_test.go
with
7 additions
and
7 deletions
server/rotation.go
+
5
−
5
View file @
3f8fdbf3
...
...
@@ -55,7 +55,7 @@ func defaultRotationStrategy(rotationFrequency, idTokenValidFor time.Duration) r
}
}
type
keyRotat
e
r
struct
{
type
keyRotat
o
r
struct
{
storage
.
Storage
strategy
rotationStrategy
...
...
@@ -69,10 +69,10 @@ type keyRotater struct {
// 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.
func
(
s
*
Server
)
startKeyRotation
(
ctx
context
.
Context
,
strategy
rotationStrategy
,
now
func
()
time
.
Time
)
{
rotat
e
r
:=
keyRotat
e
r
{
s
.
storage
,
strategy
,
now
,
s
.
logger
}
rotat
o
r
:=
keyRotat
o
r
{
s
.
storage
,
strategy
,
now
,
s
.
logger
}
// Try to rotate immediately so properly configured storages will have keys.
if
err
:=
rotat
e
r
.
rotate
();
err
!=
nil
{
if
err
:=
rotat
o
r
.
rotate
();
err
!=
nil
{
if
err
==
errAlreadyRotated
{
s
.
logger
.
Infof
(
"Key rotation not needed: %v"
,
err
)
}
else
{
...
...
@@ -86,7 +86,7 @@ func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy
case
<-
ctx
.
Done
()
:
return
case
<-
time
.
After
(
time
.
Second
*
30
)
:
if
err
:=
rotat
e
r
.
rotate
();
err
!=
nil
{
if
err
:=
rotat
o
r
.
rotate
();
err
!=
nil
{
s
.
logger
.
Errorf
(
"failed to rotate keys: %v"
,
err
)
}
}
...
...
@@ -94,7 +94,7 @@ func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy
}()
}
func
(
k
keyRotat
e
r
)
rotate
()
error
{
func
(
k
keyRotat
o
r
)
rotate
()
error
{
keys
,
err
:=
k
.
GetKeys
()
if
err
!=
nil
&&
err
!=
storage
.
ErrNotFound
{
return
fmt
.
Errorf
(
"get keys: %v"
,
err
)
...
...
This diff is collapsed.
Click to expand it.
server/rotation_test.go
+
2
−
2
View file @
3f8fdbf3
...
...
@@ -57,7 +57,7 @@ func slicesEq(s1, s2 []string) bool {
return
true
}
func
TestKeyRotat
e
r
(
t
*
testing
.
T
)
{
func
TestKeyRotat
o
r
(
t
*
testing
.
T
)
{
now
:=
time
.
Now
()
delta
:=
time
.
Millisecond
...
...
@@ -73,7 +73,7 @@ func TestKeyRotater(t *testing.T) {
Level
:
logrus
.
DebugLevel
,
}
r
:=
&
keyRotat
e
r
{
r
:=
&
keyRotat
o
r
{
Storage
:
memory
.
New
(
l
),
strategy
:
defaultRotationStrategy
(
rotationFrequency
,
validFor
),
now
:
func
()
time
.
Time
{
return
now
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment