Skip to content

Commit f323e05

Browse files
authored
Merge pull request #128 from nyndo/leeway-nbf-exp
Leeway due to clock skew when checking exp and nbf
2 parents e9a7e0a + 1b933ff commit f323e05

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [Unreleased]
88

99
### Added
10+
* Added five minutes leeway due to clock skew between openidconnect server and client.
1011
* Fix save access_token from request in implicit flow authentication #129
1112
* verifyJWTsignature() method private -> public #126
1213
* Support for providers where provider/login URL is not the same as the issuer URL. #125

src/OpenIDConnectClient.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ class OpenIDConnectClient
189189
*/
190190
protected $timeOut = 60;
191191

192+
/**
193+
* @var int leeway (seconds)
194+
*/
195+
private $leeway = 300;
196+
192197
/**
193198
* @var array holds response types
194199
*/
@@ -871,8 +876,8 @@ private function verifyJWTclaims($claims, $accessToken = null) {
871876
return (($claims->iss == $this->getIssuer() || $claims->iss == $this->getWellKnownIssuer() || $claims->iss == $this->getWellKnownIssuer(true))
872877
&& (($claims->aud == $this->clientID) || (in_array($this->clientID, $claims->aud)))
873878
&& ($claims->nonce == $this->getNonce())
874-
&& ( !isset($claims->exp) || $claims->exp >= time())
875-
&& ( !isset($claims->nbf) || $claims->nbf <= time())
879+
&& ( !isset($claims->exp) || $claims->exp >= time() - $this->leeway)
880+
&& ( !isset($claims->nbf) || $claims->nbf <= time() + $this->leeway)
876881
&& ( !isset($claims->at_hash) || $claims->at_hash == $expecte_at_hash )
877882
);
878883
}

0 commit comments

Comments
 (0)