Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cors fix #981

Merged
merged 4 commits into from
Jan 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
9 changes: 9 additions & 0 deletions docs/swagger/paths/v1_short-urls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion module/Rest/src/Middleware/CrossDomainMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

// 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use function range;
use function sprintf;

class CreateShortUrlActionTest extends ApiTestCase
class CreateShortUrlTest extends ApiTestCase
{
/** @test */
public function createsNewShortUrlWhenOnlyLongUrlIsProvided(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;

class DeleteShortUrlActionTest extends ApiTestCase
class DeleteShortUrlTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;
use ShlinkioApiTest\Shlink\Rest\Utils\NotFoundUrlHelpersTrait;

class EditShortUrlTagsActionTest extends ApiTestCase
class EditShortUrlTagsTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use function GuzzleHttp\Psr7\build_query;
use function sprintf;

class EditShortUrlActionTest extends ApiTestCase
class EditShortUrlTest extends ApiTestCase
{
use ArraySubsetAsserts;
use NotFoundUrlHelpersTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;

class GlobalVisitsActionTest extends ApiTestCase
class GlobalVisitsTest extends ApiTestCase
{
/**
* @test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use GuzzleHttp\RequestOptions;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;

class ListTagsActionTest extends ApiTestCase
class ListTagsTest extends ApiTestCase
{
/**
* @test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use function sprintf;

class ResolveShortUrlActionTest extends ApiTestCase
class ResolveShortUrlTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use function GuzzleHttp\Psr7\build_query;
use function sprintf;

class ShortUrlVisitsActionTest extends ApiTestCase
class ShortUrlVisitsTest extends ApiTestCase
{
use NotFoundUrlHelpersTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use function sprintf;

class TagVisitsActionTest extends ApiTestCase
class TagVisitsTest extends ApiTestCase
{
/**
* @test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use GuzzleHttp\RequestOptions;
use Shlinkio\Shlink\TestUtils\ApiTest\ApiTestCase;

class UpdateTagActionTest extends ApiTestCase
class UpdateTagTest extends ApiTestCase
{
/**
* @test
Expand Down
2 changes: 1 addition & 1 deletion module/Rest/test-api/Middleware/CorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function responseIncludesCorsHeadersIfOriginIsSent(
]);

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'));
Expand Down
4 changes: 2 additions & 2 deletions module/Rest/test/Middleware/CrossDomainMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function anyRequestIncludesTheAllowAccessHeader(): void

$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);
Expand All @@ -82,7 +82,7 @@ public function optionsRequestIncludesMoreHeaders(): void

$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'));
Expand Down