diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-09-22 20:25:47 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-11-09 10:56:24 +0100 |
commit | 53054b2bf6a919fd4ff9b44b6ad1986f21f488b6 (patch) | |
tree | 39cad52645ce00fbf863ff8e482d10dfcbe7f26c /application/api/ApiUtils.php | |
parent | e09bb93e18a333eff8e6a4156f5b58ba9c7d25cd (diff) | |
download | Shaarli-53054b2bf6a919fd4ff9b44b6ad1986f21f488b6.tar.gz Shaarli-53054b2bf6a919fd4ff9b44b6ad1986f21f488b6.tar.zst Shaarli-53054b2bf6a919fd4ff9b44b6ad1986f21f488b6.zip |
Apply PHP Code Beautifier on source code for linter automatic fixes
Diffstat (limited to 'application/api/ApiUtils.php')
-rw-r--r-- | application/api/ApiUtils.php | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/application/api/ApiUtils.php b/application/api/ApiUtils.php index eb1ca9bc..05a2840a 100644 --- a/application/api/ApiUtils.php +++ b/application/api/ApiUtils.php | |||
@@ -1,4 +1,5 @@ | |||
1 | <?php | 1 | <?php |
2 | |||
2 | namespace Shaarli\Api; | 3 | namespace Shaarli\Api; |
3 | 4 | ||
4 | use Shaarli\Api\Exceptions\ApiAuthorizationException; | 5 | use Shaarli\Api\Exceptions\ApiAuthorizationException; |
@@ -27,7 +28,7 @@ class ApiUtils | |||
27 | throw new ApiAuthorizationException('Malformed JWT token'); | 28 | throw new ApiAuthorizationException('Malformed JWT token'); |
28 | } | 29 | } |
29 | 30 | ||
30 | $genSign = Base64Url::encode(hash_hmac('sha512', $parts[0] .'.'. $parts[1], $secret, true)); | 31 | $genSign = Base64Url::encode(hash_hmac('sha512', $parts[0] . '.' . $parts[1], $secret, true)); |
31 | if ($parts[2] != $genSign) { | 32 | if ($parts[2] != $genSign) { |
32 | throw new ApiAuthorizationException('Invalid JWT signature'); | 33 | throw new ApiAuthorizationException('Invalid JWT signature'); |
33 | } | 34 | } |
@@ -42,7 +43,8 @@ class ApiUtils | |||
42 | throw new ApiAuthorizationException('Invalid JWT payload'); | 43 | throw new ApiAuthorizationException('Invalid JWT payload'); |
43 | } | 44 | } |
44 | 45 | ||
45 | if (empty($payload->iat) | 46 | if ( |
47 | empty($payload->iat) | ||
46 | || $payload->iat > time() | 48 | || $payload->iat > time() |
47 | || time() - $payload->iat > ApiMiddleware::$TOKEN_DURATION | 49 | || time() - $payload->iat > ApiMiddleware::$TOKEN_DURATION |
48 | ) { | 50 | ) { |