Revize 73804802
Přidáno uživatelem Cajova-Houba před téměř 7 roky(ů)
.gitignore | ||
---|---|---|
1 |
# slozka s idea projektem |
|
2 |
backend/.idea |
|
3 |
|
backend/.env | ||
---|---|---|
1 |
APP_ENV=local |
|
2 |
APP_DEBUG=true |
|
3 |
APP_KEY=SomeRandomKey!!! |
|
4 |
|
|
5 |
DB_CONNECTION=mysql |
|
6 |
DB_HOST=localhost |
|
7 |
DB_PORT=3306 |
|
8 |
DB_DATABASE=prujezd_vozidel |
|
9 |
DB_USERNAME=aswi |
|
10 |
DB_PASSWORD=aswi |
|
11 |
|
|
12 |
CACHE_DRIVER=memcached |
|
13 |
QUEUE_DRIVER=sync |
|
14 |
|
|
15 |
# doba platnosti JWT v sekundach |
|
16 |
JWT_DURATION=1800 |
|
17 |
# JWT iss parametr |
|
18 |
JWT_ISS=aswi-doprava |
|
19 |
JWT_SECRET=asdfkeylol |
backend/app/Http/Controllers/DeviceController.php | ||
---|---|---|
82 | 82 |
public function lastDay() { |
83 | 83 |
return Zaznam::lastInsertedDate(); |
84 | 84 |
} |
85 |
|
|
86 |
public function headerTest(Request $request) { |
|
87 |
$authHeader = $request->header("jwt"); |
|
88 |
|
|
89 |
if($authHeader != null) { |
|
90 |
return $authHeader; |
|
91 |
} else { |
|
92 |
return $request->header("jwt"); |
|
93 |
} |
|
94 |
} |
|
85 | 95 |
} |
backend/app/Http/Controllers/LocationController.php | ||
---|---|---|
14 | 14 |
|
15 | 15 |
class LocationController extends Controller |
16 | 16 |
{ |
17 |
/** |
|
18 |
* Vrati likaci s danym id. |
|
19 |
* |
|
20 |
* @param $id |
|
21 |
* @return Lokace s id. |
|
22 |
*/ |
|
23 |
public function findById($id) |
|
24 |
{ |
|
25 |
$location = Location::withData(array("Česká Kubice, směr od Německa", "Česká Kubice", "Česká Kubice", "KP055", "5")); |
|
26 |
$location->id = $id; |
|
27 |
return response()->json($location); |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* Vrati instanci lokace jako json. |
|
32 |
*/ |
|
33 |
public function getLocation() |
|
34 |
{ |
|
35 |
return response()->json(Location::withData(array("Česká Kubice, směr od Německa", "Česká Kubice", "Česká Kubice", "KP055", "5"))); |
|
36 |
} |
|
37 |
|
|
38 | 17 |
/** |
39 | 18 |
* Vrati vsechna mesta. |
40 | 19 |
*/ |
backend/app/Http/Controllers/TokenController.php | ||
---|---|---|
1 |
<?php |
|
2 |
/** |
|
3 |
* Created by PhpStorm. |
|
4 |
* User: Zdenda |
|
5 |
* Date: 29.4.2018 |
|
6 |
* Time: 10:20 |
|
7 |
*/ |
|
8 |
|
|
9 |
namespace App\Http\Controllers; |
|
10 |
|
|
11 |
use \Firebase\JWT\JWT; |
|
12 |
|
|
13 |
class TokenController extends Controller |
|
14 |
{ |
|
15 |
/** |
|
16 |
* Vygeneruje nový token pro JWT autorizaci. |
|
17 |
*/ |
|
18 |
public function generateToken() { |
|
19 |
$duration = env('JWT_DURATION', 1800); |
|
20 |
|
|
21 |
// parametry jwt |
|
22 |
$iat = time(); |
|
23 |
$exp = $iat + $duration; |
|
24 |
$iss = env('JWT_ISS', 'aswi-doprava'); |
|
25 |
|
|
26 |
// generovani tokenu |
|
27 |
$key = env('JWT_SECRET', ''); |
|
28 |
$token = array( |
|
29 |
'iss' => $iss, |
|
30 |
'iat' => $iat, |
|
31 |
'exp' => $exp |
|
32 |
); |
|
33 |
|
|
34 |
$jwt = JWT::encode($token, $key); |
|
35 |
|
|
36 |
return $jwt; |
|
37 |
} |
|
38 |
} |
backend/app/Http/routes.php | ||
---|---|---|
13 | 13 |
|
14 | 14 |
$apiUrlRoot='/api/v1/'; |
15 | 15 |
|
16 |
/** |
|
17 |
* Welcome endpoint. |
|
18 |
*/ |
|
16 | 19 |
$app->get('/', function () { |
17 |
return 'Funguje to.';
|
|
20 |
return 'Welcome.';
|
|
18 | 21 |
}); |
19 | 22 |
|
20 | 23 |
/** |
... | ... | |
24 | 27 |
*/ |
25 | 28 |
$app->get($apiUrlRoot.'devices', 'DeviceController@getDevice'); |
26 | 29 |
|
27 |
$app->get($apiUrlRoot.'devices/all', 'DeviceController@getAll'); |
|
30 |
//$app->get($apiUrlRoot.'devices/all', 'DeviceController@getAll');
|
|
28 | 31 |
|
29 | 32 |
/** |
30 | 33 |
* Parametry v url: |
... | ... | |
36 | 39 |
*/ |
37 | 40 |
$app->get($apiUrlRoot.'devices/{id}', 'DeviceController@getDeviceById'); |
38 | 41 |
|
39 |
//$app->get($apiUrlRoot.'devices/lastday', 'DeviceController@lastDay'); |
|
40 |
|
|
41 | 42 |
/** |
42 | 43 |
* Vrati vsechny typy aut. |
43 | 44 |
*/ |
44 | 45 |
$app->get($apiUrlRoot.'vehicles', 'VehicleController@getAll'); |
45 | 46 |
|
47 |
/** |
|
48 |
* Vrati vsechna mesta. |
|
49 |
*/ |
|
46 | 50 |
$app->get($apiUrlRoot.'cities', 'LocationController@getCities'); |
47 | 51 |
|
52 |
/** |
|
53 |
* Vygeneruje novy JWT s omezenou platnosti. |
|
54 |
*/ |
|
55 |
$app->get($apiUrlRoot.'token', 'TokenController@generateToken'); |
|
56 |
|
|
57 |
|
|
58 |
|
|
59 |
// testovani |
|
60 |
$app->get($apiUrlRoot.'header', 'DeviceController@headerTest'); |
backend/composer.json | ||
---|---|---|
7 | 7 |
"require": { |
8 | 8 |
"php": ">=5.5.9", |
9 | 9 |
"laravel/lumen-framework": "5.2.*", |
10 |
"vlucas/phpdotenv": "~2.2" |
|
10 |
"vlucas/phpdotenv": "~2.2", |
|
11 |
"firebase/php-jwt": "^5.0" |
|
11 | 12 |
}, |
12 | 13 |
"require-dev": { |
13 | 14 |
"fzaninotto/faker": "~1.4", |
backend/composer.lock | ||
---|---|---|
4 | 4 |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | 5 |
"This file is @generated automatically" |
6 | 6 |
], |
7 |
"hash": "eb888ea84a45675db2bc1f4dd4da889d",
|
|
8 |
"content-hash": "be56596918ef42a15b75d881aaedbd55",
|
|
7 |
"hash": "d6efa3bd19563e064047d9b70e8a2752",
|
|
8 |
"content-hash": "e59526fcb072b5d7e63b1eea55da3b4f",
|
|
9 | 9 |
"packages": [ |
10 | 10 |
{ |
11 | 11 |
"name": "doctrine/inflector", |
... | ... | |
74 | 74 |
], |
75 | 75 |
"time": "2015-11-06 14:35:42" |
76 | 76 |
}, |
77 |
{ |
|
78 |
"name": "firebase/php-jwt", |
|
79 |
"version": "v5.0.0", |
|
80 |
"source": { |
|
81 |
"type": "git", |
|
82 |
"url": "https://github.com/firebase/php-jwt.git", |
|
83 |
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e" |
|
84 |
}, |
|
85 |
"dist": { |
|
86 |
"type": "zip", |
|
87 |
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", |
|
88 |
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", |
|
89 |
"shasum": "" |
|
90 |
}, |
|
91 |
"require": { |
|
92 |
"php": ">=5.3.0" |
|
93 |
}, |
|
94 |
"require-dev": { |
|
95 |
"phpunit/phpunit": " 4.8.35" |
|
96 |
}, |
|
97 |
"type": "library", |
|
98 |
"autoload": { |
|
99 |
"psr-4": { |
|
100 |
"Firebase\\JWT\\": "src" |
|
101 |
} |
|
102 |
}, |
|
103 |
"notification-url": "https://packagist.org/downloads/", |
|
104 |
"license": [ |
|
105 |
"BSD-3-Clause" |
|
106 |
], |
|
107 |
"authors": [ |
|
108 |
{ |
|
109 |
"name": "Neuman Vong", |
|
110 |
"email": "neuman+pear@twilio.com", |
|
111 |
"role": "Developer" |
|
112 |
}, |
|
113 |
{ |
|
114 |
"name": "Anant Narayanan", |
|
115 |
"email": "anant@php.net", |
|
116 |
"role": "Developer" |
|
117 |
} |
|
118 |
], |
|
119 |
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", |
|
120 |
"homepage": "https://github.com/firebase/php-jwt", |
|
121 |
"time": "2017-06-27 22:17:23" |
|
122 |
}, |
|
77 | 123 |
{ |
78 | 124 |
"name": "illuminate/auth", |
79 | 125 |
"version": "v5.2.45", |
backend/vendor/composer/autoload_psr4.php | ||
---|---|---|
45 | 45 |
'Illuminate\\Bus\\' => array($vendorDir . '/illuminate/bus'), |
46 | 46 |
'Illuminate\\Broadcasting\\' => array($vendorDir . '/illuminate/broadcasting'), |
47 | 47 |
'Illuminate\\Auth\\' => array($vendorDir . '/illuminate/auth'), |
48 |
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'), |
|
48 | 49 |
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'), |
49 | 50 |
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'), |
50 | 51 |
'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), |
backend/vendor/composer/autoload_static.php | ||
---|---|---|
78 | 78 |
), |
79 | 79 |
'F' => |
80 | 80 |
array ( |
81 |
'Firebase\\JWT\\' => 13, |
|
81 | 82 |
'FastRoute\\' => 10, |
82 | 83 |
'Faker\\' => 6, |
83 | 84 |
), |
... | ... | |
256 | 257 |
array ( |
257 | 258 |
0 => __DIR__ . '/..' . '/illuminate/auth', |
258 | 259 |
), |
260 |
'Firebase\\JWT\\' => |
|
261 |
array ( |
|
262 |
0 => __DIR__ . '/..' . '/firebase/php-jwt/src', |
|
263 |
), |
|
259 | 264 |
'FastRoute\\' => |
260 | 265 |
array ( |
261 | 266 |
0 => __DIR__ . '/..' . '/nikic/fast-route/src', |
backend/vendor/composer/installed.json | ||
---|---|---|
3513 | 3513 |
"testing", |
3514 | 3514 |
"xunit" |
3515 | 3515 |
] |
3516 |
}, |
|
3517 |
{ |
|
3518 |
"name": "firebase/php-jwt", |
|
3519 |
"version": "v5.0.0", |
|
3520 |
"version_normalized": "5.0.0.0", |
|
3521 |
"source": { |
|
3522 |
"type": "git", |
|
3523 |
"url": "https://github.com/firebase/php-jwt.git", |
|
3524 |
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e" |
|
3525 |
}, |
|
3526 |
"dist": { |
|
3527 |
"type": "zip", |
|
3528 |
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", |
|
3529 |
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e", |
|
3530 |
"shasum": "" |
|
3531 |
}, |
|
3532 |
"require": { |
|
3533 |
"php": ">=5.3.0" |
|
3534 |
}, |
|
3535 |
"require-dev": { |
|
3536 |
"phpunit/phpunit": " 4.8.35" |
|
3537 |
}, |
|
3538 |
"time": "2017-06-27 22:17:23", |
|
3539 |
"type": "library", |
|
3540 |
"installation-source": "dist", |
|
3541 |
"autoload": { |
|
3542 |
"psr-4": { |
|
3543 |
"Firebase\\JWT\\": "src" |
|
3544 |
} |
|
3545 |
}, |
|
3546 |
"notification-url": "https://packagist.org/downloads/", |
|
3547 |
"license": [ |
|
3548 |
"BSD-3-Clause" |
|
3549 |
], |
|
3550 |
"authors": [ |
|
3551 |
{ |
|
3552 |
"name": "Neuman Vong", |
|
3553 |
"email": "neuman+pear@twilio.com", |
|
3554 |
"role": "Developer" |
|
3555 |
}, |
|
3556 |
{ |
|
3557 |
"name": "Anant Narayanan", |
|
3558 |
"email": "anant@php.net", |
|
3559 |
"role": "Developer" |
|
3560 |
} |
|
3561 |
], |
|
3562 |
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", |
|
3563 |
"homepage": "https://github.com/firebase/php-jwt" |
|
3516 | 3564 |
} |
3517 | 3565 |
] |
backend/vendor/firebase/php-jwt/LICENSE | ||
---|---|---|
1 |
Copyright (c) 2011, Neuman Vong |
|
2 |
|
|
3 |
All rights reserved. |
|
4 |
|
|
5 |
Redistribution and use in source and binary forms, with or without |
|
6 |
modification, are permitted provided that the following conditions are met: |
|
7 |
|
|
8 |
* Redistributions of source code must retain the above copyright |
|
9 |
notice, this list of conditions and the following disclaimer. |
|
10 |
|
|
11 |
* Redistributions in binary form must reproduce the above |
|
12 |
copyright notice, this list of conditions and the following |
|
13 |
disclaimer in the documentation and/or other materials provided |
|
14 |
with the distribution. |
|
15 |
|
|
16 |
* Neither the name of Neuman Vong nor the names of other |
|
17 |
contributors may be used to endorse or promote products derived |
|
18 |
from this software without specific prior written permission. |
|
19 |
|
|
20 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
21 |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
22 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
23 |
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
24 |
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
25 |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
26 |
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
27 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
28 |
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
29 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
30 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
backend/vendor/firebase/php-jwt/README.md | ||
---|---|---|
1 |
[](https://travis-ci.org/firebase/php-jwt) |
|
2 |
[](https://packagist.org/packages/firebase/php-jwt) |
|
3 |
[](https://packagist.org/packages/firebase/php-jwt) |
|
4 |
[](https://packagist.org/packages/firebase/php-jwt) |
|
5 |
|
|
6 |
PHP-JWT |
|
7 |
======= |
|
8 |
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to [RFC 7519](https://tools.ietf.org/html/rfc7519). |
|
9 |
|
|
10 |
Installation |
|
11 |
------------ |
|
12 |
|
|
13 |
Use composer to manage your dependencies and download PHP-JWT: |
|
14 |
|
|
15 |
```bash |
|
16 |
composer require firebase/php-jwt |
|
17 |
``` |
|
18 |
|
|
19 |
Example |
|
20 |
------- |
|
21 |
```php |
|
22 |
<?php |
|
23 |
use \Firebase\JWT\JWT; |
|
24 |
|
|
25 |
$key = "example_key"; |
|
26 |
$token = array( |
|
27 |
"iss" => "http://example.org", |
|
28 |
"aud" => "http://example.com", |
|
29 |
"iat" => 1356999524, |
|
30 |
"nbf" => 1357000000 |
|
31 |
); |
|
32 |
|
|
33 |
/** |
|
34 |
* IMPORTANT: |
|
35 |
* You must specify supported algorithms for your application. See |
|
36 |
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40 |
|
37 |
* for a list of spec-compliant algorithms. |
|
38 |
*/ |
|
39 |
$jwt = JWT::encode($token, $key); |
|
40 |
$decoded = JWT::decode($jwt, $key, array('HS256')); |
|
41 |
|
|
42 |
print_r($decoded); |
|
43 |
|
|
44 |
/* |
|
45 |
NOTE: This will now be an object instead of an associative array. To get |
|
46 |
an associative array, you will need to cast it as such: |
|
47 |
*/ |
|
48 |
|
|
49 |
$decoded_array = (array) $decoded; |
|
50 |
|
|
51 |
/** |
|
52 |
* You can add a leeway to account for when there is a clock skew times between |
|
53 |
* the signing and verifying servers. It is recommended that this leeway should |
|
54 |
* not be bigger than a few minutes. |
|
55 |
* |
|
56 |
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef |
|
57 |
*/ |
|
58 |
JWT::$leeway = 60; // $leeway in seconds |
|
59 |
$decoded = JWT::decode($jwt, $key, array('HS256')); |
|
60 |
|
|
61 |
?> |
|
62 |
``` |
|
63 |
Example with RS256 (openssl) |
|
64 |
---------------------------- |
|
65 |
```php |
|
66 |
<?php |
|
67 |
use \Firebase\JWT\JWT; |
|
68 |
|
|
69 |
$privateKey = <<<EOD |
|
70 |
-----BEGIN RSA PRIVATE KEY----- |
|
71 |
MIICXAIBAAKBgQC8kGa1pSjbSYZVebtTRBLxBz5H4i2p/llLCrEeQhta5kaQu/Rn |
|
72 |
vuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t0tyazyZ8JXw+KgXTxldMPEL9 |
|
73 |
5+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4ehde/zUxo6UvS7UrBQIDAQAB |
|
74 |
AoGAb/MXV46XxCFRxNuB8LyAtmLDgi/xRnTAlMHjSACddwkyKem8//8eZtw9fzxz |
|
75 |
bWZ/1/doQOuHBGYZU8aDzzj59FZ78dyzNFoF91hbvZKkg+6wGyd/LrGVEB+Xre0J |
|
76 |
Nil0GReM2AHDNZUYRv+HYJPIOrB0CRczLQsgFJ8K6aAD6F0CQQDzbpjYdx10qgK1 |
|
77 |
cP59UHiHjPZYC0loEsk7s+hUmT3QHerAQJMZWC11Qrn2N+ybwwNblDKv+s5qgMQ5 |
|
78 |
5tNoQ9IfAkEAxkyffU6ythpg/H0Ixe1I2rd0GbF05biIzO/i77Det3n4YsJVlDck |
|
79 |
ZkcvY3SK2iRIL4c9yY6hlIhs+K9wXTtGWwJBAO9Dskl48mO7woPR9uD22jDpNSwe |
|
80 |
k90OMepTjzSvlhjbfuPN1IdhqvSJTDychRwn1kIJ7LQZgQ8fVz9OCFZ/6qMCQGOb |
|
81 |
qaGwHmUK6xzpUbbacnYrIM6nLSkXgOAwv7XXCojvY614ILTK3iXiLBOxPu5Eu13k |
|
82 |
eUz9sHyD6vkgZzjtxXECQAkp4Xerf5TGfQXGXhxIX52yH+N2LtujCdkQZjXAsGdm |
|
83 |
B2zNzvrlgRmgBrklMTrMYgm1NPcW+bRLGcwgW2PTvNM= |
|
84 |
-----END RSA PRIVATE KEY----- |
|
85 |
EOD; |
|
86 |
|
|
87 |
$publicKey = <<<EOD |
|
88 |
-----BEGIN PUBLIC KEY----- |
|
89 |
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8kGa1pSjbSYZVebtTRBLxBz5H |
|
90 |
4i2p/llLCrEeQhta5kaQu/RnvuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t |
|
91 |
0tyazyZ8JXw+KgXTxldMPEL95+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4 |
|
92 |
ehde/zUxo6UvS7UrBQIDAQAB |
|
93 |
-----END PUBLIC KEY----- |
|
94 |
EOD; |
|
95 |
|
|
96 |
$token = array( |
|
97 |
"iss" => "example.org", |
|
98 |
"aud" => "example.com", |
|
99 |
"iat" => 1356999524, |
|
100 |
"nbf" => 1357000000 |
|
101 |
); |
|
102 |
|
|
103 |
$jwt = JWT::encode($token, $privateKey, 'RS256'); |
|
104 |
echo "Encode:\n" . print_r($jwt, true) . "\n"; |
|
105 |
|
|
106 |
$decoded = JWT::decode($jwt, $publicKey, array('RS256')); |
|
107 |
|
|
108 |
/* |
|
109 |
NOTE: This will now be an object instead of an associative array. To get |
|
110 |
an associative array, you will need to cast it as such: |
|
111 |
*/ |
|
112 |
|
|
113 |
$decoded_array = (array) $decoded; |
|
114 |
echo "Decode:\n" . print_r($decoded_array, true) . "\n"; |
|
115 |
?> |
|
116 |
``` |
|
117 |
|
|
118 |
Changelog |
|
119 |
--------- |
|
120 |
|
|
121 |
#### 5.0.0 / 2017-06-26 |
|
122 |
- Support RS384 and RS512. |
|
123 |
See [#117](https://github.com/firebase/php-jwt/pull/117). Thanks [@joostfaassen](https://github.com/joostfaassen)! |
|
124 |
- Add an example for RS256 openssl. |
|
125 |
See [#125](https://github.com/firebase/php-jwt/pull/125). Thanks [@akeeman](https://github.com/akeeman)! |
|
126 |
- Detect invalid Base64 encoding in signature. |
|
127 |
See [#162](https://github.com/firebase/php-jwt/pull/162). Thanks [@psignoret](https://github.com/psignoret)! |
|
128 |
- Update `JWT::verify` to handle OpenSSL errors. |
|
129 |
See [#159](https://github.com/firebase/php-jwt/pull/159). Thanks [@bshaffer](https://github.com/bshaffer)! |
|
130 |
- Add `array` type hinting to `decode` method |
|
131 |
See [#101](https://github.com/firebase/php-jwt/pull/101). Thanks [@hywak](https://github.com/hywak)! |
|
132 |
- Add all JSON error types. |
|
133 |
See [#110](https://github.com/firebase/php-jwt/pull/110). Thanks [@gbalduzzi](https://github.com/gbalduzzi)! |
|
134 |
- Bugfix 'kid' not in given key list. |
|
135 |
See [#129](https://github.com/firebase/php-jwt/pull/129). Thanks [@stampycode](https://github.com/stampycode)! |
|
136 |
- Miscellaneous cleanup, documentation and test fixes. |
|
137 |
See [#107](https://github.com/firebase/php-jwt/pull/107), [#115](https://github.com/firebase/php-jwt/pull/115), |
|
138 |
[#160](https://github.com/firebase/php-jwt/pull/160), [#161](https://github.com/firebase/php-jwt/pull/161), and |
|
139 |
[#165](https://github.com/firebase/php-jwt/pull/165). Thanks [@akeeman](https://github.com/akeeman), |
|
140 |
[@chinedufn](https://github.com/chinedufn), and [@bshaffer](https://github.com/bshaffer)! |
|
141 |
|
|
142 |
#### 4.0.0 / 2016-07-17 |
|
143 |
- Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)! |
|
144 |
- Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)! |
|
145 |
- Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)! |
|
146 |
- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)! |
|
147 |
|
|
148 |
#### 3.0.0 / 2015-07-22 |
|
149 |
- Minimum PHP version updated from `5.2.0` to `5.3.0`. |
|
150 |
- Add `\Firebase\JWT` namespace. See |
|
151 |
[#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to |
|
152 |
[@Dashron](https://github.com/Dashron)! |
|
153 |
- Require a non-empty key to decode and verify a JWT. See |
|
154 |
[#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to |
|
155 |
[@sjones608](https://github.com/sjones608)! |
|
156 |
- Cleaner documentation blocks in the code. See |
|
157 |
[#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to |
|
158 |
[@johanderuijter](https://github.com/johanderuijter)! |
|
159 |
|
|
160 |
#### 2.2.0 / 2015-06-22 |
|
161 |
- Add support for adding custom, optional JWT headers to `JWT::encode()`. See |
|
162 |
[#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to |
|
163 |
[@mcocaro](https://github.com/mcocaro)! |
|
164 |
|
|
165 |
#### 2.1.0 / 2015-05-20 |
|
166 |
- Add support for adding a leeway to `JWT:decode()` that accounts for clock skew |
|
167 |
between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)! |
|
168 |
- Add support for passing an object implementing the `ArrayAccess` interface for |
|
169 |
`$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)! |
|
170 |
|
|
171 |
#### 2.0.0 / 2015-04-01 |
|
172 |
- **Note**: It is strongly recommended that you update to > v2.0.0 to address |
|
173 |
known security vulnerabilities in prior versions when both symmetric and |
|
174 |
asymmetric keys are used together. |
|
175 |
- Update signature for `JWT::decode(...)` to require an array of supported |
|
176 |
algorithms to use when verifying token signatures. |
|
177 |
|
|
178 |
|
|
179 |
Tests |
|
180 |
----- |
|
181 |
Run the tests using phpunit: |
|
182 |
|
|
183 |
```bash |
|
184 |
$ pear install PHPUnit |
|
185 |
$ phpunit --configuration phpunit.xml.dist |
|
186 |
PHPUnit 3.7.10 by Sebastian Bergmann. |
|
187 |
..... |
|
188 |
Time: 0 seconds, Memory: 2.50Mb |
|
189 |
OK (5 tests, 5 assertions) |
|
190 |
``` |
|
191 |
|
|
192 |
New Lines in private keys |
|
193 |
----- |
|
194 |
|
|
195 |
If your private key contains `\n` characters, be sure to wrap it in double quotes `""` |
|
196 |
and not single quotes `''` in order to properly interpret the escaped characters. |
|
197 |
|
|
198 |
License |
|
199 |
------- |
|
200 |
[3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause). |
backend/vendor/firebase/php-jwt/composer.json | ||
---|---|---|
1 |
{ |
|
2 |
"name": "firebase/php-jwt", |
|
3 |
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", |
|
4 |
"homepage": "https://github.com/firebase/php-jwt", |
|
5 |
"authors": [ |
|
6 |
{ |
|
7 |
"name": "Neuman Vong", |
|
8 |
"email": "neuman+pear@twilio.com", |
|
9 |
"role": "Developer" |
|
10 |
}, |
|
11 |
{ |
|
12 |
"name": "Anant Narayanan", |
|
13 |
"email": "anant@php.net", |
|
14 |
"role": "Developer" |
|
15 |
} |
|
16 |
], |
|
17 |
"license": "BSD-3-Clause", |
|
18 |
"require": { |
|
19 |
"php": ">=5.3.0" |
|
20 |
}, |
|
21 |
"autoload": { |
|
22 |
"psr-4": { |
|
23 |
"Firebase\\JWT\\": "src" |
|
24 |
} |
|
25 |
}, |
|
26 |
"require-dev": { |
|
27 |
"phpunit/phpunit": " 4.8.35" |
|
28 |
} |
|
29 |
} |
backend/vendor/firebase/php-jwt/src/BeforeValidException.php | ||
---|---|---|
1 |
<?php |
|
2 |
namespace Firebase\JWT; |
|
3 |
|
|
4 |
class BeforeValidException extends \UnexpectedValueException |
|
5 |
{ |
|
6 |
|
|
7 |
} |
backend/vendor/firebase/php-jwt/src/ExpiredException.php | ||
---|---|---|
1 |
<?php |
|
2 |
namespace Firebase\JWT; |
|
3 |
|
|
4 |
class ExpiredException extends \UnexpectedValueException |
|
5 |
{ |
|
6 |
|
|
7 |
} |
backend/vendor/firebase/php-jwt/src/JWT.php | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
namespace Firebase\JWT; |
|
4 |
use \DomainException; |
|
5 |
use \InvalidArgumentException; |
|
6 |
use \UnexpectedValueException; |
|
7 |
use \DateTime; |
|
8 |
|
|
9 |
/** |
|
10 |
* JSON Web Token implementation, based on this spec: |
|
11 |
* https://tools.ietf.org/html/rfc7519 |
|
12 |
* |
|
13 |
* PHP version 5 |
|
14 |
* |
|
15 |
* @category Authentication |
|
16 |
* @package Authentication_JWT |
|
17 |
* @author Neuman Vong <neuman@twilio.com> |
|
18 |
* @author Anant Narayanan <anant@php.net> |
|
19 |
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD |
|
20 |
* @link https://github.com/firebase/php-jwt |
|
21 |
*/ |
|
22 |
class JWT |
|
23 |
{ |
|
24 |
|
|
25 |
/** |
|
26 |
* When checking nbf, iat or expiration times, |
|
27 |
* we want to provide some extra leeway time to |
|
28 |
* account for clock skew. |
|
29 |
*/ |
|
30 |
public static $leeway = 0; |
|
31 |
|
|
32 |
/** |
|
33 |
* Allow the current timestamp to be specified. |
|
34 |
* Useful for fixing a value within unit testing. |
|
35 |
* |
|
36 |
* Will default to PHP time() value if null. |
|
37 |
*/ |
|
38 |
public static $timestamp = null; |
|
39 |
|
|
40 |
public static $supported_algs = array( |
|
41 |
'HS256' => array('hash_hmac', 'SHA256'), |
|
42 |
'HS512' => array('hash_hmac', 'SHA512'), |
|
43 |
'HS384' => array('hash_hmac', 'SHA384'), |
|
44 |
'RS256' => array('openssl', 'SHA256'), |
|
45 |
'RS384' => array('openssl', 'SHA384'), |
|
46 |
'RS512' => array('openssl', 'SHA512'), |
|
47 |
); |
|
48 |
|
|
49 |
/** |
|
50 |
* Decodes a JWT string into a PHP object. |
|
51 |
* |
|
52 |
* @param string $jwt The JWT |
|
53 |
* @param string|array $key The key, or map of keys. |
|
54 |
* If the algorithm used is asymmetric, this is the public key |
|
55 |
* @param array $allowed_algs List of supported verification algorithms |
|
56 |
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
|
57 |
* |
|
58 |
* @return object The JWT's payload as a PHP object |
|
59 |
* |
|
60 |
* @throws UnexpectedValueException Provided JWT was invalid |
|
61 |
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed |
|
62 |
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf' |
|
63 |
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat' |
|
64 |
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim |
|
65 |
* |
|
66 |
* @uses jsonDecode |
|
67 |
* @uses urlsafeB64Decode |
|
68 |
*/ |
|
69 |
public static function decode($jwt, $key, array $allowed_algs = array()) |
|
70 |
{ |
|
71 |
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp; |
|
72 |
|
|
73 |
if (empty($key)) { |
|
74 |
throw new InvalidArgumentException('Key may not be empty'); |
|
75 |
} |
|
76 |
$tks = explode('.', $jwt); |
|
77 |
if (count($tks) != 3) { |
|
78 |
throw new UnexpectedValueException('Wrong number of segments'); |
|
79 |
} |
|
80 |
list($headb64, $bodyb64, $cryptob64) = $tks; |
|
81 |
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) { |
|
82 |
throw new UnexpectedValueException('Invalid header encoding'); |
|
83 |
} |
|
84 |
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) { |
|
85 |
throw new UnexpectedValueException('Invalid claims encoding'); |
|
86 |
} |
|
87 |
if (false === ($sig = static::urlsafeB64Decode($cryptob64))) { |
|
88 |
throw new UnexpectedValueException('Invalid signature encoding'); |
|
89 |
} |
|
90 |
if (empty($header->alg)) { |
|
91 |
throw new UnexpectedValueException('Empty algorithm'); |
|
92 |
} |
|
93 |
if (empty(static::$supported_algs[$header->alg])) { |
|
94 |
throw new UnexpectedValueException('Algorithm not supported'); |
|
95 |
} |
|
96 |
if (!in_array($header->alg, $allowed_algs)) { |
|
97 |
throw new UnexpectedValueException('Algorithm not allowed'); |
|
98 |
} |
|
99 |
if (is_array($key) || $key instanceof \ArrayAccess) { |
|
100 |
if (isset($header->kid)) { |
|
101 |
if (!isset($key[$header->kid])) { |
|
102 |
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key'); |
|
103 |
} |
|
104 |
$key = $key[$header->kid]; |
|
105 |
} else { |
|
106 |
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key'); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
// Check the signature |
|
111 |
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) { |
|
112 |
throw new SignatureInvalidException('Signature verification failed'); |
|
113 |
} |
|
114 |
|
|
115 |
// Check if the nbf if it is defined. This is the time that the |
|
116 |
// token can actually be used. If it's not yet that time, abort. |
|
117 |
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) { |
|
118 |
throw new BeforeValidException( |
|
119 |
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf) |
|
120 |
); |
|
121 |
} |
|
122 |
|
|
123 |
// Check that this token has been created before 'now'. This prevents |
|
124 |
// using tokens that have been created for later use (and haven't |
|
125 |
// correctly used the nbf claim). |
|
126 |
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) { |
|
127 |
throw new BeforeValidException( |
|
128 |
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat) |
|
129 |
); |
|
130 |
} |
|
131 |
|
|
132 |
// Check if this token has expired. |
|
133 |
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) { |
|
134 |
throw new ExpiredException('Expired token'); |
|
135 |
} |
|
136 |
|
|
137 |
return $payload; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* Converts and signs a PHP object or array into a JWT string. |
|
142 |
* |
|
143 |
* @param object|array $payload PHP object or array |
|
144 |
* @param string $key The secret key. |
|
145 |
* If the algorithm used is asymmetric, this is the private key |
|
146 |
* @param string $alg The signing algorithm. |
|
147 |
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
|
148 |
* @param mixed $keyId |
|
149 |
* @param array $head An array with header elements to attach |
|
150 |
* |
|
151 |
* @return string A signed JWT |
|
152 |
* |
|
153 |
* @uses jsonEncode |
|
154 |
* @uses urlsafeB64Encode |
|
155 |
*/ |
|
156 |
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null) |
|
157 |
{ |
|
158 |
$header = array('typ' => 'JWT', 'alg' => $alg); |
|
159 |
if ($keyId !== null) { |
|
160 |
$header['kid'] = $keyId; |
|
161 |
} |
|
162 |
if ( isset($head) && is_array($head) ) { |
|
163 |
$header = array_merge($head, $header); |
|
164 |
} |
|
165 |
$segments = array(); |
|
166 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header)); |
|
167 |
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload)); |
|
168 |
$signing_input = implode('.', $segments); |
|
169 |
|
|
170 |
$signature = static::sign($signing_input, $key, $alg); |
|
171 |
$segments[] = static::urlsafeB64Encode($signature); |
|
172 |
|
|
173 |
return implode('.', $segments); |
|
174 |
} |
|
175 |
|
|
176 |
/** |
|
177 |
* Sign a string with a given key and algorithm. |
|
178 |
* |
|
179 |
* @param string $msg The message to sign |
|
180 |
* @param string|resource $key The secret key |
|
181 |
* @param string $alg The signing algorithm. |
|
182 |
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256' |
|
183 |
* |
|
184 |
* @return string An encrypted message |
|
185 |
* |
|
186 |
* @throws DomainException Unsupported algorithm was specified |
|
187 |
*/ |
|
188 |
public static function sign($msg, $key, $alg = 'HS256') |
|
189 |
{ |
|
190 |
if (empty(static::$supported_algs[$alg])) { |
|
191 |
throw new DomainException('Algorithm not supported'); |
|
192 |
} |
|
193 |
list($function, $algorithm) = static::$supported_algs[$alg]; |
|
194 |
switch($function) { |
|
195 |
case 'hash_hmac': |
|
196 |
return hash_hmac($algorithm, $msg, $key, true); |
|
197 |
case 'openssl': |
|
198 |
$signature = ''; |
|
199 |
$success = openssl_sign($msg, $signature, $key, $algorithm); |
|
200 |
if (!$success) { |
|
201 |
throw new DomainException("OpenSSL unable to sign data"); |
|
202 |
} else { |
|
203 |
return $signature; |
|
204 |
} |
|
205 |
} |
|
206 |
} |
|
207 |
|
|
208 |
/** |
|
209 |
* Verify a signature with the message, key and method. Not all methods |
|
210 |
* are symmetric, so we must have a separate verify and sign method. |
|
211 |
* |
|
212 |
* @param string $msg The original message (header and body) |
|
213 |
* @param string $signature The original signature |
|
214 |
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key |
|
215 |
* @param string $alg The algorithm |
|
216 |
* |
|
217 |
* @return bool |
|
218 |
* |
|
219 |
* @throws DomainException Invalid Algorithm or OpenSSL failure |
|
220 |
*/ |
|
221 |
private static function verify($msg, $signature, $key, $alg) |
|
222 |
{ |
|
223 |
if (empty(static::$supported_algs[$alg])) { |
|
224 |
throw new DomainException('Algorithm not supported'); |
|
225 |
} |
|
226 |
|
|
227 |
list($function, $algorithm) = static::$supported_algs[$alg]; |
|
228 |
switch($function) { |
|
229 |
case 'openssl': |
|
230 |
$success = openssl_verify($msg, $signature, $key, $algorithm); |
|
231 |
if ($success === 1) { |
|
232 |
return true; |
|
233 |
} elseif ($success === 0) { |
|
234 |
return false; |
|
235 |
} |
|
236 |
// returns 1 on success, 0 on failure, -1 on error. |
|
237 |
throw new DomainException( |
|
238 |
'OpenSSL error: ' . openssl_error_string() |
|
239 |
); |
|
240 |
case 'hash_hmac': |
|
241 |
default: |
|
242 |
$hash = hash_hmac($algorithm, $msg, $key, true); |
|
243 |
if (function_exists('hash_equals')) { |
|
244 |
return hash_equals($signature, $hash); |
|
245 |
} |
|
246 |
$len = min(static::safeStrlen($signature), static::safeStrlen($hash)); |
|
247 |
|
|
248 |
$status = 0; |
|
249 |
for ($i = 0; $i < $len; $i++) { |
|
250 |
$status |= (ord($signature[$i]) ^ ord($hash[$i])); |
|
251 |
} |
|
252 |
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash)); |
|
253 |
|
|
254 |
return ($status === 0); |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
/** |
|
259 |
* Decode a JSON string into a PHP object. |
|
260 |
* |
|
261 |
* @param string $input JSON string |
|
262 |
* |
|
263 |
* @return object Object representation of JSON string |
|
264 |
* |
|
265 |
* @throws DomainException Provided string was invalid JSON |
|
266 |
*/ |
|
267 |
public static function jsonDecode($input) |
|
268 |
{ |
|
269 |
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) { |
|
270 |
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you |
|
271 |
* to specify that large ints (like Steam Transaction IDs) should be treated as |
|
272 |
* strings, rather than the PHP default behaviour of converting them to floats. |
|
273 |
*/ |
|
274 |
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING); |
|
275 |
} else { |
|
276 |
/** Not all servers will support that, however, so for older versions we must |
|
277 |
* manually detect large ints in the JSON string and quote them (thus converting |
|
278 |
*them to strings) before decoding, hence the preg_replace() call. |
|
279 |
*/ |
|
280 |
$max_int_length = strlen((string) PHP_INT_MAX) - 1; |
|
281 |
$json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input); |
|
282 |
$obj = json_decode($json_without_bigints); |
|
283 |
} |
|
284 |
|
|
285 |
if (function_exists('json_last_error') && $errno = json_last_error()) { |
|
286 |
static::handleJsonError($errno); |
|
287 |
} elseif ($obj === null && $input !== 'null') { |
|
288 |
throw new DomainException('Null result with non-null input'); |
|
289 |
} |
|
290 |
return $obj; |
|
291 |
} |
|
292 |
|
|
293 |
/** |
|
294 |
* Encode a PHP object into a JSON string. |
|
295 |
* |
|
296 |
* @param object|array $input A PHP object or array |
|
297 |
* |
|
298 |
* @return string JSON representation of the PHP object or array |
|
299 |
* |
|
300 |
* @throws DomainException Provided object could not be encoded to valid JSON |
|
301 |
*/ |
|
302 |
public static function jsonEncode($input) |
|
303 |
{ |
|
304 |
$json = json_encode($input); |
|
305 |
if (function_exists('json_last_error') && $errno = json_last_error()) { |
|
306 |
static::handleJsonError($errno); |
|
307 |
} elseif ($json === 'null' && $input !== null) { |
|
308 |
throw new DomainException('Null result with non-null input'); |
|
309 |
} |
|
310 |
return $json; |
|
311 |
} |
|
312 |
|
|
313 |
/** |
|
314 |
* Decode a string with URL-safe Base64. |
|
315 |
* |
|
316 |
* @param string $input A Base64 encoded string |
|
317 |
* |
|
318 |
* @return string A decoded string |
|
319 |
*/ |
|
320 |
public static function urlsafeB64Decode($input) |
|
321 |
{ |
|
322 |
$remainder = strlen($input) % 4; |
|
323 |
if ($remainder) { |
|
324 |
$padlen = 4 - $remainder; |
|
325 |
$input .= str_repeat('=', $padlen); |
|
326 |
} |
|
327 |
return base64_decode(strtr($input, '-_', '+/')); |
|
328 |
} |
|
329 |
|
|
330 |
/** |
|
331 |
* Encode a string with URL-safe Base64. |
|
332 |
* |
|
333 |
* @param string $input The string you want encoded |
|
334 |
* |
|
335 |
* @return string The base64 encode of what you passed in |
|
336 |
*/ |
|
337 |
public static function urlsafeB64Encode($input) |
|
338 |
{ |
|
339 |
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_')); |
|
340 |
} |
|
341 |
|
|
342 |
/** |
|
343 |
* Helper method to create a JSON error. |
|
344 |
* |
|
345 |
* @param int $errno An error number from json_last_error() |
|
346 |
* |
|
347 |
* @return void |
|
348 |
*/ |
|
349 |
private static function handleJsonError($errno) |
|
350 |
{ |
|
351 |
$messages = array( |
|
352 |
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', |
|
353 |
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON', |
|
354 |
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', |
|
355 |
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', |
|
356 |
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3 |
|
357 |
); |
|
358 |
throw new DomainException( |
|
359 |
isset($messages[$errno]) |
|
360 |
? $messages[$errno] |
|
361 |
: 'Unknown JSON error: ' . $errno |
|
362 |
); |
|
363 |
} |
|
364 |
|
|
365 |
/** |
|
366 |
* Get the number of bytes in cryptographic strings. |
|
367 |
* |
|
368 |
* @param string |
|
369 |
* |
|
370 |
* @return int |
|
371 |
*/ |
|
372 |
private static function safeStrlen($str) |
|
373 |
{ |
|
374 |
if (function_exists('mb_strlen')) { |
|
375 |
return mb_strlen($str, '8bit'); |
|
376 |
} |
|
377 |
return strlen($str); |
|
378 |
} |
|
379 |
} |
backend/vendor/firebase/php-jwt/src/SignatureInvalidException.php | ||
---|---|---|
1 |
<?php |
|
2 |
namespace Firebase\JWT; |
|
3 |
|
|
4 |
class SignatureInvalidException extends \UnexpectedValueException |
|
5 |
{ |
|
6 |
|
|
7 |
} |
Také k dispozici: Unified diff
refs #6742: Pridano api pro generovani JWT.