mirror of
https://gitlab.linphone.org/BC/public/flexisip-account-manager.git
synced 2026-01-17 01:58:07 +00:00
Fix FLEXIAPI-262 Bypass the JWT auth if we have an API
This commit is contained in:
parent
0d48ff3964
commit
1b1df7eef8
3 changed files with 15 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ v1.7
|
|||
- Fix FLEXIAPI-255 Create a INSTALL.md tutorial and log FlexisipPusherConnector errors
|
||||
- Fix FLEXIAPI-257 Return a more coherent message when search API endpoints returns a 404
|
||||
- Fix FLEXIAPI-260 Return 404 and not 403 if the contact is already in the list or missing when removing it
|
||||
- Fix FLEXIAPI-262 Bypass the JWT auth if we have an API Key
|
||||
|
||||
v1.6
|
||||
----
|
||||
|
|
|
|||
|
|
@ -99,7 +99,12 @@ class AuthenticateJWT
|
|||
return $next($request);
|
||||
}
|
||||
|
||||
if (!empty(config('app.account_authentication_bearer'))) {
|
||||
if (
|
||||
!empty(config('app.account_authentication_bearer'))
|
||||
// Bypass the JWT auth if we have an API Key
|
||||
&& !$request->header('x-api-key')
|
||||
&& !$request->cookie('x-api-key')
|
||||
) {
|
||||
$response = new Response();
|
||||
|
||||
$response->header(
|
||||
|
|
|
|||
|
|
@ -64,13 +64,20 @@ class ApiAccountApiKeyTest extends TestCase
|
|||
->json($this->method, '/api/accounts/me')
|
||||
->assertStatus(200);
|
||||
|
||||
$this->keyAuthenticated($account)
|
||||
->json($this->method, '/api/accounts/me')
|
||||
->assertStatus(200);
|
||||
|
||||
// Bypass the JWT middleware
|
||||
config()->set('app.account_authentication_bearer', 'fake-bearer');
|
||||
|
||||
$this->keyAuthenticated($account)
|
||||
->json($this->method, '/api/accounts/me')
|
||||
->assertStatus(200);
|
||||
|
||||
$this->assertDatabaseHas('api_keys', [
|
||||
'account_id' => $account->id,
|
||||
'requests' => 2
|
||||
'requests' => 3
|
||||
]);
|
||||
|
||||
DB::table('api_keys')->update(['ip' => 'no_localhost']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue