Skip to content

Commit

Permalink
enable to validate by old system secret when setting `ROTATED_SYSTEM_…
Browse files Browse the repository at this point in the history
…SECRET`

Signed-off-by: Shota SAWADA <xiootas@gmail.com>
  • Loading branch information
sawadashota committed Dec 27, 2018
1 parent e2d6c44 commit 7ece1fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ func initConfig() {
viper.BindEnv("SYSTEM_SECRET")
viper.SetDefault("SYSTEM_SECRET", "")

viper.BindEnv("ROTATED_SYSTEM_SECRET")
viper.SetDefault("ROTATED_SYSTEM_SECRET", "")

viper.BindEnv("CLIENT_SECRET")
viper.SetDefault("CLIENT_SECRET", "")

Expand Down
2 changes: 1 addition & 1 deletion cmd/server/handler_oauth2_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func newOAuth2Provider(c *config.Config) fosite.OAuth2Provider {
}

var coreStrategy foauth2.CoreStrategy
hmacStrategy := compose.NewOAuth2HMACStrategy(fc, c.GetSystemSecret(), nil)
hmacStrategy := compose.NewOAuth2HMACStrategy(fc, c.GetSystemSecret(), c.GetRotatedSystemSecrets())
if c.OAuth2AccessTokenStrategy == "jwt" {
kid := uuid.New()
if _, err := createOrGetJWK(c, oauth2.OAuth2JWTKeyName, kid, "private"); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ func (c *Config) Context() *Context {
Hasher: hasher,
FositeStrategy: &foauth2.HMACSHAStrategy{
Enigma: &hmac.HMACStrategy{
GlobalSecret: c.GetSystemSecret(),
GlobalSecret: c.GetSystemSecret(),
RotatedGlobalSecrets: c.GetRotatedSystemSecrets(),
},
AccessTokenLifespan: c.GetAccessTokenLifespan(),
AuthorizeCodeLifespan: c.GetAuthCodeLifespan(),
Expand Down

0 comments on commit 7ece1fc

Please sign in to comment.