Merge pull request #981 from acelaya-forks/feature/cors-fix

Feature/cors fix
This commit is contained in:
Alejandro Celaya 2021-01-24 09:54:14 +01:00 committed by GitHub
commit a4de8cee7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 41 additions and 14 deletions

View file

@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## [Unreleased]
### Added
* *Nothing*
### Changed
* *Nothing*
### Deprecated
* *Nothing*
### Removed
* *Nothing*
### Fixed
* [#979](https://github.com/shlinkio/shlink/issues/979) Added missing `itemsPerPage` query param to swagger docs for short RULs list.
* [#980](https://github.com/shlinkio/shlink/issues/980) Fixed value used for `Access-Control-Allow-Origin`, that could not work as expected when including an IP address.
## [2.5.1] - 2021-01-21
### Added
* *Nothing*

View file

@ -19,6 +19,15 @@
"type": "integer"
}
},
{
"name": "itemsPerPage",
"in": "query",
"description": "The amount of items to return on every page. Defaults to 10",
"required": false,
"schema": {
"type": "number"
}
},
{
"name": "searchTerm",
"in": "query",

View file

@ -32,7 +32,7 @@ class CrossDomainMiddleware implements MiddlewareInterface, RequestMethodInterfa
}
// Add Allow-Origin header
$response = $response->withHeader('Access-Control-Allow-Origin', $request->getHeader('Origin'));
$response = $response->withHeader('Access-Control-Allow-Origin', '*');
if ($request->getMethod() !== self::METHOD_OPTIONS) {
return $response;
}

View file

@ -12,7 +12,7 @@ use function Functional\map;
use function range;
use function sprintf;
class CreateShortUrlActionTest extends ApiTestCase
class CreateShortUrlTest extends ApiTestCase
{
/** @test */
public function createsNewShortUrlWhenOnlyLongUrlIsProvided(): void

View file

@ -7,7 +7,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
class DeleteShortUrlActionTest extends ApiTestCase
class DeleteShortUrlTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

View file

@ -8,7 +8,7 @@ use GuzzleHttp\RequestOptions;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
class EditShortUrlTagsActionTest extends ApiTestCase
class EditShortUrlTagsTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

View file

@ -14,7 +14,7 @@ use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
use function GuzzleHttp\Psr7\build_query;
use function sprintf;
class EditShortUrlActionTest extends ApiTestCase
class EditShortUrlTest extends ApiTestCase
{
use ArraySubsetAsserts;
use NotFoundUrlHelpersTrait;

View file

@ -6,7 +6,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
class GlobalVisitsActionTest extends ApiTestCase
class GlobalVisitsTest extends ApiTestCase
{
/**
* @test

View file

@ -7,7 +7,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
use GuzzleHttp\RequestOptions;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
class ListTagsActionTest extends ApiTestCase
class ListTagsTest extends ApiTestCase
{
/**
* @test

View file

@ -11,7 +11,7 @@ use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
use function sprintf;
class ResolveShortUrlActionTest extends ApiTestCase
class ResolveShortUrlTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

View file

@ -11,7 +11,7 @@ use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;
use function GuzzleHttp\Psr7\build_query;
use function sprintf;
class ShortUrlVisitsActionTest extends ApiTestCase
class ShortUrlVisitsTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

View file

@ -8,7 +8,7 @@ use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use function sprintf;
class TagVisitsActionTest extends ApiTestCase
class TagVisitsTest extends ApiTestCase
{
/**
* @test

View file

@ -7,7 +7,7 @@ namespace ShlinkioApiTest\Shlink\Rest\Action;
use GuzzleHttp\RequestOptions;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
class UpdateTagActionTest extends ApiTestCase
class UpdateTagTest extends ApiTestCase
{
/**
* @test

View file

@ -35,7 +35,7 @@ class CorsTest extends ApiTestCase
]);
self::assertEquals($expectedStatusCode, $resp->getStatusCode());
self::assertEquals($origin, $resp->getHeaderLine('Access-Control-Allow-Origin'));
self::assertEquals('*', $resp->getHeaderLine('Access-Control-Allow-Origin'));
self::assertFalse($resp->hasHeader('Access-Control-Allow-Methods'));
self::assertFalse($resp->hasHeader('Access-Control-Max-Age'));
self::assertFalse($resp->hasHeader('Access-Control-Allow-Headers'));

View file

@ -61,7 +61,7 @@ class CrossDomainMiddlewareTest extends TestCase
$headers = $response->getHeaders();
self::assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertEquals('*', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertArrayNotHasKey('Access-Control-Allow-Methods', $headers);
self::assertArrayNotHasKey('Access-Control-Max-Age', $headers);
self::assertArrayNotHasKey('Access-Control-Allow-Headers', $headers);
@ -82,7 +82,7 @@ class CrossDomainMiddlewareTest extends TestCase
$headers = $response->getHeaders();
self::assertEquals('local', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertEquals('*', $response->getHeaderLine('Access-Control-Allow-Origin'));
self::assertArrayHasKey('Access-Control-Allow-Methods', $headers);
self::assertEquals('1000', $response->getHeaderLine('Access-Control-Max-Age'));
self::assertEquals('foo, bar, baz', $response->getHeaderLine('Access-Control-Allow-Headers'));