Skip to content

Commit

Permalink
rename MaxClockOffset to MaxClockSkew
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Nov 4, 2019
1 parent 11f9453 commit 99be429
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions certificate/authorization/authorizations.go
Expand Up @@ -27,9 +27,9 @@ import (
const (
// Bucket is the bucket used with a bolt-backed authorizations DB.
Bucket = "authorizations"
// MaxClockOffset is the max duration in seconds in the past or
// future that a claim timestamp is allowed to have and still be valid.
MaxClockOffset = 5 * time.Minute
// MaxClockSkew is the max duration in the past or future that a claim
// timestamp is allowed to have and still be valid.
MaxClockSkew = 5 * time.Minute
tokenDataLength = 64 // 2^(64*8) =~ 1.34E+154
tokenDelimiter = ":"
tokenVersion = 0
Expand Down
4 changes: 2 additions & 2 deletions certificate/authorization/db.go
Expand Up @@ -172,8 +172,8 @@ func (authDB *DB) Claim(ctx context.Context, opts *ClaimOpts) (err error) {
defer mon.Task()(&ctx)(&err)
now := time.Now()
reqTime := time.Unix(opts.Req.Timestamp, 0)
if (now.Sub(reqTime) > MaxClockOffset) ||
(reqTime.Sub(now) > MaxClockOffset) {
if (now.Sub(reqTime) > MaxClockSkew) ||
(reqTime.Sub(now) > MaxClockSkew) {
return Error.New("claim timestamp is outside of max delay window: %d", opts.Req.Timestamp)
}

Expand Down
4 changes: 2 additions & 2 deletions certificate/authorization/db_test.go
Expand Up @@ -246,8 +246,8 @@ func TestAuthorizationDB_Claim_Valid(t *testing.T) {

claimTime := time.Unix(claim.Timestamp, 0)
assert.Condition(t, func() bool {
return now.Sub(claimTime) < MaxClockOffset &&
claimTime.Sub(now) < MaxClockOffset
return now.Sub(claimTime) < MaxClockSkew &&
claimTime.Sub(now) < MaxClockSkew
})
}

Expand Down
4 changes: 2 additions & 2 deletions certificate/peer_test.go
Expand Up @@ -203,8 +203,8 @@ func TestCertificateSigner_Sign(t *testing.T) {
now := time.Now()
claimTime := time.Unix(claim.Timestamp, 0)
assert.Condition(t, func() bool {
return now.Sub(claimTime) < authorization.MaxClockOffset &&
claimTime.Sub(now) < authorization.MaxClockOffset
return now.Sub(claimTime) < authorization.MaxClockSkew &&
claimTime.Sub(now) < authorization.MaxClockSkew
})
})
})
Expand Down

0 comments on commit 99be429

Please sign in to comment.