@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | protected $tag; |
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | - * @param \Illuminate\Cache\CacheManager $cache |
|
| 21 | + * @param Repository $cache |
|
| 22 | 22 | * @param string $tag |
| 23 | 23 | */ |
| 24 | 24 | public function __construct(Repository $cache, $tag = 'jwt') |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * Add a new item into storage. |
| 32 | 32 | * |
| 33 | 33 | * @param string $key |
| 34 | - * @param mixed $value |
|
| 34 | + * @param string $value |
|
| 35 | 35 | * @param int $minutes |
| 36 | 36 | * @return void |
| 37 | 37 | */ |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * @param string $key |
| 45 | - * @param mixed $value |
|
| 45 | + * @param string $value |
|
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | 48 | public function forever($key, $value) |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | */ |
| 90 | 90 | protected function cache() |
| 91 | 91 | { |
| 92 | - if (! method_exists($this->cache, 'tags')) { |
|
| 92 | + if (!method_exists($this->cache, 'tags')) { |
|
| 93 | 93 | return $this->cache; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -163,6 +163,10 @@ |
||
| 163 | 163 | $this->assertEquals(500, $property->getValue($list)); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | + /** |
|
| 167 | + * @param string $id |
|
| 168 | + * @param integer $exp |
|
| 169 | + */ |
|
| 166 | 170 | protected function tokenStub($id = null, $exp = null, $claims = []) |
| 167 | 171 | { |
| 168 | 172 | $builder = new \Lcobucci\JWT\Builder(); |
@@ -9,6 +9,10 @@ |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | if (!function_exists('config_path')) { |
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @param string $path |
|
| 15 | + */ |
|
| 12 | 16 | function config_path($path) { |
| 13 | 17 | return $path; |
| 14 | 18 | } |
@@ -51,13 +51,13 @@ |
||
| 51 | 51 | { |
| 52 | 52 | $app = m::mock(ApplicationStub::class)->makePartial(); |
| 53 | 53 | |
| 54 | - $app->singleton('config', function() { |
|
| 54 | + $app->singleton('config', function () { |
|
| 55 | 55 | $repo = new \Illuminate\Config\Repository(); |
| 56 | - $repo->set('jwt', include __DIR__.'/../config/jwt.php'); |
|
| 56 | + $repo->set('jwt', include __DIR__ . '/../config/jwt.php'); |
|
| 57 | 57 | return $repo; |
| 58 | 58 | }); |
| 59 | 59 | |
| 60 | - $app->singleton(\Illuminate\Contracts\Cache\Repository::class, function() { |
|
| 60 | + $app->singleton(\Illuminate\Contracts\Cache\Repository::class, function () { |
|
| 61 | 61 | return m::mock(\Illuminate\Contracts\Cache\Repository::class); |
| 62 | 62 | }); |
| 63 | 63 | |
@@ -3,13 +3,15 @@ |
||
| 3 | 3 | use Mockery as m; |
| 4 | 4 | |
| 5 | 5 | if (!function_exists('env')) { |
| 6 | - function env($name, $default = null) { |
|
| 6 | + function env($name, $default = null) |
|
| 7 | + { |
|
| 7 | 8 | return $default; |
| 8 | 9 | } |
| 9 | 10 | } |
| 10 | 11 | |
| 11 | 12 | if (!function_exists('config_path')) { |
| 12 | - function config_path($path) { |
|
| 13 | + function config_path($path) |
|
| 14 | + { |
|
| 13 | 15 | return $path; |
| 14 | 16 | } |
| 15 | 17 | } |
@@ -37,6 +37,9 @@ |
||
| 37 | 37 | { |
| 38 | 38 | use \Framgia\Jwt\SigningTokens; |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $type |
|
| 42 | + */ |
|
| 40 | 43 | public function signer($algorithm = 'sha256', $type = null) |
| 41 | 44 | { |
| 42 | 45 | // Pass call to protected method |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | // If we've already retrieved the user for the current request we can just |
| 67 | 67 | // return it back immediately. We do not want to fetch the user data on |
| 68 | 68 | // every call to this method because that would be tremendously slow. |
| 69 | - if (! is_null($this->user)) { |
|
| 69 | + if (!is_null($this->user)) { |
|
| 70 | 70 | return $this->user; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | $token = $this->getTokenForRequest(); |
| 76 | 76 | |
| 77 | - if (! is_null($token)) { |
|
| 77 | + if (!is_null($token)) { |
|
| 78 | 78 | $user = $this->provider->retrieveById($token->getClaim('sub')); |
| 79 | 79 | } |
| 80 | 80 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $builder->setSubject($id); |
| 141 | 141 | |
| 142 | 142 | if ($this->user instanceof ProvidesCredentials) { |
| 143 | - foreach($this->user->getCredentials() as $key => $value) { |
|
| 143 | + foreach ($this->user->getCredentials() as $key => $value) { |
|
| 144 | 144 | $builder->set($key, $value); |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -48,8 +48,7 @@ |
||
| 48 | 48 | Request $request, |
| 49 | 49 | Blacklist $blacklist, |
| 50 | 50 | Signer $signer |
| 51 | - ) |
|
| 52 | - { |
|
| 51 | + ) { |
|
| 53 | 52 | $this->request = $request; |
| 54 | 53 | $this->provider = $provider; |
| 55 | 54 | $this->blacklist = $blacklist; |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | { |
| 56 | 56 | // if there is no exp claim then add the jwt to |
| 57 | 57 | // the blacklist indefinitely |
| 58 | - if (! $token->hasClaim('exp')) { |
|
| 58 | + if (!$token->hasClaim('exp')) { |
|
| 59 | 59 | return $this->addForever($token); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | // check whether the expiry + grace has past |
| 117 | - return $val !== null && ! Carbon::createFromTimestamp($val['valid_until'])->isFuture(); |
|
| 117 | + return $val !== null && !Carbon::createFromTimestamp($val['valid_until'])->isFuture(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -49,4 +49,6 @@ |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | -abstract class TaggedStoreStub extends \Illuminate\Cache\TaggableStore implements \Illuminate\Contracts\Cache\Store {} |
|
| 52 | +abstract class TaggedStoreStub extends \Illuminate\Cache\TaggableStore implements \Illuminate\Contracts\Cache\Store |
|
| 53 | +{ |
|
| 54 | +} |
|
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $signer->shouldReceive('verify')->once()->andReturn(true); |
| 45 | 45 | |
| 46 | - $request->headers->set('Authorization', 'Bearer '.$token); |
|
| 46 | + $request->headers->set('Authorization', 'Bearer ' . $token); |
|
| 47 | 47 | |
| 48 | 48 | $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer); |
| 49 | 49 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $token = $signer->sign((new \Lcobucci\JWT\Builder())->setSubject(1)->setExpiration(time() + 3600))->getToken(); |
| 67 | 67 | |
| 68 | - $request->headers->set('Authorization', 'Bearer '.$token); |
|
| 68 | + $request->headers->set('Authorization', 'Bearer ' . $token); |
|
| 69 | 69 | |
| 70 | 70 | $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer); |
| 71 | 71 | |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $request = Illuminate\Http\Request::create('/'); |
| 258 | 258 | $signer->shouldReceive('verify')->once()->andReturn(true); |
| 259 | 259 | |
| 260 | - $request->headers->set('Authorization', 'Bearer '.$token); |
|
| 260 | + $request->headers->set('Authorization', 'Bearer ' . $token); |
|
| 261 | 261 | |
| 262 | 262 | $guard = new Framgia\Jwt\Guard($provider, $request, $blacklist, $signer); |
| 263 | 263 | |
@@ -20,10 +20,10 @@ |
||
| 20 | 20 | |
| 21 | 21 | // Check if provided class exists and extends BaseVerifier |
| 22 | 22 | // to avoid possible code injections |
| 23 | - if (is_subclass_of($class = Signer::class.'\\'.$type.'\\'.$algorithm, Signer\BaseSigner::class)) { |
|
| 23 | + if (is_subclass_of($class = Signer::class . '\\' . $type . '\\' . $algorithm, Signer\BaseSigner::class)) { |
|
| 24 | 24 | return new $class; |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - throw new InvalidArgumentException('['.$algorithm.'] is not supported in ['.$type.'] verifier.'); |
|
| 27 | + throw new InvalidArgumentException('[' . $algorithm . '] is not supported in [' . $type . '] verifier.'); |
|
| 28 | 28 | } |
| 29 | 29 | } |