Using custom digester
This commit is contained in:
parent
94e719132b
commit
bf5467515d
@ -3,17 +3,12 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Antadis\Auth\Wsse\WsseAuthServiceProvider;
|
||||||
use Antadis\Security\Wsse\WsseHeaderGenerator;
|
use Antadis\Security\Wsse\WsseHeaderGenerator;
|
||||||
use Antadis\Security\Wsse\Dater;
|
|
||||||
use Antadis\Security\Wsse\Noncer;
|
|
||||||
use Antadis\Security\Wsse\Digester;
|
|
||||||
use Antadis\Gateways\Prestashop;
|
|
||||||
use Illuminate\Support\Facades\Gate;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
|
||||||
|
|
||||||
use ApiUser;
|
use ApiUser;
|
||||||
|
|
||||||
class AuthServiceProvider extends ServiceProvider
|
class AuthServiceProvider extends WsseAuthServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register any application services.
|
* Register any application services.
|
||||||
@ -32,16 +27,29 @@ class AuthServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
$this->app['auth']->viaRequest('api', function ($request) {
|
if (env('APP_DEBUG') === true) {
|
||||||
//BRICO USER 2553994 (latour@antadis.com)
|
$this->app['auth']->viaRequest('api', function ($request) {
|
||||||
//BBB USER 952478 (marion@antadis.com)
|
//BRICO USER 2553994 (latour@antadis.com)
|
||||||
$user = new ApiUser(952478);
|
//BBB USER 952478 (marion@antadis.com)
|
||||||
if (\Validate::isLoadedObject($user)) {
|
$user = new ApiUser(952478);
|
||||||
return $user;
|
if (\Validate::isLoadedObject($user)) {
|
||||||
} else {
|
return $user;
|
||||||
return null;
|
} else {
|
||||||
}
|
return null;
|
||||||
return User::findByEmail('latour@antadis.com');
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
parent::boot();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the digester
|
||||||
|
*
|
||||||
|
* @return Antadis\Security\Wsse\Digester
|
||||||
|
*/
|
||||||
|
protected function getDigester() {
|
||||||
|
return new Digester();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
app/Providers/Digester.php
Normal file
14
app/Providers/Digester.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Providers;
|
||||||
|
|
||||||
|
use Antadis\Security\Wsse\DigesterInterface;
|
||||||
|
|
||||||
|
class Digester implements DigesterInterface {
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function generate($nonce, $created, $password) {
|
||||||
|
return base64_encode(sha1($nonce.$created.$password, false));
|
||||||
|
}
|
||||||
|
}
|
@ -95,14 +95,7 @@ $app->routeMiddleware([
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//$app->register(Antadis\Gateways\Prestashop\ServiceProvider::class);
|
$app->register(App\Providers\AuthServiceProvider::class);
|
||||||
if (env('APP_DEBUG') === true) {
|
|
||||||
//AUTOLOGGED USER
|
|
||||||
$app->register(App\Providers\AuthServiceProvider::class);
|
|
||||||
} else {
|
|
||||||
//REAL APP USER
|
|
||||||
$app->register(Antadis\Auth\Wsse\WsseAuthServiceProvider::class);
|
|
||||||
}
|
|
||||||
$app->register(Barryvdh\Cors\ServiceProvider::class);
|
$app->register(Barryvdh\Cors\ServiceProvider::class);
|
||||||
$app->register(Antadis\API\Front\ApiProvider::class);
|
$app->register(Antadis\API\Front\ApiProvider::class);
|
||||||
|
|
||||||
|
@ -6,7 +6,8 @@ return array(
|
|||||||
'ApiTag' => 'App\Models\Tag',
|
'ApiTag' => 'App\Models\Tag',
|
||||||
'ApiCart' => 'App\Models\Cart',
|
'ApiCart' => 'App\Models\Cart',
|
||||||
'ApiCarrier' => 'App\Models\Carrier',
|
'ApiCarrier' => 'App\Models\Carrier',
|
||||||
'ApiOrderDetail' => 'App\Models\Order\OrderDetail'
|
'ApiOrderDetail' => 'App\Models\Order\OrderDetail',
|
||||||
|
'ApiUser' => 'App\Models\User',
|
||||||
],
|
],
|
||||||
'controllers' => [
|
'controllers' => [
|
||||||
'ApiBaseController' => 'App\Web\Controllers\Controller',
|
'ApiBaseController' => 'App\Web\Controllers\Controller',
|
||||||
|
9
config/wsse.php
Normal file
9
config/wsse.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return array(
|
||||||
|
/* USER MODEL TO USE */
|
||||||
|
'userModel' => 'App\\Models\\User',
|
||||||
|
|
||||||
|
/* HOW MUCH TIME THE SIGNATURE IS ALIVE. PUT IT TO 0 TO ENABLE ENDLESS SIGNATURES */
|
||||||
|
'ttl' => 0,
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user