Skip to content

Commit feea336

Browse files
committed
Merge commit 'd0faaab6cc0dfba47cf111613ad665e7c465e2ff' into release/v0.4.1
2 parents ef4a732 + d0faaab commit feea336

File tree

13 files changed

+308
-153
lines changed

13 files changed

+308
-153
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ mutation RefreshAuthToken {
121121
}
122122
```
123123

124+
## Filters
125+
126+
The plugin offers some filters to hook into.
127+
128+
### Change Auth Token expiration
129+
130+
**Note: For security, we highly recommend, that the Auth Token is short lived. So do not set this higher than 300 seconds unless you know what you are doing.**
131+
132+
```php
133+
add_filter('graphql_jwt_auth_expire', 60);
134+
```
135+
136+
- Argument: Expiration in seconds
137+
- Default: 300
138+
124139

125140
## Example using GraphiQL
126141
![Example using GraphiQL](https://github.com/wp-graphql/wp-graphql-jwt-authentication/blob/master/img/jwt-auth-example.gif?raw=true)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"wpunit-test": "vendor/bin/codecept run wpunit"
1818
},
1919
"require": {
20-
"firebase/php-jwt": "^4.0"
20+
"firebase/php-jwt": "^5.0"
2121
},
2222
"require-dev": {
2323
"lucatume/wp-browser": ">=2.2.1 <2.2.8"

src/Auth.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Auth {
2323
public static function get_secret_key() {
2424

2525
// Use the defined secret key, if it exists
26-
$secret_key = defined( 'GRAPHQL_JWT_AUTH_SECRET_KEY' ) && ! empty( GRAPHQL_JWT_AUTH_SECRET_KEY ) ? GRAPHQL_JWT_AUTH_SECRET_KEY : 'graphql-jwt-auth';
26+
$secret_key = defined( 'GRAPHQL_JWT_AUTH_SECRET_KEY' ) && ! empty( GRAPHQL_JWT_AUTH_SECRET_KEY ) ? GRAPHQL_JWT_AUTH_SECRET_KEY : null;
2727
return apply_filters( 'graphql_jwt_auth_secret_key', $secret_key );
2828

2929
}
@@ -105,19 +105,17 @@ public static function get_token_expiration() {
105105
/**
106106
* Set the expiration time, default is 300 seconds.
107107
*/
108-
$expiration = self::get_token_issued() + 300;
108+
$expiration = 300;
109109

110110
/**
111-
* Determine the expiration value. Default is 7 days, but is filterable to be configured as needed
111+
* Determine the expiration value. Default is 5 minutes, but is filterable to be configured as needed
112112
*
113113
* @param string $expiration The timestamp for when the token should expire
114114
*/
115-
self::$expiration = apply_filters( 'graphql_jwt_auth_expire', $expiration );
116-
115+
self::$expiration = self::get_token_issued() + apply_filters( 'graphql_jwt_auth_expire', $expiration );
117116
}
118117

119118
return ! empty( self::$expiration ) ? self::$expiration : null;
120-
121119
}
122120

123121
/**

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
require_once __DIR__ . '/composer/autoload_real.php';
66

7-
return ComposerAutoloaderInit2bca884894f5dad38a04fb4589efa493::getLoader();
7+
return ComposerAutoloaderInitb81212723df6ec6a4125604686c14dbf::getLoader();

vendor/composer/autoload_real.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit2bca884894f5dad38a04fb4589efa493
5+
class ComposerAutoloaderInitb81212723df6ec6a4125604686c14dbf
66
{
77
private static $loader;
88

@@ -19,15 +19,15 @@ public static function getLoader()
1919
return self::$loader;
2020
}
2121

22-
spl_autoload_register(array('ComposerAutoloaderInit2bca884894f5dad38a04fb4589efa493', 'loadClassLoader'), true, true);
22+
spl_autoload_register(array('ComposerAutoloaderInitb81212723df6ec6a4125604686c14dbf', 'loadClassLoader'), true, true);
2323
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24-
spl_autoload_unregister(array('ComposerAutoloaderInit2bca884894f5dad38a04fb4589efa493', 'loadClassLoader'));
24+
spl_autoload_unregister(array('ComposerAutoloaderInitb81212723df6ec6a4125604686c14dbf', 'loadClassLoader'));
2525

2626
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
2727
if ($useStaticLoader) {
2828
require_once __DIR__ . '/autoload_static.php';
2929

30-
call_user_func(\Composer\Autoload\ComposerStaticInit2bca884894f5dad38a04fb4589efa493::getInitializer($loader));
30+
call_user_func(\Composer\Autoload\ComposerStaticInitb81212723df6ec6a4125604686c14dbf::getInitializer($loader));
3131
} else {
3232
$map = require __DIR__ . '/autoload_namespaces.php';
3333
foreach ($map as $namespace => $path) {

vendor/composer/autoload_static.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Composer\Autoload;
66

7-
class ComposerStaticInit2bca884894f5dad38a04fb4589efa493
7+
class ComposerStaticInitb81212723df6ec6a4125604686c14dbf
88
{
99
public static $prefixLengthsPsr4 = array (
1010
'W' =>
@@ -42,9 +42,9 @@ class ComposerStaticInit2bca884894f5dad38a04fb4589efa493
4242
public static function getInitializer(ClassLoader $loader)
4343
{
4444
return \Closure::bind(function () use ($loader) {
45-
$loader->prefixLengthsPsr4 = ComposerStaticInit2bca884894f5dad38a04fb4589efa493::$prefixLengthsPsr4;
46-
$loader->prefixDirsPsr4 = ComposerStaticInit2bca884894f5dad38a04fb4589efa493::$prefixDirsPsr4;
47-
$loader->classMap = ComposerStaticInit2bca884894f5dad38a04fb4589efa493::$classMap;
45+
$loader->prefixLengthsPsr4 = ComposerStaticInitb81212723df6ec6a4125604686c14dbf::$prefixLengthsPsr4;
46+
$loader->prefixDirsPsr4 = ComposerStaticInitb81212723df6ec6a4125604686c14dbf::$prefixDirsPsr4;
47+
$loader->classMap = ComposerStaticInitb81212723df6ec6a4125604686c14dbf::$classMap;
4848

4949
}, null, ClassLoader::class);
5050
}

vendor/composer/installed.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
[
22
{
33
"name": "firebase/php-jwt",
4-
"version": "v4.0.0",
5-
"version_normalized": "4.0.0.0",
4+
"version": "v5.1.0",
5+
"version_normalized": "5.1.0.0",
66
"source": {
77
"type": "git",
88
"url": "https://github.com/firebase/php-jwt.git",
9-
"reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35"
9+
"reference": "4566062c68f76f43d44f1643f4970fe89757d4c6"
1010
},
1111
"dist": {
1212
"type": "zip",
13-
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
14-
"reference": "dccf163dc8ed7ed6a00afc06c51ee5186a428d35",
13+
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/4566062c68f76f43d44f1643f4970fe89757d4c6",
14+
"reference": "4566062c68f76f43d44f1643f4970fe89757d4c6",
1515
"shasum": ""
1616
},
1717
"require": {
1818
"php": ">=5.3.0"
1919
},
20-
"time": "2016-07-18T04:51:16+00:00",
20+
"require-dev": {
21+
"phpunit/phpunit": "^4.8|^5"
22+
},
23+
"time": "2020-02-24T23:15:03+00:00",
2124
"type": "library",
2225
"installation-source": "dist",
2326
"autoload": {

vendor/firebase/php-jwt/README.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Example
2323
use \Firebase\JWT\JWT;
2424

2525
$key = "example_key";
26-
$token = array(
26+
$payload = array(
2727
"iss" => "http://example.org",
2828
"aud" => "http://example.com",
2929
"iat" => 1356999524,
@@ -36,7 +36,7 @@ $token = array(
3636
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
3737
* for a list of spec-compliant algorithms.
3838
*/
39-
$jwt = JWT::encode($token, $key);
39+
$jwt = JWT::encode($payload, $key);
4040
$decoded = JWT::decode($jwt, $key, array('HS256'));
4141

4242
print_r($decoded);
@@ -58,12 +58,87 @@ $decoded_array = (array) $decoded;
5858
JWT::$leeway = 60; // $leeway in seconds
5959
$decoded = JWT::decode($jwt, $key, array('HS256'));
6060

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+
$payload = array(
97+
"iss" => "example.org",
98+
"aud" => "example.com",
99+
"iat" => 1356999524,
100+
"nbf" => 1357000000
101+
);
102+
103+
$jwt = JWT::encode($payload, $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";
61115
?>
62116
```
63117

64118
Changelog
65119
---------
66120

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+
67142
#### 4.0.0 / 2016-07-17
68143
- 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)!
69144
- 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)!
@@ -114,6 +189,12 @@ Time: 0 seconds, Memory: 2.50Mb
114189
OK (5 tests, 5 assertions)
115190
```
116191

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+
117198
License
118199
-------
119200
[3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause).

vendor/firebase/php-jwt/composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323
"Firebase\\JWT\\": "src"
2424
}
2525
},
26-
"minimum-stability": "dev"
26+
"require-dev": {
27+
"phpunit/phpunit": "^4.8|^5"
28+
}
2729
}

vendor/firebase/php-jwt/composer.lock

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)