Skip to content
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

cmd/dex: expose IDTokensValidFor and RotateKeysAfter server options in config #665

Merged
merged 1 commit into from
Nov 4, 2016
Merged

cmd/dex: expose IDTokensValidFor and RotateKeysAfter server options in config #665

merged 1 commit into from
Nov 4, 2016

Conversation

rithujohn191
Copy link
Contributor

closes #660.

@ericchiang

@rithujohn191
Copy link
Contributor Author

@ericchiang I know we discussed that I should ParseDuration before the gRPC code, but since there is a possibility that both the durations might not be provided, I thought it would be easier to do it after defining serverConfig. Let me know if you want me to change it.

@ericchiang
Copy link
Contributor

Travis caught some issues with the struct tags. Please take a look.

@@ -215,3 +216,12 @@ func (c *Connector) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
return err
}

// Expiry holds various expiration time durations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Expiry holds configuration for the validity period of components."

if c.Expiry.SigningKeys != "" {
signingKeys, err := time.ParseDuration(c.Expiry.SigningKeys)
if err != nil {
return fmt.Errorf("parsing SigningKeys expiry: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: signingKeys (since that's the config field).

if c.Expiry.IDTokens != "" {
idTokens, err := time.ParseDuration(c.Expiry.IDTokens)
if err != nil {
return fmt.Errorf("parsing IdTokens expiry: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same nit: lowercase idTokens to correspond to config field

@ericchiang
Copy link
Contributor

Sorry, I appear to have caused a merge conflict :/

@ericchiang
Copy link
Contributor

lgtm

@ericchiang ericchiang merged commit ce703a7 into dexidp:dev Nov 4, 2016
@rithujohn191 rithujohn191 deleted the expose-serv-opts branch November 4, 2016 16:42
@chrisdone
Copy link

Has there been any effort to add a webhook for this? The SP doesn't know exactly when Dex refreshes its signing keys, so I was wondering whether there was any interest in making Dex push to its static clients a HTTP request to say its keys have been rotated.

@ericchiang
Copy link
Contributor

chrisdone@ key endpoints have expiry data in a Cache-Control HTTP header. You can just use that :) you definitely don't need a webhook for this.

@chrisdone
Copy link

@ericchiang Thanks.

Upon reflection, neither the webhook nor the expiry data are sufficient to avoid race conditions:

  • Due to time skew where the SP and Dex's times become out of sync, SP can jump the gun.
  • Dex could be restarted or re-provisioned during the expiry interval, meaning that the JWKs would be rotated earlier than expected.

In this situation, the expiry datetime is essentially advisory, to reduce cache misses. A webhook would mitigate the time skew and restarts, causing fewer cache misses, but is also advisory.

I will have to implement an on-demand system in SP which requests an update from Dex on cache misses (whenever JWKs fail to decode a JWT in an attempted authentication).

The only missing piece of the puzzle is to avoid DoS attacks causing intentional cache misses. Some kind of rate limit of e.g. 5 minutes will probably have to do. 🤔

@ericchiang
Copy link
Contributor

ericchiang commented Jun 18, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants