Skip to content

Commit

Permalink
Merge pull request #1 from InternationalCodeCouncil/exceptions
Browse files Browse the repository at this point in the history
Exceptions
  • Loading branch information
bclarkicc committed Jul 30, 2020
2 parents e23b33f + 497d6f7 commit 3c4f400
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/CognitoClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ public function verifyAccessToken($accessToken)

$expectedIss = sprintf('https://cognito-idp.%s.amazonaws.com/%s', $this->region, $this->userPoolId);
if ($jwtPayload['iss'] !== $expectedIss) {
throw new TokenVerificationException('invalid iss');
throw new TokenVerificationException('Invalid token issuer');
}

if ( !in_array($jwtPayload['token_use'], ['id','access']) ) {
throw new TokenVerificationException('invalid token_use');
throw new TokenVerificationException('Invalid token purpose/use');
}

if ($jwtPayload['exp'] < time()) {
throw new TokenExpiryException('invalid exp');
throw new TokenExpiryException('Expired token');
}

return $jwtPayload['username'] ?? $jwtPayload['cognito:username'];
Expand Down
6 changes: 0 additions & 6 deletions src/Exception/ExipredCodeException.php

This file was deleted.

6 changes: 6 additions & 0 deletions src/Exception/ExpiredCodeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace pmill\AwsCognito\Exception;

class ExpiredCodeException extends CognitoResponseException
{
}

0 comments on commit 3c4f400

Please sign in to comment.