-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/release/2.10'
- Loading branch information
Showing
15 changed files
with
243 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Use this service definition file to override services and parameters in the test environment. | ||
# For example to mock certain services, or override a parameter for test. | ||
|
||
parameters: | ||
middleware_credentials_password: secret | ||
|
||
services: | ||
surfnet_stepup.service.sms_second_factor: | ||
class: Surfnet\StepupBundle\Tests\TestDouble\Service\SmsSecondFactorService | ||
arguments: | ||
- "@surfnet_stepup.service.challenge_handler" | ||
|
||
# The middleware client bundle guzzle client is overloaded to be able to pass the testcookie to the ensure MW is | ||
# loaded in test mode. This way people setting the testcookie in prod will not switch their mw api into testmode | ||
# resulting in 500 errors. | ||
surfnet_stepup_middleware_client.guzzle.api: | ||
public: false | ||
class: GuzzleHttp\Client | ||
factory: ['Surfnet\StepupRa\RaBundle\Tests\TestDouble\Factory\GuzzleApiFactory', createApiGuzzleClient] | ||
arguments: | ||
- "%middleware_url_api%" | ||
- "%middleware_credentials_username%" | ||
- "%middleware_credentials_password%" | ||
|
||
surfnet_stepup_middleware_client.guzzle.commands: | ||
public: false | ||
class: GuzzleHttp\Client | ||
factory: ['Surfnet\StepupRa\RaBundle\Tests\TestDouble\Factory\GuzzleApiFactory', createCommandGuzzleClient] | ||
arguments: | ||
- "%middleware_url_command_api%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
use Symfony\Component\Debug\Debug; | ||
use Symfony\Component\HttpFoundation\Request; | ||
$loader = require __DIR__.'/../app/autoload.php'; | ||
Debug::enable(~E_USER_DEPRECATED); | ||
|
||
$request = Request::createFromGlobals(); | ||
|
||
$kernel = new AppKernel('test', true); | ||
$kernel->boot(); | ||
|
||
$trustedProxies = $kernel->getContainer()->getParameter('trusted_proxies'); | ||
Request::setTrustedProxies($trustedProxies, Request::HEADER_X_FORWARDED_ALL); | ||
|
||
$response = $kernel->handle($request); | ||
$response->send(); | ||
$kernel->terminate($request, $response); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Surfnet/StepupRa/RaBundle/Security/Authentication/Handler/LogoutSuccessHandler.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2019 SURFnet B.V. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\StepupRa\RaBundle\Security\Authentication\Handler; | ||
|
||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Symfony\Component\Security\Http\Logout\LogoutSuccessHandlerInterface; | ||
|
||
final class LogoutSuccessHandler implements LogoutSuccessHandlerInterface | ||
{ | ||
/** | ||
* @var TokenStorageInterface | ||
*/ | ||
private $tokenStorage; | ||
|
||
/** | ||
* @var string[] | ||
*/ | ||
private $logoutRedirectUrl; | ||
|
||
/** | ||
* @param TokenStorageInterface $tokenStorage | ||
* @param string[] $logoutRedirectUrl | ||
*/ | ||
public function __construct(TokenStorageInterface $tokenStorage, array $logoutRedirectUrl) | ||
{ | ||
$this->tokenStorage = $tokenStorage; | ||
$this->logoutRedirectUrl = $logoutRedirectUrl; | ||
} | ||
|
||
public function onLogoutSuccess(Request $request) | ||
{ | ||
$token = $this->tokenStorage->getToken(); | ||
$identity = $token->getUser(); | ||
|
||
return new RedirectResponse($this->logoutRedirectUrl[$identity->preferredLocale]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/Surfnet/StepupRa/RaBundle/Tests/TestDouble/Factory/GuzzleApiFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright 2018 SURFnet bv | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace Surfnet\StepupRa\RaBundle\Tests\TestDouble\Factory; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Cookie\CookieJar; | ||
|
||
/** | ||
* This factory builds replacements for the Guzzle clients that are normally provided by the middleware bundle. The | ||
* added extra in this factory is that the testcookie is added to the configuration. | ||
*/ | ||
class GuzzleApiFactory | ||
{ | ||
/** | ||
* @param $apiUri | ||
* @param $username | ||
* @param $password | ||
* @return Client | ||
* | ||
* @see \Surfnet\StepupMiddlewareClientBundle\DependencyInjection\SurfnetStepupMiddlewareClientExtension::configureMiddlewareReadApiClient | ||
*/ | ||
public static function createApiGuzzleClient($apiUri, $username, $password) | ||
{ | ||
$arguments = [ | ||
'base_uri' => $apiUri, | ||
'auth' => [ | ||
$username, | ||
$password, | ||
'basic', | ||
], | ||
'headers' => [ | ||
'Accept' => 'application/json', | ||
], | ||
'cookies' => self::makeCookieJar($apiUri), | ||
]; | ||
|
||
return new Client($arguments); | ||
} | ||
|
||
/** | ||
* @param $apiUri | ||
* @return Client | ||
* | ||
* @see \Surfnet\StepupMiddlewareClientBundle\DependencyInjection\SurfnetStepupMiddlewareClientExtension::configureMiddlewareCommandApiUrl | ||
*/ | ||
public static function createCommandGuzzleClient($apiUri) | ||
{ | ||
return new Client( | ||
[ | ||
'base_uri' => $apiUri, | ||
'cookies' => self::makeCookieJar($apiUri), | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* @param string $uri | ||
* @return CookieJar | ||
*/ | ||
private static function makeCookieJar($uri) | ||
{ | ||
$cookieDomain = parse_url($uri, PHP_URL_HOST); | ||
|
||
return CookieJar::fromArray( | ||
[ | ||
'testcookie' => 'testcookie', | ||
], | ||
$cookieDomain | ||
); | ||
} | ||
} |