From a4d0f63446af4a2b66e6c7d7f2d0bef34b2f59a1 Mon Sep 17 00:00:00 2001 From: Stephane CRIVISIER Date: Mon, 24 Nov 2014 15:41:09 +0100 Subject: [PATCH] Utilisation de etna/php-rsa en v0.2.0 --- composer.json | 2 +- src/AuthServiceProvider.php | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 5b91dd3..707983c 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "require": { "php": ">=5.5", "silex/silex": "1.x", - "etna/php-rsa": "0.x" + "etna/php-rsa": "~0.2.0" }, "require-dev": { "behat/behat": "~3.0" diff --git a/src/AuthServiceProvider.php b/src/AuthServiceProvider.php index af50966..95594ef 100644 --- a/src/AuthServiceProvider.php +++ b/src/AuthServiceProvider.php @@ -14,17 +14,17 @@ class AuthServiceProvider implements ServiceProviderInterface { private $app = null; private $rsa = null; - + public function __construct(RSA $rsa = null) { $this->rsa = $rsa; } - + public function setRSA(RSA $rsa) { $this->rsa = $rsa; } - + /** * Check configuration and load public key */ @@ -36,7 +36,7 @@ public function boot(Application $app) throw new \Exception("\$app['{$key}']: invalid key"); break; } - + $this->app = $app; if ($this->rsa === null) { @@ -52,10 +52,10 @@ public function boot(Application $app) $file = $app["auth.public_key.tmp_path"]; if (!file_exists($file) || filemtime($file) < strtotime("-30seconds")) { $key = file_get_contents("{$app["auth.authenticator_url"]}/public.key"); - + file_put_contents($file, $key); } - $this->rsa = RSA::loadPublicKey($file); + $this->rsa = RSA::loadPublicKey("file://" . $file); } } @@ -81,7 +81,7 @@ public function register(Application $app) $app["auth.authenticated"] = [$this, "authenticated"]; $app["auth.secure"] = [$this, "userHasGroup"]; } - + /** * Add a user object to the current request */ @@ -97,7 +97,7 @@ public function addUserToRequest(Request $req) } // La conf me demande de forcer le guest - + if (!isset($req->user->login_date) || ($this->app["auth.force_guest"] && $req->user->login_date == null)) { $req->user = null; } @@ -152,7 +152,7 @@ public function generate($identity) "identity" => $cookie, "signature" => $signature, ])); - + return $cookie; }