Skip to content

Commit

Permalink
Utilisation de etna/php-rsa en v0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stem committed Nov 24, 2014
1 parent 717ca41 commit a4d0f63
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 9 additions & 9 deletions src/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -36,7 +36,7 @@ public function boot(Application $app)
throw new \Exception("\$app['{$key}']: invalid key");
break;
}

$this->app = $app;

if ($this->rsa === null) {
Expand All @@ -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);
}
}

Expand All @@ -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
*/
Expand All @@ -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;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public function generate($identity)
"identity" => $cookie,
"signature" => $signature,
]));

return $cookie;
}

Expand Down

0 comments on commit a4d0f63

Please sign in to comment.