Skip to content

Commit 68abf97

Browse files
committed
Add support to allow for clock skew
1 parent 5d20d42 commit 68abf97

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

saml.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ type SAMLServiceProvider struct {
9292

9393
signingContextMu sync.RWMutex
9494
signingContext *dsig.SigningContext
95+
96+
AllowClockSkew time.Duration
9597
}
9698

9799
// SetSPKeyStore sets the encryption key to be used.

validate.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ func (sp *SAMLServiceProvider) VerifyAssertionConditions(assertion *types.Assert
7777
return nil, ErrParsing{Tag: NotBeforeAttr, Value: conditions.NotBefore, Type: "time.RFC3339"}
7878
}
7979

80-
if now.Before(notBefore) {
80+
allowedSkew := sp.AllowClockSkew
81+
82+
if now.Before(notBefore.Add(-allowedSkew)) {
8183
warningInfo.InvalidTime = true
8284
}
8385

@@ -90,7 +92,7 @@ func (sp *SAMLServiceProvider) VerifyAssertionConditions(assertion *types.Assert
9092
return nil, ErrParsing{Tag: NotOnOrAfterAttr, Value: conditions.NotOnOrAfter, Type: "time.RFC3339"}
9193
}
9294

93-
if now.After(notOnOrAfter) {
95+
if now.After(notOnOrAfter.Add(allowedSkew)) {
9496
warningInfo.InvalidTime = true
9597
}
9698

0 commit comments

Comments
 (0)