Activate the account if the confirmation_key matches during provisioning

Complete the documentation and test
Bump the package number
This commit is contained in:
Timothée Jaussoin 2021-11-17 11:24:51 +01:00
parent 64a6f3076a
commit d091b0dbcf
5 changed files with 60 additions and 45 deletions

View file

@ -149,7 +149,7 @@ class ProvisioningController extends Controller
$passwords = $account->passwords()->get();
foreach ($passwords as $password) { // => foreach ($passwords)
foreach ($passwords as $password) {
$section = $dom->createElement('section');
$section->setAttribute('name', 'auth_info_' . $authInfoIndex);
@ -185,6 +185,12 @@ class ProvisioningController extends Controller
}
if ($confirmationKey) {
// Activate the account
if ($account->activated == false
&& $confirmationKey == $account->confirmation_key) {
$account->activated = true;
}
$account->confirmation_key = null;
$account->save();
}

86
flexiapi/composer.lock generated
View file

@ -404,16 +404,16 @@
},
{
"name": "doctrine/dbal",
"version": "3.1.3",
"version": "3.1.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/dbal.git",
"reference": "96b0053775a544b4a6ab47654dac0621be8b4cf8"
"reference": "821b4f01a36ce63ed36c090ea74767b72db367e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/96b0053775a544b4a6ab47654dac0621be8b4cf8",
"reference": "96b0053775a544b4a6ab47654dac0621be8b4cf8",
"url": "https://api.github.com/repos/doctrine/dbal/zipball/821b4f01a36ce63ed36c090ea74767b72db367e9",
"reference": "821b4f01a36ce63ed36c090ea74767b72db367e9",
"shasum": ""
},
"require": {
@ -426,14 +426,14 @@
"require-dev": {
"doctrine/coding-standard": "9.0.0",
"jetbrains/phpstorm-stubs": "2021.1",
"phpstan/phpstan": "0.12.99",
"phpstan/phpstan-strict-rules": "^0.12.11",
"phpstan/phpstan": "1.1.1",
"phpstan/phpstan-strict-rules": "^1",
"phpunit/phpunit": "9.5.10",
"psalm/plugin-phpunit": "0.16.1",
"squizlabs/php_codesniffer": "3.6.0",
"squizlabs/php_codesniffer": "3.6.1",
"symfony/cache": "^5.2|^6.0",
"symfony/console": "^2.0.5|^3.0|^4.0|^5.0|^6.0",
"vimeo/psalm": "4.10.0"
"vimeo/psalm": "4.12.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
@ -493,7 +493,7 @@
],
"support": {
"issues": "https://github.com/doctrine/dbal/issues",
"source": "https://github.com/doctrine/dbal/tree/3.1.3"
"source": "https://github.com/doctrine/dbal/tree/3.1.4"
},
"funding": [
{
@ -509,7 +509,7 @@
"type": "tidelift"
}
],
"time": "2021-10-02T16:15:05+00:00"
"time": "2021-11-15T16:44:33+00:00"
},
{
"name": "doctrine/deprecations",
@ -1456,16 +1456,16 @@
},
{
"name": "laravel/framework",
"version": "v8.69.0",
"version": "v8.71.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "545181da688db64fed6d8427e55f630a90ca0d32"
"reference": "d822426d75ecf8e8ccd3ccd404db7202d1a9875e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/545181da688db64fed6d8427e55f630a90ca0d32",
"reference": "545181da688db64fed6d8427e55f630a90ca0d32",
"url": "https://api.github.com/repos/laravel/framework/zipball/d822426d75ecf8e8ccd3ccd404db7202d1a9875e",
"reference": "d822426d75ecf8e8ccd3ccd404db7202d1a9875e",
"shasum": ""
},
"require": {
@ -1542,12 +1542,12 @@
},
"require-dev": {
"aws/aws-sdk-php": "^3.198.1",
"doctrine/dbal": "^2.13.3|^3.1.2",
"doctrine/dbal": "^2.13.3|^3.1.4",
"filp/whoops": "^2.14.3",
"guzzlehttp/guzzle": "^6.5.5|^7.0.1",
"league/flysystem-cached-adapter": "^1.0",
"mockery/mockery": "^1.4.4",
"orchestra/testbench-core": "^6.23",
"orchestra/testbench-core": "^6.27",
"pda/pheanstalk": "^4.0",
"phpunit/phpunit": "^8.5.19|^9.5.8",
"predis/predis": "^1.1.9",
@ -1556,7 +1556,7 @@
"suggest": {
"aws/aws-sdk-php": "Required to use the SQS queue driver, DynamoDb failed job storage and SES mail driver (^3.198.1).",
"brianium/paratest": "Required to run tests in parallel (^6.0).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.2).",
"doctrine/dbal": "Required to rename columns and drop SQLite columns (^2.13.3|^3.1.4).",
"ext-bcmath": "Required to use the multiple_of validation rule.",
"ext-ftp": "Required to use the Flysystem FTP driver.",
"ext-gd": "Required to use Illuminate\\Http\\Testing\\FileFactory::image().",
@ -1577,7 +1577,7 @@
"phpunit/phpunit": "Required to use assertions and run tests (^8.5.19|^9.5.8).",
"predis/predis": "Required to use the predis connector (^1.1.9).",
"psr/http-message": "Required to allow Storage::put to accept a StreamInterface (^1.0).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0).",
"pusher/pusher-php-server": "Required to use the Pusher broadcast driver (^4.0|^5.0|^6.0|^7.0).",
"symfony/cache": "Required to PSR-6 cache bridge (^5.1.4).",
"symfony/filesystem": "Required to enable support for relative symbolic links (^5.1.4).",
"symfony/psr-http-message-bridge": "Required to use PSR-7 bridging features (^2.0).",
@ -1624,20 +1624,20 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
"time": "2021-11-02T13:53:22+00:00"
"time": "2021-11-16T15:00:50+00:00"
},
{
"name": "laravel/serializable-closure",
"version": "v1.0.3",
"version": "v1.0.4",
"source": {
"type": "git",
"url": "https://github.com/laravel/serializable-closure.git",
"reference": "6cfc678735f22ccedad761b8cae2bab14c3d8e5b"
"reference": "8148e72e6c2c3af7f05640ada1b26c3bca970f8d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/6cfc678735f22ccedad761b8cae2bab14c3d8e5b",
"reference": "6cfc678735f22ccedad761b8cae2bab14c3d8e5b",
"url": "https://api.github.com/repos/laravel/serializable-closure/zipball/8148e72e6c2c3af7f05640ada1b26c3bca970f8d",
"reference": "8148e72e6c2c3af7f05640ada1b26c3bca970f8d",
"shasum": ""
},
"require": {
@ -1683,7 +1683,7 @@
"issues": "https://github.com/laravel/serializable-closure/issues",
"source": "https://github.com/laravel/serializable-closure"
},
"time": "2021-10-07T14:00:57+00:00"
"time": "2021-11-16T17:01:57+00:00"
},
{
"name": "laravel/tinker",
@ -5494,16 +5494,16 @@
},
{
"name": "vlucas/phpdotenv",
"version": "v5.3.1",
"version": "v5.4.0",
"source": {
"type": "git",
"url": "https://github.com/vlucas/phpdotenv.git",
"reference": "accaddf133651d4b5cf81a119f25296736ffc850"
"reference": "d4394d044ed69a8f244f3445bcedf8a0d7fe2403"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/accaddf133651d4b5cf81a119f25296736ffc850",
"reference": "accaddf133651d4b5cf81a119f25296736ffc850",
"url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/d4394d044ed69a8f244f3445bcedf8a0d7fe2403",
"reference": "d4394d044ed69a8f244f3445bcedf8a0d7fe2403",
"shasum": ""
},
"require": {
@ -5526,7 +5526,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.3-dev"
"dev-master": "5.4-dev"
}
},
"autoload": {
@ -5556,7 +5556,7 @@
],
"support": {
"issues": "https://github.com/vlucas/phpdotenv/issues",
"source": "https://github.com/vlucas/phpdotenv/tree/v5.3.1"
"source": "https://github.com/vlucas/phpdotenv/tree/v5.4.0"
},
"funding": [
{
@ -5568,7 +5568,7 @@
"type": "tidelift"
}
],
"time": "2021-10-02T19:24:42+00:00"
"time": "2021-11-10T01:08:39+00:00"
},
{
"name": "voku/portable-ascii",
@ -5925,16 +5925,16 @@
},
{
"name": "facade/ignition",
"version": "2.16.0",
"version": "2.16.1",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "23400e6cc565c9dcae2c53704b4de1c4870c0697"
"reference": "29b533f63a3b269aa599d08dd4d22a0d720e295f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/23400e6cc565c9dcae2c53704b4de1c4870c0697",
"reference": "23400e6cc565c9dcae2c53704b4de1c4870c0697",
"url": "https://api.github.com/repos/facade/ignition/zipball/29b533f63a3b269aa599d08dd4d22a0d720e295f",
"reference": "29b533f63a3b269aa599d08dd4d22a0d720e295f",
"shasum": ""
},
"require": {
@ -5998,7 +5998,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2021-10-28T11:47:23+00:00"
"time": "2021-11-16T13:09:30+00:00"
},
{
"name": "facade/ignition-contracts",
@ -7700,16 +7700,16 @@
},
{
"name": "sebastian/exporter",
"version": "4.0.3",
"version": "4.0.4",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/exporter.git",
"reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65"
"reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65",
"reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65",
"url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9",
"shasum": ""
},
"require": {
@ -7758,14 +7758,14 @@
}
],
"description": "Provides the functionality to export PHP variables for visualization",
"homepage": "http://www.github.com/sebastianbergmann/exporter",
"homepage": "https://www.github.com/sebastianbergmann/exporter",
"keywords": [
"export",
"exporter"
],
"support": {
"issues": "https://github.com/sebastianbergmann/exporter/issues",
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4"
},
"funding": [
{
@ -7773,7 +7773,7 @@
"type": "github"
}
],
"time": "2020-09-28T05:24:23+00:00"
"time": "2021-11-11T14:18:36+00:00"
},
{
"name": "sebastian/global-state",

View file

@ -292,6 +292,8 @@ Return the provisioning information available in the liblinphone configuration f
Return the provisioning information available in the liblinphone configuration file.
If the `confirmation_key` is valid the related account information are added to the returned XML. The account is then considered as "provisioned" and those account related information will be removed in the upcoming requests (the content will be the same as the previous url).
If the account is not activated and the `confirmation_key` is valid. The account will be activated.
### `VISIT /provisioning/qrcode/{confirmation_key}`
Return a QRCode that points to the provisioning URL.

View file

@ -19,10 +19,12 @@
namespace Tests\Feature;
use Account;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
use App\Password;
use App\Account as DBAccount;
class AccountProvisioningTest extends TestCase
{
@ -77,6 +79,8 @@ class AccountProvisioningTest extends TestCase
$password = Password::factory()->create();
$password->account->generateApiKey();
$password->account->activated = false;
$password->account->save();
// Ensure that we get the authentication password once
$response = $this->get($this->route.'/'.$password->account->confirmation_key)
@ -84,6 +88,9 @@ class AccountProvisioningTest extends TestCase
->assertHeader('Content-Type', 'application/xml')
->assertSee('ha1');
// Check if the account has been activated
$this->assertEquals(true, DBAccount::where('id', $password->account->id)->first()->activated);
// And then twice
$response = $this->get($this->route.'/'.$password->account->confirmation_key)
->assertStatus(200)

View file

@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
%define build_number 112
%define build_number 113
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager