mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-04-17 11:48:28 +00:00
Fix FLEXIAPI-347 Allow IPv4 and IPv6 in the External Account domain attribute
This commit is contained in:
parent
6a1f3471d6
commit
6550a9082c
6 changed files with 35 additions and 7 deletions
|
|
@ -3,7 +3,7 @@ variables:
|
|||
ROCKY_9_IMAGE_VERSION: 20250702_171314_update_rocky9_dockerhub
|
||||
ROCKY_10_IMAGE_VERSION: 20250908_164454_rocky10_first
|
||||
DEBIAN_12_IMAGE_VERSION: 20250908_154742_refresh_dependencies
|
||||
DEBIAN_13_IMAGE_VERSION: 20251204_115628_update_packages
|
||||
DEBIAN_13_IMAGE_VERSION: 20260120_152506_update_packages
|
||||
PHP_REDIS_REMI_VERSION: php-pecl-redis6-6.1.0-1
|
||||
PHP_IGBINARY_REMI_VERSION: php-pecl-igbinary-3.2.16-2
|
||||
PHP_MSGPACK_REMI_VERSION: php-pecl-msgpack-2.2.0-3
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ namespace App\Http\Controllers\Admin;
|
|||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\ExternalAccount\CreateUpdate;
|
||||
use App\Services\AccountService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\ExternalAccount;
|
||||
use App\Account;
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
namespace App\Http\Requests\ExternalAccount;
|
||||
|
||||
use App\Rules\DomainOrIp;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
use App\ExternalAccount;
|
||||
use App\Rules\SIPUsername;
|
||||
use App\Rules\Domain;
|
||||
|
||||
class CreateUpdate extends FormRequest
|
||||
{
|
||||
|
|
@ -40,7 +40,7 @@ class CreateUpdate extends FormRequest
|
|||
|
||||
return [
|
||||
'username' => ['required', $usernameValidation, new SIPUsername()],
|
||||
'domain' => ['required', new Domain()],
|
||||
'domain' => ['required', new DomainOrIp()],
|
||||
'realm' => 'different:domain',
|
||||
'registrar' => 'different:domain',
|
||||
'outbound_proxy' => 'different:domain',
|
||||
|
|
|
|||
22
flexiapi/app/Rules/DomainOrIp.php
Normal file
22
flexiapi/app/Rules/DomainOrIp.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace App\Rules;
|
||||
|
||||
use App\Space;
|
||||
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
use Respect\Validation\Validator;
|
||||
|
||||
class DomainOrIp implements Rule
|
||||
{
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return Validator::regex('/' . Space::DOMAIN_REGEX . '/')->validate($value)
|
||||
|| Validator::ip()->validate($value);
|
||||
}
|
||||
|
||||
public function message()
|
||||
{
|
||||
return 'The :attribute should be a valid domain';
|
||||
}
|
||||
}
|
||||
|
|
@ -77,7 +77,7 @@ class ApiAccountExternalAccountTest extends TestCase
|
|||
$this->keyAuthenticated($admin)
|
||||
->json($this->method, $this->route . '/' . $account->id . '/external/', [
|
||||
'username' => $username . '3',
|
||||
'domain' => 'bar.dev',
|
||||
'domain' => '127.0.0.1', // IPv4
|
||||
'realm' => 'newrealm',
|
||||
'protocol' => 'UDP'
|
||||
])->assertJsonValidationErrors(['password']);
|
||||
|
|
@ -96,5 +96,13 @@ class ApiAccountExternalAccountTest extends TestCase
|
|||
$this->keyAuthenticated($admin)
|
||||
->get($this->route . '/' . $account->id . '/external/')
|
||||
->assertStatus(404);
|
||||
|
||||
$this->keyAuthenticated($admin)
|
||||
->json($this->method, $this->route . '/' . $account->id . '/external/', [
|
||||
'username' => $username,
|
||||
'domain' => '2345:425:2CA1:0000:0000:567:5673:23b5', // IPv6
|
||||
'password' => 'password',
|
||||
'protocol' => 'UDP'
|
||||
])->assertStatus(201);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue