Skip to content

Commit

Permalink
Run CS fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
XWB committed Feb 12, 2020
1 parent 4ef2310 commit 9071aa5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions Controller/RedirectToServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use RuntimeException;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
* @author Alexander <[email protected]>
Expand Down Expand Up @@ -100,7 +100,6 @@ private function storeReturnPath(Request $request, string $authorizationUrl): vo
$sessionKeyFailure = '_security.'.$providerKey.'.failed_target_path';

if (!empty($param) && $targetUrl = $request->get($param)) {

if (!$this->domainWhitelist->isValidTargetUrl($targetUrl)) {
throw new AccessDeniedHttpException('Not allowed to redirect to '.$targetUrl);
}
Expand Down
1 change: 0 additions & 1 deletion Tests/Controller/RedirectToServiceControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ protected function setUp(): void
$this->oAuthUtils = $this->createMock(OAuthUtils::class);
$this->domainsWhiteList = $this->createMock(DomainWhitelist::class);


$this->session = $this->createMock(SessionInterface::class);
$this->request = Request::create('/');
$this->request->setSession($this->session);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Util/DomainWhitelistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

namespace HWI\Bundle\OAuthBundle\Tests\Util;

use PHPUnit\Framework\TestCase;
use HWI\Bundle\OAuthBundle\Util\DomainWhitelist;
use PHPUnit\Framework\TestCase;

class DomainWhitelistTest extends TestCase
{
/**
* @dataProvider targetUrlProvider
*
* @param string $targetUrl
* @param array $domainsWhitelistParameter
* @param bool $isValidTargetUrl
* @param array $domainsWhitelistParameter
* @param bool $isValidTargetUrl
*/
public function testValidateTargetUrl($targetUrl, $domainsWhitelistParameter, $isValidTargetUrl)
{
Expand All @@ -38,4 +38,4 @@ public function targetUrlProvider()
['https://example.com/redirect', ['foobar.com', 'example.com'], true],
];
}
}
}
7 changes: 4 additions & 3 deletions Util/DomainWhitelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ public function __construct(array $targetPathDomainsWhiteList)

/**
* @param string $targetUrl
*
* @return bool
*/
public function isValidTargetUrl(string $targetUrl)
{
if (0 === count($this->targetPathDomainsWhiteList)) {
if (0 === \count($this->targetPathDomainsWhiteList)) {
return true;
}

Expand All @@ -44,10 +45,10 @@ public function isValidTargetUrl(string $targetUrl)
return false;
}

if (!in_array($urlParts['host'], $this->targetPathDomainsWhiteList, true)) {
if (!\in_array($urlParts['host'], $this->targetPathDomainsWhiteList, true)) {
return false;
}

return true;
}
}
}

0 comments on commit 9071aa5

Please sign in to comment.