Skip to content

Commit

Permalink
Merge pull request #326 from jumbojett/fix/cleanup-back-channel
Browse files Browse the repository at this point in the history
chore: code cleanup of back-channel PR #302
  • Loading branch information
DeepDiver1975 authored Sep 28, 2022
2 parents 31354e8 + db9a25c commit 4046c22
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ public function authenticate() {

// Success!
return true;

}

throw new OpenIDConnectClientException ('Unable to verify JWT claims');
Expand Down Expand Up @@ -479,8 +478,8 @@ public function signOut($idToken, $redirect) {
* back-channel logout flows.
*
* This function should be evaluated as a boolean check
* in your route that receives the POST request for back-
* channel logout executed from the OP.
* in your route that receives the POST request for back-channel
* logout executed from the OP.
*
* @return bool
* @throws OpenIDConnectClientException
Expand All @@ -506,18 +505,15 @@ public function verifyLogoutToken()
}

// Verify Logout Token Claims
if ($this->verifyLogoutTokenClaims($claims, $logout_token)) {
$this->logoutToken = $logout_token;
if ($this->verifyLogoutTokenClaims($claims)) {
$this->verifiedClaims = $claims;
return true;
}
else {
return false;
}
}
else {
throw new OpenIDConnectClientException('Back-channel logout: There was no logout_token in the request');

return false;
}

throw new OpenIDConnectClientException('Back-channel logout: There was no logout_token in the request');
}

/**
Expand All @@ -526,6 +522,7 @@ public function verifyLogoutToken()
*
* @param object $claims
* @return bool
* @throws OpenIDConnectClientException
*/
public function verifyLogoutTokenClaims($claims)
{
Expand Down Expand Up @@ -572,11 +569,11 @@ public function verifyLogoutTokenClaims($claims)
return false;
}
// Validate the iat. At this point we can return true if it is ok
if (isset($claims->iat) && ((gettype($claims->iat) === 'integer') && ($claims->iat <= time() + $this->leeway))) {
if (isset($claims->iat) && ((is_int($claims->iat)) && ($claims->iat <= time() + $this->leeway))) {
return true;
} else {
return false;
}

return false;
}

/**
Expand Down Expand Up @@ -770,6 +767,7 @@ protected function generateRandString() {
* Start Here
* @return void
* @throws OpenIDConnectClientException
* @throws \Exception
*/
private function requestAuthorization() {

Expand Down

0 comments on commit 4046c22

Please sign in to comment.