Update v1.0.6.5

This commit is contained in:
sujitprasad
2016-03-02 12:25:21 +05:30
parent 7011553462
commit c56ff86194
218 changed files with 17161 additions and 2358 deletions

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\Auth;
interface AuthInterface
{
/**
* Check a user's credentials
* Check a user's credentials.
*
* @param array $credentials
* @return bool
@@ -13,7 +22,7 @@ interface AuthInterface
public function byCredentials(array $credentials = []);
/**
* Authenticate a user via the id
* Authenticate a user via the id.
*
* @param mixed $id
* @return bool
@@ -21,7 +30,7 @@ interface AuthInterface
public function byId($id);
/**
* Get the currently authenticated user
* Get the currently authenticated user.
*
* @return mixed
*/

View File

@@ -1,8 +1,16 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\Auth;
use Exception;
use Illuminate\Auth\AuthManager;
class IlluminateAuthAdapter implements AuthInterface
@@ -21,7 +29,7 @@ class IlluminateAuthAdapter implements AuthInterface
}
/**
* Check a user's credentials
* Check a user's credentials.
*
* @param array $credentials
* @return bool
@@ -32,22 +40,18 @@ class IlluminateAuthAdapter implements AuthInterface
}
/**
* Authenticate a user via the id
* Authenticate a user via the id.
*
* @param mixed $id
* @return bool
*/
public function byId($id)
{
try {
return $this->auth->onceUsingId($id);
} catch (Exception $e) {
return false;
}
return $this->auth->onceUsingId($id);
}
/**
* Get the currently authenticated user
* Get the currently authenticated user.
*
* @return mixed
*/

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\JWT;
interface JWTInterface

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\JWT;
abstract class JWTProvider
@@ -25,7 +34,7 @@ abstract class JWTProvider
}
/**
* Set the algorithm used to sign the token
* Set the algorithm used to sign the token.
*
* @param string $algo
* @return self
@@ -38,7 +47,7 @@ abstract class JWTProvider
}
/**
* Get the algorithm used to sign the token
* Get the algorithm used to sign the token.
*
* @return string
*/

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\JWT;
use Exception;
@@ -27,7 +36,7 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
}
/**
* Create a JSON Web Token
* Create a JSON Web Token.
*
* @return string
* @throws \Tymon\JWTAuth\Exceptions\JWTException
@@ -39,12 +48,12 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
return $this->jws->getTokenString();
} catch (Exception $e) {
throw new JWTException('Could not create token: ' . $e->getMessage());
throw new JWTException('Could not create token: '.$e->getMessage());
}
}
/**
* Decode a JSON Web Token
* Decode a JSON Web Token.
*
* @param string $token
* @return array
@@ -55,7 +64,7 @@ class NamshiAdapter extends JWTProvider implements JWTInterface
try {
$jws = JWS::load($token);
} catch (Exception $e) {
throw new TokenInvalidException('Could not decode token: ' . $e->getMessage());
throw new TokenInvalidException('Could not decode token: '.$e->getMessage());
}
if (! $jws->verify($this->secret, $this->algo)) {

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers;
use Tymon\JWTAuth\JWTAuth;
@@ -26,7 +35,7 @@ class JWTAuthServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__.'/../config/config.php' => config_path('jwt.php')
__DIR__.'/../config/config.php' => config_path('jwt.php'),
], 'config');
$this->bootBindings();
@@ -35,7 +44,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Bind some Interfaces and implementations
* Bind some Interfaces and implementations.
*/
protected function bootBindings()
{
@@ -102,11 +111,11 @@ class JWTAuthServiceProvider extends ServiceProvider
$this->registerPayloadFactory();
$this->registerJWTCommand();
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'jwt');
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'jwt');
}
/**
* Register the bindings for the User provider
* Register the bindings for the User provider.
*/
protected function registerUserProvider()
{
@@ -116,7 +125,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the JSON Web Token provider
* Register the bindings for the JSON Web Token provider.
*/
protected function registerJWTProvider()
{
@@ -131,7 +140,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the Auth provider
* Register the bindings for the Auth provider.
*/
protected function registerAuthProvider()
{
@@ -141,7 +150,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the Storage provider
* Register the bindings for the Storage provider.
*/
protected function registerStorageProvider()
{
@@ -151,7 +160,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the Payload Factory
* Register the bindings for the Payload Factory.
*/
protected function registerClaimFactory()
{
@@ -161,7 +170,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the JWT Manager
* Register the bindings for the JWT Manager.
*/
protected function registerJWTManager()
{
@@ -178,7 +187,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the main JWTAuth class
* Register the bindings for the main JWTAuth class.
*/
protected function registerJWTAuth()
{
@@ -196,17 +205,19 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the main JWTAuth class
* Register the bindings for the main JWTAuth class.
*/
protected function registerJWTBlacklist()
{
$this->app['tymon.jwt.blacklist'] = $this->app->share(function ($app) {
return new Blacklist($app['tymon.jwt.provider.storage']);
$instance = new Blacklist($app['tymon.jwt.provider.storage']);
return $instance->setRefreshTTL($this->config('refresh_ttl'));
});
}
/**
* Register the bindings for the payload validator
* Register the bindings for the payload validator.
*/
protected function registerPayloadValidator()
{
@@ -216,7 +227,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the bindings for the Payload Factory
* Register the bindings for the Payload Factory.
*/
protected function registerPayloadFactory()
{
@@ -228,7 +239,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Register the Artisan command
* Register the Artisan command.
*/
protected function registerJWTCommand()
{
@@ -238,7 +249,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Helper to get the config values
* Helper to get the config values.
*
* @param string $key
* @return string
@@ -249,7 +260,7 @@ class JWTAuthServiceProvider extends ServiceProvider
}
/**
* Get an instantiable configuration instance. Pinched from dingo/api :)
* Get an instantiable configuration instance. Pinched from dingo/api :).
*
* @param mixed $instance
* @return object

View File

@@ -1,9 +1,17 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\Storage;
use Illuminate\Cache\CacheManager;
use Tymon\JWTAuth\Providers\Storage\StorageInterface;
class IlluminateCacheAdapter implements StorageInterface
{
@@ -26,7 +34,7 @@ class IlluminateCacheAdapter implements StorageInterface
}
/**
* Add a new item into storage
* Add a new item into storage.
*
* @param string $key
* @param mixed $value
@@ -39,7 +47,7 @@ class IlluminateCacheAdapter implements StorageInterface
}
/**
* Check whether a key exists in storage
* Check whether a key exists in storage.
*
* @param string $key
* @return bool
@@ -50,7 +58,7 @@ class IlluminateCacheAdapter implements StorageInterface
}
/**
* Remove an item from storage
* Remove an item from storage.
*
* @param string $key
* @return bool
@@ -61,7 +69,7 @@ class IlluminateCacheAdapter implements StorageInterface
}
/**
* Remove all items associated with the tag
* Remove all items associated with the tag.
*
* @return void
*/
@@ -71,7 +79,7 @@ class IlluminateCacheAdapter implements StorageInterface
}
/**
* Return the cache instance with tags attached
* Return the cache instance with tags attached.
*
* @return \Illuminate\Cache\CacheManager
*/

View File

@@ -1,25 +1,34 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\Storage;
interface StorageInterface
{
/**
* @param string $key
* @param integer $minutes
* @param int $minutes
* @return void
*/
public function add($key, $value, $minutes);
/**
* @param string $key
* @return boolean
* @return bool
*/
public function has($key);
/**
* @param string $key
* @return boolean
* @return bool
*/
public function destroy($key);

View File

@@ -1,5 +1,14 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\User;
use Illuminate\Database\Eloquent\Model;
@@ -12,7 +21,7 @@ class EloquentUserAdapter implements UserInterface
protected $user;
/**
* Create a new User instance
* Create a new User instance.
*
* @param \Illuminate\Database\Eloquent\Model $user
*/
@@ -22,7 +31,7 @@ class EloquentUserAdapter implements UserInterface
}
/**
* Get the user by the given key, value
* Get the user by the given key, value.
*
* @param mixed $key
* @param mixed $value

View File

@@ -1,11 +1,20 @@
<?php
/*
* This file is part of jwt-auth.
*
* (c) Sean Tymon <tymon148@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Tymon\JWTAuth\Providers\User;
interface UserInterface
{
/**
* Get the user by the given key, value
* Get the user by the given key, value.
*
* @param string $key
* @param mixed $value