mobieve / auth-client
This package provides Classes for Auth Clients made by Mobieve.
Installs: 635
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/mobieve/auth-client
Requires
- php: ^7.1.3
- guzzlehttp/guzzle: ^6.5.0
- illuminate/support: ^6.0
- symfony/http-kernel: ^4.4.1
- symfony/psr-http-message-bridge: ^2.0
- tymon/jwt-auth: ^1.0.0-rc-5
README
Mobieve Auth Client PHP
This package provides Classes for Auth Clients made by Mobieve.
- Mobieve\AuthClient\Facades\CustomClient
- Mobieve\AuthClient\Middleware\MobieveAuthMiddleware
- Mobieve\AuthClient\Models\CustomClient
- Mobieve\AuthClient\Providers\CustomClientServiceProvider
Mobieve Custom HTTP Client
Configuration
In config/app.php include:
'providers' => [ ... Mobieve\AuthClient\Providers\CustomClientServiceProvider::class ],
and:
'aliases' => [ ... 'JWTFactory' => Tymon\JWTAuth\Facades\JWTFactory::class, 'JWTAuth' => Tymon\JWTAuth\Facades\JWTAuth::class, 'MobieveClient' => Mobieve\AuthClient\Facades\CustomClient::class ],
If user requests is needed you also need to include:
'aliases' => [ ... 'Auth' => Illuminate\Support\Facades\Auth::class, 'User' => App\User::class, 'Team' => App\Team::class ],
You also need to configure auth service info in config/services.php, like:
return [ ... 'auth' => [ 'url' => env('MOBIEVE_AUTH_URL') . '/oauth/token', 'client_id' => env('MOBIEVE_AUTH_CLIENT_ID'), 'client_secret' => env('MOBIEVE_AUTH_CLIENT_SECRET') ] ];
and include your personal MOBIEVE_AUTH_CLIENT_ID and MOBIEVE_AUTH_CLIENT_SECRET in your environment variables.
Usage
MobieveClient::get(string $url, array $params); MobieveClient::post(string $url, array $params); MobieveClient::put(string $url, array $params); MobieveClient::delete(string $url);
Middleware
Four different middleware classes are available.
MobieveClientAuthMiddleware is used to ensure that the requester is a Client registered in Mobieve Auth server.
MobieveUserAuthMiddleware, on the other hand, is used to ensure that the requester is an User registered in Mobieve Auth server.
MobieveUserTeamAuthMiddleware, is used to ensure thar the request is an User with Team registered in Mobieve Auth server.
MobieveAuthMiddleware, will only check if token is valid.
To use Mobieve Middleware layer in order to check incoming requests authorization include following line in Http/Kernel.php:
You need to include the middleware that you want to use in Http/Kernel.php file, as demonstrated below:
protected $routeMiddleware = [ ... 'mobieve.auth-client' => \Mobieve\AuthClient\Middleware\MovieveClientAuthMiddleware::class, 'mobieve.auth-user' => \Mobieve\AuthClient\Middleware\MovieveClientAuthMiddleware::class ];
and add 'mobieve.auth-client' or 'mobieve.auth-user' in all routes you need to protect, according to the desired behavior.