Skip to content

Commit

Permalink
Merge pull request #8 from lapwil/feature/55387
Browse files Browse the repository at this point in the history
[FEATURE#55387] Lock public key
  • Loading branch information
Guillaume Dubost authored Jun 21, 2017
2 parents a4d0f63 + 3f947d4 commit 2b9b7c8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ script:
- mkdir -p tmp/keys
- openssl genrsa -out tmp/keys/private.key 2048
- openssl rsa -in tmp/keys/private.key -pubout -out tmp/keys/public.key
- composer install --dev --prefer-source
- bin/behat -f progress
- composer self-update
- composer install --dev --no-interaction --prefer-source
- vendor/bin/behat -f progress
notify:
slack:
team : {{slackTeam}}
Expand Down
5 changes: 5 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ default:
- tests/features
formatters:
progress: true
wip:
suites:
default:
filters:
tags: '@wip'
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"repositories": [
{
"type": "composer",
"url": "http://blu-composer.herokuapp.com"
"url": "https://blu-composer.herokuapp.com"
}
]
}
14 changes: 10 additions & 4 deletions src/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ public function boot(Application $app)
$app["auth.authenticator_url"] = \trim($app["auth.authenticator_url"], "/");

$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);
if (!file_exists($file)) {
// On lock l'accès au fichier, sinon accès concurrentiel et ttkc
// La suite est bloqué tant que le fichier n'est pas accessible
$fp = fopen($file, "w+");
if (flock($fp, LOCK_EX) || filemtime($file) < strtotime("-30seconds")) {
$key = file_get_contents("{$app["auth.authenticator_url"]}/public.key");

file_put_contents($file, $key);
}
fclose($fp);
}
$this->rsa = RSA::loadPublicKey("file://" . $file);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public function setupApplication()
}

/**
* @Given /^que j\'instancie un nouvel objet$/
* @Given /^j\'instancie un nouvel objet$/
*/
public function queJInstancieUnNouvelObjet()
public function jInstancieUnNouvelObjet()
{
$this->app->register(new AuthServiceProvider());
}
Expand Down

0 comments on commit 2b9b7c8

Please sign in to comment.