Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
753526a5
Commit
753526a5
authored
Jul 19, 2017
by
rithu john
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
server/rotation.go: Fix key rotation with multiple dex instances.
parent
2f0ac68d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
rotation.go
server/rotation.go
+8
-1
No files found.
server/rotation.go
View file @
753526a5
...
...
@@ -5,6 +5,7 @@ import (
"crypto/rand"
"crypto/rsa"
"encoding/hex"
"errors"
"fmt"
"io"
"time"
...
...
@@ -15,6 +16,8 @@ import (
"github.com/coreos/dex/storage"
)
var
errAlreadyRotated
=
errors
.
New
(
"keys already rotated by another server instance"
)
// rotationStrategy describes a strategy for generating cryptographic keys, how
// often to rotate them, and how long they can validate signatures after rotation.
type
rotationStrategy
struct
{
...
...
@@ -70,8 +73,12 @@ func (s *Server) startKeyRotation(ctx context.Context, strategy rotationStrategy
// Try to rotate immediately so properly configured storages will have keys.
if
err
:=
rotater
.
rotate
();
err
!=
nil
{
if
err
==
errAlreadyRotated
{
s
.
logger
.
Infof
(
"Key rotation not needed: %v"
,
err
)
}
else
{
s
.
logger
.
Errorf
(
"failed to rotate keys: %v"
,
err
)
}
}
go
func
()
{
for
{
...
...
@@ -128,7 +135,7 @@ func (k keyRotater) rotate() error {
// if you are running multiple instances of dex, another instance
// could have already rotated the keys.
if
tNow
.
Before
(
keys
.
NextRotation
)
{
return
storage
.
Keys
{},
nil
return
storage
.
Keys
{},
errAlreadyRotated
}
expired
:=
func
(
key
storage
.
VerificationKey
)
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment