From ef1856d9b4bebdc692541f2ce010792c2b3a7d6b Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Thu, 21 May 2015 14:57:06 +0200 Subject: [PATCH 01/36] Move SMS second factor verification to Stepup bundle. --- app/config/config.yml | 20 +- composer.json | 2 +- composer.lock | 50 +-- ...SelfServiceSamlStepupProviderExtension.php | 4 +- .../Command/RevokeCommand.php | 1 - .../Command/SendSmsCommand.php | 59 ---- .../Controller/Controller.php | 1 - .../SelfServiceBundle/DateTime/DateTime.php | 37 --- .../DependencyInjection/Configuration.php | 148 --------- ...tStepupSelfServiceSelfServiceExtension.php | 29 -- .../Resources/config/services.yml | 28 +- .../Authentication/SessionHandler.php | 1 - .../TooManyChallengesRequestedException.php | 25 -- .../Service/SmsSecondFactor/Otp.php | 105 ------- .../SmsSecondFactor/OtpVerification.php | 106 ------- .../SessionSmsVerificationStateHandler.php | 117 ------- .../SmsSecondFactor/SmsVerificationState.php | 133 -------- .../SmsVerificationStateHandler.php | 62 ---- .../Service/SmsSecondFactorService.php | 78 ++--- .../SelfServiceBundle/Service/SmsService.php | 97 ------ .../Tests/DateTimeHelper.php | 37 --- .../Tests/Service/SmsSecondFactor/OtpTest.php | 106 ------- .../SmsVerificationStateTest.php | 288 ------------------ 23 files changed, 63 insertions(+), 1471 deletions(-) delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsCommand.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/DateTime/DateTime.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/Configuration.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/Exception/TooManyChallengesRequestedException.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/Otp.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/OtpVerification.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SessionSmsVerificationStateHandler.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationState.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationStateHandler.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsService.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/DateTimeHelper.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/OtpTest.php delete mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/SmsVerificationStateTest.php diff --git a/app/config/config.yml b/app/config/config.yml index 26369b79f..8b547f4ea 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -89,17 +89,6 @@ monolog: publisher: { hostname: %graylog_hostname% } formatter: surfnet_stepup.monolog.full_message_exception_gelf_message_formatter -surfnet_stepup_self_service_self_service: - sms: - originator: %sms_originator% - otp_expiry_interval: %sms_otp_expiry_interval% - maximum_otp_requests: %sms_maximum_otp_requests% - gateway_api: - url: %gateway_api_url% - credentials: - username: %gateway_api_username% - password: %gateway_api_password% - mopa_bootstrap: form: show_legend: false @@ -145,6 +134,15 @@ surfnet_stepup: loa1: %stepup_loa_loa1% loa2: %stepup_loa_loa2% loa3: %stepup_loa_loa3% + sms: + originator: %sms_originator% + otp_expiry_interval: %sms_otp_expiry_interval% + maximum_otp_requests: %sms_maximum_otp_requests% + gateway_api: + url: %gateway_api_url% + credentials: + username: %gateway_api_username% + password: %gateway_api_password% jms_translation: locales: %locales% diff --git a/composer.json b/composer.json index f13355ca6..fbd337454 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-develop", + "surfnet/stepup-bundle": "dev-maintenance/sms-verification", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 09634e60a..4861e1234 100644 --- a/composer.lock +++ b/composer.lock @@ -1,10 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "47e88ab167ef626f6d5a065f5bbe3386", + "hash": "87de26c67c058c2058f8ada4bbdb78ee", "packages": [ { "name": "beberlei/assert", @@ -1148,12 +1148,12 @@ "version": "1.1.0", "source": { "type": "git", - "url": "https://github.com/moontoast/math.git", + "url": "https://github.com/ramsey/moontoast-math.git", "reference": "fce28a9d1e73e73376cb44e5e581675d15fbe2f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/moontoast/math/zipball/fce28a9d1e73e73376cb44e5e581675d15fbe2f3", + "url": "https://api.github.com/repos/ramsey/moontoast-math/zipball/fce28a9d1e73e73376cb44e5e581675d15fbe2f3", "reference": "fce28a9d1e73e73376cb44e5e581675d15fbe2f3", "shasum": "" }, @@ -1190,7 +1190,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/818b0f47ebd352559950e9a64431ff9472e8a9dd", + "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/a5573423b7d029d65bf85e3eba336d5d85d695f1", "reference": "818b0f47ebd352559950e9a64431ff9472e8a9dd", "shasum": "" }, @@ -1650,7 +1650,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/saml2/zipball/fb22b707c7a4705d2d54401715c8f6d229e88a74", + "url": "https://api.github.com/repos/SURFnet/saml2/zipball/b2d96e911d8e9348edd75bcd980f60a251fa5c28", "reference": "fb22b707c7a4705d2d54401715c8f6d229e88a74", "shasum": "" }, @@ -1750,16 +1750,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-develop", + "version": "dev-maintenance/sms-verification", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "cae60583cbb8907f5f2fa4730091765c59a4204a" + "reference": "246dd36743fc263762f7c53ec0e9f986693baa5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/cae60583cbb8907f5f2fa4730091765c59a4204a", - "reference": "cae60583cbb8907f5f2fa4730091765c59a4204a", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/246dd36743fc263762f7c53ec0e9f986693baa5f", + "reference": "246dd36743fc263762f7c53ec0e9f986693baa5f", "shasum": "" }, "require": { @@ -1796,7 +1796,7 @@ "suaas", "surfnet" ], - "time": "2015-04-02 12:24:11" + "time": "2015-05-22 11:47:24" }, { "name": "surfnet/stepup-middleware-client-bundle", @@ -1808,7 +1808,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/c9c64643062c16452d9e3075850eee8436a82ec5", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/4eafa9f46ec0e79acd0104b49e316bbbb6c128ba", "reference": "c9c64643062c16452d9e3075850eee8436a82ec5", "shasum": "" }, @@ -1857,7 +1857,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/4f4d4d9d04b3d9b1e322ad4cc6579336ba932ed3", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/34db9134005e4e6ce42662f5d58a9d681e3c1968", "reference": "4f4d4d9d04b3d9b1e322ad4cc6579336ba932ed3", "shasum": "" }, @@ -2351,12 +2351,12 @@ "version": "v1.16.2", "source": { "type": "git", - "url": "https://github.com/fabpot/Twig.git", + "url": "https://github.com/twigphp/Twig.git", "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", "shasum": "" }, @@ -2533,12 +2533,12 @@ "version": "v1.6.0", "source": { "type": "git", - "url": "https://github.com/Behat/Mink.git", + "url": "https://github.com/minkphp/Mink.git", "reference": "090900a0049c441f1e072bbd837db4079b2250c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/Mink/zipball/090900a0049c441f1e072bbd837db4079b2250c5", + "url": "https://api.github.com/repos/minkphp/Mink/zipball/090900a0049c441f1e072bbd837db4079b2250c5", "reference": "090900a0049c441f1e072bbd837db4079b2250c5", "shasum": "" }, @@ -2588,12 +2588,12 @@ "version": "v1.2.0", "source": { "type": "git", - "url": "https://github.com/Behat/MinkBrowserKitDriver.git", + "url": "https://github.com/minkphp/MinkBrowserKitDriver.git", "reference": "aed8f4a596b79014a75254c3e337511c33e38cbd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/MinkBrowserKitDriver/zipball/aed8f4a596b79014a75254c3e337511c33e38cbd", + "url": "https://api.github.com/repos/minkphp/MinkBrowserKitDriver/zipball/aed8f4a596b79014a75254c3e337511c33e38cbd", "reference": "aed8f4a596b79014a75254c3e337511c33e38cbd", "shasum": "" }, @@ -2694,12 +2694,12 @@ "version": "v1.1.0", "source": { "type": "git", - "url": "https://github.com/Behat/MinkGoutteDriver.git", + "url": "https://github.com/minkphp/MinkGoutteDriver.git", "reference": "2bf327b4166694ecaa8ae7f956cb6ae252ecf03e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/MinkGoutteDriver/zipball/2bf327b4166694ecaa8ae7f956cb6ae252ecf03e", + "url": "https://api.github.com/repos/minkphp/MinkGoutteDriver/zipball/2bf327b4166694ecaa8ae7f956cb6ae252ecf03e", "reference": "2bf327b4166694ecaa8ae7f956cb6ae252ecf03e", "shasum": "" }, @@ -2746,12 +2746,12 @@ "version": "v1.2.0", "source": { "type": "git", - "url": "https://github.com/Behat/MinkSelenium2Driver.git", + "url": "https://github.com/minkphp/MinkSelenium2Driver.git", "reference": "8018fee80bf6573f909ece3e0dfc07d0eb352210" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Behat/MinkSelenium2Driver/zipball/8018fee80bf6573f909ece3e0dfc07d0eb352210", + "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/8018fee80bf6573f909ece3e0dfc07d0eb352210", "reference": "8018fee80bf6573f909ece3e0dfc07d0eb352210", "shasum": "" }, @@ -2899,12 +2899,12 @@ "version": "v2.0.2", "source": { "type": "git", - "url": "https://github.com/fabpot/Goutte.git", + "url": "https://github.com/FriendsOfPHP/Goutte.git", "reference": "b12c3f7ec68d8814b50444cfe142fd0a056557f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Goutte/zipball/b12c3f7ec68d8814b50444cfe142fd0a056557f9", + "url": "https://api.github.com/repos/FriendsOfPHP/Goutte/zipball/b12c3f7ec68d8814b50444cfe142fd0a056557f9", "reference": "b12c3f7ec68d8814b50444cfe142fd0a056557f9", "shasum": "" }, diff --git a/src/Surfnet/StepupSelfService/SamlStepupProviderBundle/DependencyInjection/SurfnetStepupSelfServiceSamlStepupProviderExtension.php b/src/Surfnet/StepupSelfService/SamlStepupProviderBundle/DependencyInjection/SurfnetStepupSelfServiceSamlStepupProviderExtension.php index 461f76c9c..a66bfafef 100644 --- a/src/Surfnet/StepupSelfService/SamlStepupProviderBundle/DependencyInjection/SurfnetStepupSelfServiceSamlStepupProviderExtension.php +++ b/src/Surfnet/StepupSelfService/SamlStepupProviderBundle/DependencyInjection/SurfnetStepupSelfServiceSamlStepupProviderExtension.php @@ -19,12 +19,12 @@ namespace Surfnet\StepupSelfService\SamlStepupProviderBundle\DependencyInjection; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; -use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\DependencyInjection\Loader; class SurfnetStepupSelfServiceSamlStepupProviderExtension extends Extension { diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/RevokeCommand.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/RevokeCommand.php index d4cec0f23..aeefddd80 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/RevokeCommand.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/RevokeCommand.php @@ -18,7 +18,6 @@ namespace Surfnet\StepupSelfService\SelfServiceBundle\Command; -use Surfnet\StepupMiddlewareClientBundle\Command\AbstractCommand; use Symfony\Component\Validator\Constraints as Assert; class RevokeCommand diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsCommand.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsCommand.php deleted file mode 100644 index 92e95ffde..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsCommand.php +++ /dev/null @@ -1,59 +0,0 @@ -root('surfnet_stepup_self_service_self_service'); - - $this->createGatewayApiConfiguration($rootNode); - $this->createSmsConfiguration($rootNode); - - return $treeBuilder; - } - - private function createGatewayApiConfiguration(ArrayNodeDefinition $root) - { - $root - ->children() - ->arrayNode('gateway_api') - ->info('Gateway API configuration') - ->children() - ->arrayNode('credentials') - ->info('Basic authentication credentials') - ->children() - ->scalarNode('username') - ->info('Username for the Gateway API') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return (!is_string($value) || empty($value)); - }) - ->thenInvalid( - 'Invalid Gateway API username specified: "%s". Must be non-empty string' - ) - ->end() - ->end() - ->scalarNode('password') - ->info('Password for the Gateway API') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return (!is_string($value) || empty($value)); - }) - ->thenInvalid( - 'Invalid Gateway API password specified: "%s". Must be non-empty string' - ) - ->end() - ->end() - ->end() - ->end() - ->scalarNode('url') - ->info('The URL to the Gateway application (e.g. https://gateway.tld)') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return (!is_string($value) || empty($value) || !preg_match('~/$~', $value)); - }) - ->thenInvalid( - 'Invalid Gateway URL specified: "%s". Must be string ending in forward slash' - ) - ->end() - ->end() - ->end() - ->end() - ->end(); - } - - private function createSmsConfiguration(ArrayNodeDefinition $root) - { - $root - ->children() - ->arrayNode('sms') - ->info('SMS configuration') - ->isRequired() - ->children() - ->scalarNode('originator') - ->info('Originator (sender) for SMS messages') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return (!is_string($value) || !preg_match('~^[a-z0-9]{1,11}$~i', $value)); - }) - ->thenInvalid( - 'Invalid SMS originator specified: "%s". Must be a string matching ' - . '"~^[a-z0-9]{1,11}$~i".' - ) - ->end() - ->end() - ->integerNode('otp_expiry_interval') - ->info('After how many seconds an SMS challenge OTP expires') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return $value <= 0; - }) - ->thenInvalid( - 'Invalid SMS challenge OTP expiry, must be one or more seconds.' - ) - ->end() - ->end() - ->integerNode('maximum_otp_requests') - ->info('How many challenges a user may request during a session') - ->isRequired() - ->validate() - ->ifTrue(function ($value) { - return $value <= 0; - }) - ->thenInvalid( - 'Maximum OTP requests has a minimum of 1' - ) - ->end() - ->end() - ->end() - ->end() - ->end(); - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php index f22f44ff6..3b5c800e4 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php @@ -35,36 +35,7 @@ class SurfnetStepupSelfServiceSelfServiceExtension extends Extension */ public function load(array $configs, ContainerBuilder $container) { - $configuration = new Configuration(); - $config = $this->processConfiguration($configuration, $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); - - $gatewayGuzzleOptions = [ - 'base_url' => $config['gateway_api']['url'], - 'defaults' => [ - 'auth' => [ - $config['gateway_api']['credentials']['username'], - $config['gateway_api']['credentials']['password'], - 'basic' - ], - 'headers' => [ - 'Accept' => 'application/json' - ] - ] - ]; - - $gatewayGuzzle = $container->getDefinition('surfnet_stepup_self_service_self_service.guzzle.gateway_api'); - $gatewayGuzzle->replaceArgument(0, $gatewayGuzzleOptions); - - $smsSecondFactorService = - $container->getDefinition('surfnet_stepup_self_service_self_service.service.sms_second_factor'); - $smsSecondFactorService->replaceArgument(4, $config['sms']['originator']); - - $container - ->getDefinition('surfnet_stepup_self_service_self_service.challenge_handler') - ->replaceArgument(2, $config['sms']['otp_expiry_interval']) - ->replaceArgument(3, $config['sms']['maximum_otp_requests']); } } diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml index fa8539241..9e6c025e8 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml @@ -47,22 +47,9 @@ services: public: false class: Surfnet\StepupSelfService\SelfServiceBundle\Service\YubikeyService arguments: - - @surfnet_stepup_self_service_self_service.guzzle.gateway_api + - @surfnet_stepup.guzzle.gateway_api - @logger - surfnet_stepup_self_service_self_service.service.sms: - public: false - class: Surfnet\StepupSelfService\SelfServiceBundle\Service\SmsService - arguments: - - @surfnet_stepup_self_service_self_service.guzzle.gateway_api - - @logger - - surfnet_stepup_self_service_self_service.guzzle.gateway_api: - public: false - class: GuzzleHttp\Client - arguments: - - {} # Set from the extension - surfnet_stepup_self_service_self_service.service.yubikey_second_factor: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\YubikeySecondFactorService arguments: @@ -72,26 +59,15 @@ services: surfnet_stepup_self_service_self_service.service.sms_second_factor: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\SmsSecondFactorService arguments: - - @surfnet_stepup_self_service_self_service.service.sms - - @surfnet_stepup_self_service_self_service.challenge_handler + - @surfnet_stepup.service.sms_second_factor - @translator - @surfnet_stepup_self_service_self_service.service.command - - '' # Originator set in extension surfnet_stepup_self_service_self_service.service.gssf: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\GssfService arguments: - @surfnet_stepup_self_service_self_service.service.command - surfnet_stepup_self_service_self_service.challenge_handler: - public: false - class: Surfnet\StepupSelfService\SelfServiceBundle\Service\SmsSecondFactor\SessionSmsVerificationStateHandler - arguments: - - @session - - 'Surfnet/SelfService/SecondFactor/Sms:challenge' - - {} # OTP expiry interval - - 0 # Maximum OTP requests - self_service.service.identity: class: Surfnet\StepupSelfService\SelfServiceBundle\Service\IdentityService arguments: diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/SessionHandler.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/SessionHandler.php index 98d3bde19..727a24113 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/SessionHandler.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/SessionHandler.php @@ -19,7 +19,6 @@ namespace Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication; use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; class SessionHandler { diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/Exception/TooManyChallengesRequestedException.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/Exception/TooManyChallengesRequestedException.php deleted file mode 100644 index d7865ce2c..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/Exception/TooManyChallengesRequestedException.php +++ /dev/null @@ -1,25 +0,0 @@ -otp = $otpString; - $otp->phoneNumber = $phoneNumber; - $otp->expiryInterval = $expiryInterval; - $otp->issuedAt = DateTime::now(); - - return $otp; - } - - private function __construct() - { - } - - public function verify($userOtp) - { - if (!is_string($userOtp)) { - throw InvalidArgumentException::invalidType('string', 'userOtp', $userOtp); - } - - if (strtoupper($userOtp) !== strtoupper($this->otp)) { - return OtpVerification::noMatch(); - } - - $expiryTime = clone $this->issuedAt; - $expiryTime->add($this->expiryInterval); - - if ($expiryTime <= DateTime::now()) { - return OtpVerification::matchExpired(); - } - - return OtpVerification::foundMatch($this->phoneNumber); - } - - /** - * @param string $phoneNumber - * @return bool - */ - public function hasPhoneNumber($phoneNumber) - { - return $this->phoneNumber === $phoneNumber; - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/OtpVerification.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/OtpVerification.php deleted file mode 100644 index e10ca2427..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/OtpVerification.php +++ /dev/null @@ -1,106 +0,0 @@ -status = $status; - $this->phoneNumber = $phoneNumber; - } - - /** - * @return bool - */ - public function wasSuccessful() - { - return $this->status === self::STATUS_FOUND_MATCH; - } - - /** - * @return bool - */ - public function didOtpMatch() - { - return $this->status === self::STATUS_FOUND_MATCH || $this->status === self::STATUS_MATCH_EXPIRED; - } - /** - * @return bool - */ - public function didOtpExpire() - { - return $this->status === self::STATUS_MATCH_EXPIRED; - } - - /** - * @return bool - */ - public function wasAttemptedTooManyTimes() - { - return $this->status === self::STATUS_TOO_MANY_ATTEMPTS; - } - - /** - * @return null|string Only guaranteed to be a string when status is successful. - */ - public function getPhoneNumber() - { - return $this->phoneNumber; - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SessionSmsVerificationStateHandler.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SessionSmsVerificationStateHandler.php deleted file mode 100644 index 227687f62..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SessionSmsVerificationStateHandler.php +++ /dev/null @@ -1,117 +0,0 @@ -session = $session; - $this->sessionKey = $sessionKey; - $this->otpExpiryInterval = new DateInterval(sprintf('PT%dS', $otpExpiryInterval)); - $this->otpRequestMaximum = $otpRequestMaximum; - } - - public function hasState() - { - return $this->session->has($this->sessionKey); - } - - public function clearState() - { - $this->session->remove($this->sessionKey); - } - - public function requestNewOtp($phoneNumber) - { - /** @var SmsVerificationState|null $state */ - $state = $this->session->get($this->sessionKey); - - if (!$state) { - $state = new SmsVerificationState($this->otpExpiryInterval, $this->otpRequestMaximum); - $this->session->set($this->sessionKey, $state); - } - - return $state->requestNewOtp($phoneNumber); - } - - public function getOtpRequestsRemainingCount() - { - /** @var SmsVerificationState|null $state */ - $state = $this->session->get($this->sessionKey); - - return $state ? $state->getOtpRequestsRemainingCount() : $this->otpRequestMaximum; - } - - public function getMaximumOtpRequestsCount() - { - return $this->otpRequestMaximum; - } - - public function verify($otp) - { - /** @var SmsVerificationState|null $state */ - $state = $this->session->get($this->sessionKey); - - if (!$state) { - return OtpVerification::matchExpired(); - } - - $verification = $state->verify($otp); - - if ($verification->wasSuccessful()) { - $this->session->remove($this->sessionKey); - } - - return $verification; - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationState.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationState.php deleted file mode 100644 index 9f9d36440..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationState.php +++ /dev/null @@ -1,133 +0,0 @@ -expiryInterval = $expiryInterval; - $this->maximumOtpRequests= $maximumOtpRequests; - $this->otps = []; - $this->verificationAttemptsMade = 0; - } - - /** - * @param string $phoneNumber - * @return string The generated OTP string. - */ - public function requestNewOtp($phoneNumber) - { - if (!is_string($phoneNumber) || empty($phoneNumber)) { - throw InvalidArgumentException::invalidType('string', 'phoneNumber', $phoneNumber); - } - - if (count($this->otps) >= $this->maximumOtpRequests) { - throw new TooManyChallengesRequestedException( - sprintf( - '%d OTPs were requested, while only %d requests are allowed', - count($this->otps) + 1, - $this->maximumOtpRequests - ) - ); - } - - $this->otps = array_filter($this->otps, function (Otp $otp) use ($phoneNumber) { - return $otp->hasPhoneNumber($phoneNumber); - }); - - $otp = OtpGenerator::generate(8); - $this->otps[] = Otp::create($otp, $phoneNumber, $this->expiryInterval); - - return $otp; - } - - /** - * @param string $userOtp - * @return OtpVerification - */ - public function verify($userOtp) - { - if ($this->verificationAttemptsMade >= self::MAXIMUM_VERIFICATION_ATTEMPTS) { - return OtpVerification::tooManyAttempts(); - } - - $this->verificationAttemptsMade++; - - if (!is_string($userOtp)) { - throw InvalidArgumentException::invalidType('string', 'userOtp', $userOtp); - } - - foreach ($this->otps as $otp) { - $verification = $otp->verify($userOtp); - - if ($verification->didOtpMatch()) { - return $verification; - } - } - - return OtpVerification::noMatch(); - } - - /** - * @return int - */ - public function getOtpRequestsRemainingCount() - { - return $this->maximumOtpRequests - count($this->otps); - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationStateHandler.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationStateHandler.php deleted file mode 100644 index fb199485d..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactor/SmsVerificationStateHandler.php +++ /dev/null @@ -1,62 +0,0 @@ -smsService = $smsService; - $this->smsVerificationStateHandler = $smsVerificationStateHandler; + $this->smsSecondFactorService = $smsSecondFactorService; $this->translator = $translator; $this->commandService = $commandService; - $this->originator = $originator; } /** @@ -98,7 +69,7 @@ public function __construct( */ public function getOtpRequestsRemainingCount() { - return $this->smsVerificationStateHandler->getOtpRequestsRemainingCount(); + return $this->smsSecondFactorService->getOtpRequestsRemainingCount(); } /** @@ -106,7 +77,7 @@ public function getOtpRequestsRemainingCount() */ public function getMaximumOtpRequestsCount() { - return $this->smsVerificationStateHandler->getMaximumOtpRequestsCount(); + return $this->smsSecondFactorService->getMaximumOtpRequestsCount(); } /** @@ -114,12 +85,12 @@ public function getMaximumOtpRequestsCount() */ public function hasSmsVerificationState() { - return $this->smsVerificationStateHandler->hasState(); + return $this->smsSecondFactorService->hasSmsVerificationState(); } public function clearSmsVerificationState() { - $this->smsVerificationStateHandler->clearState(); + $this->smsSecondFactorService->clearSmsVerificationState(); } /** @@ -133,18 +104,14 @@ public function sendChallenge(SendSmsChallengeCommand $command) new CountryCode($command->countryCode), new PhoneNumber($command->subscriber) ); - $otp = $this->smsVerificationStateHandler->requestNewOtp((string) $phoneNumber); - - $body = $this->translator->trans('ss.registration.sms.challenge_body', ['%challenge%' => $otp]); - $smsCommand = new SendSmsCommand(); - $smsCommand->recipient = $phoneNumber->toMSISDN(); - $smsCommand->originator = $this->originator; - $smsCommand->body = $body; - $smsCommand->identity = $command->identity; - $smsCommand->institution = $command->institution; + $stepupCommand = new StepupSendSmsChallengeCommand(); + $stepupCommand->phoneNumber = $phoneNumber; + $stepupCommand->body = $this->translator->trans('ss.registration.sms.challenge_body'); + $stepupCommand->identity = $command->identity; + $stepupCommand->institution = $command->institution; - return $this->smsService->sendSms($smsCommand); + return $this->smsSecondFactorService->sendChallenge($stepupCommand); } /** @@ -153,7 +120,10 @@ public function sendChallenge(SendSmsChallengeCommand $command) */ public function provePossession(VerifySmsChallengeCommand $challengeCommand) { - $verification = $this->smsVerificationStateHandler->verify($challengeCommand->challenge); + $stepupCommand = new VerifyPossessionOfPhoneCommand(); + $stepupCommand->challenge = $challengeCommand->challenge; + + $verification = $this->smsSecondFactorService->verifyPossession($stepupCommand); if ($verification->didOtpExpire()) { return ProofOfPossessionResult::challengeExpired(); diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsService.php deleted file mode 100644 index a64ad10ed..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsService.php +++ /dev/null @@ -1,97 +0,0 @@ -guzzleClient = $guzzleClient; - $this->logger = $logger; - } - - /** - * @param SendSmsCommand $command - * @return bool - */ - public function sendSms(SendSmsCommand $command) - { - $this->logger->info('Sending SMS'); - - $body = [ - 'requester' => ['institution' => $command->institution, 'identity' => $command->identity], - 'message' => [ - 'originator' => $command->originator, - 'recipient' => $command->recipient, - 'body' => $command->body - ], - ]; - $response = $this->guzzleClient->post('api/send-sms', ['json' => $body, 'exceptions' => false]); - $statusCode = $response->getStatusCode(); - - if ($statusCode != 200) { - $this->logger->error( - sprintf('SMS sending failed, error: [%s] %s', $response->getStatusCode(), $response->getReasonPhrase()), - ['http-body' => $response->getBody() ? $response->getBody()->getContents() : '',] - ); - - return false; - } - - try { - $result = $response->json(); - } catch (\RuntimeException $e) { - $this->logger->error('SMS sending failed; server responded with malformed JSON.'); - - return false; - } - - if (!isset($result['status'])) { - $this->logger->error('SMS sending failed; server responded without status report.'); - - return false; - } - - if ($result['status'] !== 'OK') { - $this->logger->error('SMS sending failed; server responded with non-OK status report.'); - - return false; - } - - return true; - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/DateTimeHelper.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/DateTimeHelper.php deleted file mode 100644 index 1d3828b1a..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/DateTimeHelper.php +++ /dev/null @@ -1,37 +0,0 @@ -setAccessible(true); - $nowProperty->setValue($now); - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/OtpTest.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/OtpTest.php deleted file mode 100644 index 950a9d9ee..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/OtpTest.php +++ /dev/null @@ -1,106 +0,0 @@ - [array()], - 'integer' => [1], - 'object' => [new \stdClass()], - 'null' => [null], - 'bool' => [false], - 'resource' => [fopen('php://memory', 'w')], - ]; - } - - public function non_non_empty_strings() - { - return [ - 'empty string' => [''], - 'array' => [array()], - 'integer' => [1], - 'object' => [new \stdClass()], - 'null' => [null], - 'bool' => [false], - 'resource' => [fopen('php://memory', 'w')], - ]; - } - - /** - * @test - * @group sms - */ - public function can_be_created() - { - Otp::create('ABCDEFG', '123', new DateInterval('PT5M')); - } - - /** - * @test - * @group sms - * @dataProvider non_non_empty_strings - * @param mixed $nonString - */ - public function only_accepts_string_otps($nonString) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'otpString' - ); - Otp::create($nonString, '123', new DateInterval('PT5M')); - } - - /** - * @test - * @group sms - * @dataProvider non_non_empty_strings - * @param mixed $nonString - */ - public function only_accepts_string_phone_numbers($nonString) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'phoneNumber' - ); - Otp::create('ABCDEFG', $nonString, new DateInterval('PT5M')); - } - - /** - * @test - * @group sms - * @dataProvider non_strings - * @param mixed $nonString - */ - public function it_verifies_only_string_otps($nonString) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'otpString' - ); - $otp = Otp::create($nonString, '123', new DateInterval('PT5M')); - $otp->verify($nonString); - } -} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/SmsVerificationStateTest.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/SmsVerificationStateTest.php deleted file mode 100644 index bdb0d58ac..000000000 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Service/SmsSecondFactor/SmsVerificationStateTest.php +++ /dev/null @@ -1,288 +0,0 @@ - [array()], - 'integer' => [1], - 'object' => [new \stdClass()], - 'null' => [null], - 'bool' => [false], - 'resource' => [fopen('php://memory', 'w')], - ]; - } - - public function non_non_empty_strings() - { - return [ - 'empty string' => [''], - 'array' => [array()], - 'integer' => [1], - 'object' => [new \stdClass()], - 'null' => [null], - 'bool' => [false], - 'resource' => [fopen('php://memory', 'w')], - ]; - } - - /** - * @test - * @group sms - */ - public function it_can_be_matched() - { - $state = new SmsVerificationState(new DateInterval('PT15M'), 3); - $otp = $state->requestNewOtp('123'); - - $this->assertTrue($state->verify($otp)->wasSuccessful(), 'OTP should have matched'); - } - - /** - * @test - * @group sms - * @dataProvider non_non_empty_strings - * @param mixed $nonString - */ - public function it_accepts_only_string_phone_numbers($nonString) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'phoneNumber' - ); - $state = new SmsVerificationState(new DateInterval('PT15M'), 3); - $state->requestNewOtp($nonString); - } - - /** - * @test - * @group sms - * @dataProvider non_strings - * @param mixed $nonString - */ - public function it_verifies_only_string_otps($nonString) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'userOtp' - ); - $state = new SmsVerificationState(new DateInterval('PT15M'), 3); - $state->requestNewOtp('123'); - $state->verify($nonString); - } - - /** - * @test - * @group sms - */ - public function it_can_expire() - { - DateTimeHelper::setCurrentTime(new DateTime('@0')); - $state = new SmsVerificationState(new DateInterval('PT1S'), 3); - $otp = $state->requestNewOtp('123'); - - DateTimeHelper::setCurrentTime(new DateTime('@1')); - $verification = $state->verify($otp); - - $this->assertFalse($verification->wasSuccessful(), "Verification shouldn't be successful"); - $this->assertTrue($verification->didOtpExpire(), 'OTP should have expired'); - $this->assertTrue($verification->didOtpMatch(), 'OTP should have matched'); - } - - /** - * @test - * @group sms - */ - public function the_expiration_time_is_pushed_back_with_each_new_otp() - { - // Set a challenge - DateTimeHelper::setCurrentTime(new DateTime('@0')); - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - $otp = $state->requestNewOtp('123'); - - // Try after 3 seconds - DateTimeHelper::setCurrentTime(new DateTime('@3')); - $this->assertTrue($state->verify($otp)->wasSuccessful(), "OTP should've matched"); - - // Set a new challenge - $otp = $state->requestNewOtp('123'); - - // Try after 4 seconds (total of 7 seconds, longer than 5-second expiry interval) - DateTimeHelper::setCurrentTime(new DateTime('@7')); - $this->assertTrue($state->verify($otp)->wasSuccessful(), "OTP should've matched"); - } - - /** - * @test - * @group sms - */ - public function the_consumer_can_request_too_many_otps_but_can_keep_track_of_remaining_requests() - { - $state = new SmsVerificationState(new DateInterval('PT10S'), 3); - $this->assertSame(3, $state->getOtpRequestsRemainingCount()); - - $state->requestNewOtp('123'); - $this->assertSame(2, $state->getOtpRequestsRemainingCount()); - - $state->requestNewOtp('123'); - $this->assertSame(1, $state->getOtpRequestsRemainingCount()); - - $state->requestNewOtp('123'); - $this->assertSame(0, $state->getOtpRequestsRemainingCount()); - $this->assertSame(0, $state->getOtpRequestsRemainingCount()); - - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Service\Exception\TooManyChallengesRequestedException' - ); - $state->requestNewOtp('123'); - $this->assertSame(0, $state->getOtpRequestsRemainingCount()); - } - - public function lteZeroMaximumTries() - { - return [[0], [-1], [-1000]]; - } - - /** - * @test - * @group sms - * @dataProvider lteZeroMaximumTries - * @param int $maximumTries - */ - public function maximum_challenges_must_be_gte_1($maximumTries) - { - $this->setExpectedException( - 'Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException', - 'maximum OTP requests' - ); - - new SmsVerificationState(new DateInterval('PT15M'), $maximumTries); - } - - /** - * @test - * @group sms - */ - public function a_previous_otp_can_be_matched() - { - DateTimeHelper::setCurrentTime(new DateTime('@0')); - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - $otp1 = $state->requestNewOtp('123'); - $otp2 = $state->requestNewOtp('123'); - - $this->assertTrue($state->verify($otp1)->wasSuccessful(), "OTP should've matched"); - $this->assertTrue($state->verify($otp2)->wasSuccessful(), "OTP should've matched"); - } - - /** - * @test - * @group sms - */ - public function otp_matching_is_case_insensitive() - { - DateTimeHelper::setCurrentTime(new DateTime('@0')); - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - $otp = $state->requestNewOtp('123'); - - $this->assertTrue($state->verify(strtolower($otp))->wasSuccessful(), "OTP should've matched"); - $this->assertTrue($state->verify(strtoupper($otp))->wasSuccessful(), "OTP should've matched"); - } - - /** - * @test - * @group sms - */ - public function no_more_than_10_attempts_can_be_made_overall() - { - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - $state->requestNewOtp('237894'); - - for ($i = 0; $i < SmsVerificationState::MAXIMUM_VERIFICATION_ATTEMPTS; $i++) { - $this->assertFalse($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts not yet achieved'); - } - - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - } - - /** - * @test - * @group sms - */ - public function no_more_than_10_attempts_can_be_made_overall_even_when_multiple_otps_requested() - { - $state = new SmsVerificationState(new DateInterval('PT5S'), 99999); - $state->requestNewOtp('237894'); - - for ($i = 0; $i < SmsVerificationState::MAXIMUM_VERIFICATION_ATTEMPTS; $i++) { - $this->assertFalse($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts not yet achieved'); - $state->requestNewOtp('38942'); - } - - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - } - - /** - * @test - * @group sms - */ - public function no_more_than_10_attempts_can_be_made_overall_even_when_no_otp_requested() - { - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - - for ($i = 0; $i < SmsVerificationState::MAXIMUM_VERIFICATION_ATTEMPTS; $i++) { - $this->assertFalse($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts not yet achieved'); - } - - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - $this->assertTrue($state->verify('3')->wasAttemptedTooManyTimes(), 'Failed to assert maximum attempts achieved'); - } - - /** - * @test - * @group sms - */ - public function requesting_an_otp_with_a_different_phone_number_clears_otps_for_other_phone_numbers() - { - $state = new SmsVerificationState(new DateInterval('PT5S'), 3); - - $otpForPhone1 = $state->requestNewOtp('1'); - $otpForPhone2 = $state->requestNewOtp('2'); - - $verificationForPhone1 = $state->verify($otpForPhone1); - $this->assertFalse($verificationForPhone1->wasSuccessful(), 'Verification for phone 1 should not be successful'); - - $verificationForPhone2 = $state->verify($otpForPhone2); - $this->assertTrue($verificationForPhone2->wasSuccessful(), 'Verification for phone 2 should be successful'); - $this->assertSame('2', $verificationForPhone2->getPhoneNumber(), 'Verification for phone 2 should return phone 2'); - } -} From 0b98d53fcce06886fb281ec5633a0dc324a98ddc Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Fri, 22 May 2015 15:59:17 +0200 Subject: [PATCH 02/36] Reduce some coupling, but suppress warnings for commands and VOs. --- .../SelfServiceBundle/Service/SmsSecondFactorService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php index c1a70402d..a85f0c297 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php @@ -32,6 +32,9 @@ use Surfnet\StepupSelfService\SelfServiceBundle\Service\SmsSecondFactor\ProofOfPossessionResult; use Symfony\Component\Translation\TranslatorInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - Quite some commands and VOs are used here. + */ class SmsSecondFactorService { /** @@ -40,12 +43,12 @@ class SmsSecondFactorService private $smsSecondFactorService; /** - * @var TranslatorInterface + * @var \Symfony\Component\Translation\TranslatorInterface */ private $translator; /** - * @var CommandService + * @var \Surfnet\StepupSelfService\SelfServiceBundle\Service\CommandService */ private $commandService; From fded89d0e6bee65fc9813979abb4624fad6d9525 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Mon, 1 Jun 2015 16:18:17 +0200 Subject: [PATCH 03/36] Allow the authenticated identity to switch locales persistently --- .../translations/messages.en_GB.xliff | 30 +++++++ .../translations/messages.nl_NL.xliff | 30 +++++++ app/Resources/views/base.html.twig | 6 ++ composer.json | 4 +- composer.lock | 26 ++++--- .../Controller/LocaleController.php | 77 ++++++++++++++++++ .../EventListener/LocaleListener.php | 78 +++++++++++++++++++ .../Resources/config/routing.yml | 7 ++ .../Resources/config/services.yml | 7 ++ .../Resources/public/less/style.less | 7 ++ .../Service/IdentityService.php | 41 ++++++++++ 11 files changed, 299 insertions(+), 14 deletions(-) create mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php create mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/EventListener/LocaleListener.php diff --git a/app/Resources/translations/messages.en_GB.xliff b/app/Resources/translations/messages.en_GB.xliff index 1307c30e1..bf02f492b 100644 --- a/app/Resources/translations/messages.en_GB.xliff +++ b/app/Resources/translations/messages.en_GB.xliff @@ -17,6 +17,21 @@ button.logout Sign out + + Form/Type/SendSmsChallengeType.php + country code + country code + + + Resources/views/translations.twig + locale.en_GB + English + + + Resources/views/translations.twig + locale.nl_NL + Nederlands + views/Exception/error.html.twig views/Exception/error404.html.twig @@ -84,6 +99,16 @@ ss.error.title Error + + SelfServiceBundle/Controller/LocaleControl.php + ss.flash.error_while_switching_locale + Due to an unknown reason, switching locales failed. + + + SelfServiceBundle/Controller/LocaleControl.php + ss.flash.invalid_switch_locale_form + Due to an unknown reason, switching locales failed. + Form/Type/RevokeSecondFactorType.php ss.form.ss_revoke_second_factor.cancel @@ -472,6 +497,11 @@ An e-mail with your activation code has been sent to the e-mail address %email%. ss.second_factor_list.header.type Token + + Form/Type/SwitchLocaleType.php + stepup_middleware_client.form.switch_locale.switch + Switch + diff --git a/app/Resources/translations/messages.nl_NL.xliff b/app/Resources/translations/messages.nl_NL.xliff index 35795da53..f12e643ba 100644 --- a/app/Resources/translations/messages.nl_NL.xliff +++ b/app/Resources/translations/messages.nl_NL.xliff @@ -17,6 +17,21 @@ button.logout Uitloggen + + Form/Type/SendSmsChallengeType.php + country code + country code + + + Resources/views/translations.twig + locale.en_GB + English + + + Resources/views/translations.twig + locale.nl_NL + Nederlands + views/Exception/error.html.twig views/Exception/error404.html.twig @@ -84,6 +99,16 @@ ss.error.title Foutmelding + + SelfServiceBundle/Controller/LocaleControl.php + ss.flash.error_while_switching_locale + Due to an unknown reason, switching locales failed. + + + SelfServiceBundle/Controller/LocaleControl.php + ss.flash.invalid_switch_locale_form + Due to an unknown reason, switching locales failed. + Form/Type/RevokeSecondFactorType.php ss.form.ss_revoke_second_factor.cancel @@ -471,6 +496,11 @@ Er is een e-mail met activatiecode gestuurd naar het e-mailadres %email%. Volg d ss.second_factor_list.header.type Token + + Form/Type/SwitchLocaleType.php + stepup_middleware_client.form.switch_locale.switch + Vertalen + diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index bdb173d72..dff5b13d7 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -8,6 +8,7 @@ {% block head_style %} {% stylesheets filter='less' '@SurfnetStepupSelfServiceSelfServiceBundle/Resources/public/less/style.less' + '@SurfnetStepupBundle/Resources/public/less/stepup.less' %} {% endstylesheets %} @@ -32,6 +33,11 @@ {{ 'button.logout'|trans }} + {% set locale_switcher = stepup_locale_switcher('ss_switch_locale', {'return-url': app.request.uri}) %} + {{ form_start(locale_switcher, { attr: { class: 'form-inline' }}) }} + {{ form_widget(locale_switcher.locale) }} + {{ form_widget(locale_switcher.switch) }} + {{ form_end(locale_switcher) }}
{% endif %} diff --git a/composer.json b/composer.json index fbd337454..61665633d 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,11 @@ "fortawesome/font-awesome": "~4.2.0", "jms/translation-bundle": "~1.1.0", "jms/di-extra-bundle": "~1.4.0", - "surfnet/stepup-middleware-client-bundle": "dev-develop", + "surfnet/stepup-middleware-client-bundle": "dev-feature/preferred-locale", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-maintenance/sms-verification", + "surfnet/stepup-bundle": "dev-feature/preferred-locale", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 4861e1234..00c75f3fb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "87de26c67c058c2058f8ada4bbdb78ee", + "hash": "a59883d0234216cfda24f08c84cb5601", "packages": [ { "name": "beberlei/assert", @@ -1190,7 +1190,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/a5573423b7d029d65bf85e3eba336d5d85d695f1", + "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/6df7486cd7181be4e4649e1c7303fc3041a37ae5", "reference": "818b0f47ebd352559950e9a64431ff9472e8a9dd", "shasum": "" }, @@ -1750,16 +1750,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-maintenance/sms-verification", + "version": "dev-feature/preferred-locale", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "246dd36743fc263762f7c53ec0e9f986693baa5f" + "reference": "ade1ad6b364fa096303392c032315683f3551f7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/246dd36743fc263762f7c53ec0e9f986693baa5f", - "reference": "246dd36743fc263762f7c53ec0e9f986693baa5f", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/ade1ad6b364fa096303392c032315683f3551f7b", + "reference": "ade1ad6b364fa096303392c032315683f3551f7b", "shasum": "" }, "require": { @@ -1772,7 +1772,9 @@ "symfony/config": "~2", "symfony/dependency-injection": "~2", "symfony/form": "~2", + "symfony/framework-bundle": "~2", "symfony/http-kernel": "~2", + "symfony/twig-bridge": "~2", "symfony/validator": "~2" }, "require-dev": { @@ -1796,20 +1798,20 @@ "suaas", "surfnet" ], - "time": "2015-05-22 11:47:24" + "time": "2015-06-01 13:26:46" }, { "name": "surfnet/stepup-middleware-client-bundle", - "version": "dev-develop", + "version": "dev-feature/preferred-locale", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-Middleware-clientbundle.git", - "reference": "c9c64643062c16452d9e3075850eee8436a82ec5" + "reference": "29bcb9edaba988e7e263d677bcc3ea96e5b494ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/4eafa9f46ec0e79acd0104b49e316bbbb6c128ba", - "reference": "c9c64643062c16452d9e3075850eee8436a82ec5", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/29bcb9edaba988e7e263d677bcc3ea96e5b494ab", + "reference": "29bcb9edaba988e7e263d677bcc3ea96e5b494ab", "shasum": "" }, "require": { @@ -1845,7 +1847,7 @@ "Apache-2.0" ], "description": "Symfony2 bundle for consuming the Step-up Middleware API.", - "time": "2015-04-07 13:57:30" + "time": "2015-06-01 12:37:42" }, { "name": "surfnet/stepup-saml-bundle", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php new file mode 100644 index 000000000..7543fb4d4 --- /dev/null +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php @@ -0,0 +1,77 @@ +query->get('return-url'); + + /** @var LoggerInterface $logger */ + $logger = $this->get('logger'); + $logger->info('Switching locale...'); + + $identity = $this->getIdentity(); + if (!$identity) { + throw new AccessDeniedHttpException('Cannot switch locales when not authenticated'); + } + + $command = new SwitchLocaleCommand(); + $command->identityId = $identity->id; + + $form = $this->createForm( + 'stepup_switch_locale', + $command, + ['route' => 'ss_switch_locale', 'route_parameters' => ['return_url' => $returnUrl]] + ); + $form->handleRequest($request); + + if (!$form->isValid()) { + $this->addFlash('error', $this->get('translator')->trans('ss.flash.invalid_switch_locale_form')); + $logger->error('The switch locale form unexpectedly contained invalid data'); + return $this->redirect($returnUrl); + } + + $service = $this->get('self_service.service.identity'); + if (!$service->switchLocale($command)) { + $this->addFlash('error', $this->get('translator')->trans('ss.flash.error_while_switching_locale')); + $logger->error('An error occurred while switching locales'); + return $this->redirect($returnUrl); + } + + $logger->info('Successfully switched locale'); + + return $this->redirect($returnUrl); + } + + /** + * @return \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity + */ + private function getIdentity() + { + return $this->get('security.token_storage')->getToken()->getUser(); + } +} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/EventListener/LocaleListener.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/EventListener/LocaleListener.php new file mode 100644 index 000000000..9cdfe1cd9 --- /dev/null +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/EventListener/LocaleListener.php @@ -0,0 +1,78 @@ +tokenStorage = $tokenStorage; + $this->translator = $translator; + } + + public function setRequestLocale(GetResponseEvent $event) + { + $token = $this->tokenStorage->getToken(); + + if (!$token) { + return; + } + + /** @var Identity $identity */ + $identity = $token->getUser(); + + $request = $event->getRequest(); + $request->setLocale($identity->preferredLocale); + + // As per \Symfony\Component\HttpKernel\EventListener\TranslatorListener::setLocale() + try { + $this->translator->setLocale($request->getLocale()); + } catch (\InvalidArgumentException $e) { + $this->translator->setLocale($request->getDefaultLocale()); + } + } + + public static function getSubscribedEvents() + { + return [ + // Default locale listener listens at P16 + // Translator listener, which sets the locale for the translator, listens at P10 + // The firewall, which makes the token available, listens at P8 + // We must jump in after the firewall, forcing us to overwrite the translator locale. + KernelEvents::REQUEST => ['setRequestLocale', 7], + ]; + } +} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/routing.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/routing.yml index 978bf9502..93eb8ce94 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/routing.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/routing.yml @@ -79,3 +79,10 @@ selfservice_serviceprovider_consume_assertion: path: /authentication/consume-assertion methods: [POST] defaults: { _controller: SurfnetStepupSelfServiceSelfServiceBundle:Saml:consumeAssertion } + +ss_switch_locale: + path: /switch-locale + methods: [POST] + defaults: { _controller: SurfnetStepupSelfServiceSelfServiceBundle:Locale:switchLocale } + requirements: + 'return-url': '.+' diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml index 9e6c025e8..c87549d2b 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml @@ -73,6 +73,7 @@ services: arguments: - @surfnet_stepup_middleware_client.identity.service.identity - @surfnet_stepup_self_service_self_service.service.command + - @security.token_storage - @logger self_service.service.ra: @@ -111,3 +112,9 @@ services: class: Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\SessionHandler arguments: - @session + + # Listeners + ra.event_listener.locale: + class: Surfnet\StepupSelfService\SelfServiceBundle\EventListener\LocaleListener + arguments: [ @security.token_storage, @translator ] + tags: [{ name: kernel.event_subscriber }] diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/public/less/style.less b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/public/less/style.less index 795ae3f43..8c74d1ea9 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/public/less/style.less +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/public/less/style.less @@ -63,6 +63,13 @@ form[name="ss_verify_email"] { } } +form[name="stepup_switch_locale"] { + .pull-right(); +} +select[name="stepup_switch_locale[locale]"] { + min-width: 150px; +} + .generate-progress(100); .generate-progress(@n, @i: 0) when (@i =< @n) { diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php index f04cdde93..7619fd5c1 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php @@ -20,12 +20,16 @@ use Exception; use Psr\Log\LoggerInterface; +use Surfnet\StepupBundle\Command\SwitchLocaleCommand; use Surfnet\StepupMiddlewareClient\Identity\Dto\IdentitySearchQuery; use Surfnet\StepupMiddlewareClientBundle\Identity\Command\CreateIdentityCommand; +use Surfnet\StepupMiddlewareClientBundle\Identity\Command\ExpressLocalePreferenceCommand; use Surfnet\StepupMiddlewareClientBundle\Identity\Command\UpdateIdentityCommand; use Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity; use Surfnet\StepupMiddlewareClientBundle\Identity\Service\IdentityService as ApiIdentityService; use Surfnet\StepupSelfService\SelfServiceBundle\Exception\RuntimeException; +use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; @@ -41,6 +45,11 @@ class IdentityService implements UserProviderInterface */ private $commandService; + /** + * @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface + */ + private $tokenStorage; + /** * @var \Psr\Log\LoggerInterface */ @@ -49,10 +58,12 @@ class IdentityService implements UserProviderInterface public function __construct( ApiIdentityService $apiIdentityService, CommandService $commandService, + TokenStorageInterface $tokenStorage, LoggerInterface $logger ) { $this->apiIdentityService = $apiIdentityService; $this->commandService = $commandService; + $this->tokenStorage = $tokenStorage; $this->logger = $logger; } @@ -149,6 +160,36 @@ public function updateIdentity(Identity $identity) $this->processCommand($command); } + + /** + * @param SwitchLocaleCommand $command + * @return bool + */ + public function switchLocale(SwitchLocaleCommand $command) + { + /** @var TokenInterface|null */ + $token = $this->tokenStorage->getToken(); + + if (!$token) { + throw new RuntimeException('Cannot switch locales when unauthenticated'); + } + + /** @var Identity $identity */ + $identity = $token->getUser(); + + $expressLocalePreferenceCommand = new ExpressLocalePreferenceCommand(); + $expressLocalePreferenceCommand->identityId = $command->identityId; + $expressLocalePreferenceCommand->preferredLocale = $command->locale; + + $result = $this->commandService->execute($expressLocalePreferenceCommand); + + if ($result->isSuccessful()) { + $identity->preferredLocale = $command->locale; + } + + return $result->isSuccessful(); + } + /** * @param $command */ From 3f42509b67894ef2c402a6a48a6159470e522bd4 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Mon, 1 Jun 2015 16:45:47 +0200 Subject: [PATCH 04/36] Ignore coupling between objects in IdentityService. --- .../SelfServiceBundle/Service/IdentityService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php index 7619fd5c1..7becad97f 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php @@ -33,6 +33,9 @@ use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Core\User\UserProviderInterface; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) -- Hard to reduce due to different commands and queries used. + */ class IdentityService implements UserProviderInterface { /** From 4d463f19450e36de3f5d4a682ece8e895b22845d Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Mon, 1 Jun 2015 17:04:39 +0200 Subject: [PATCH 05/36] Update to develop branches of Stepup bundles. --- composer.json | 4 ++-- composer.lock | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 61665633d..f13355ca6 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,11 @@ "fortawesome/font-awesome": "~4.2.0", "jms/translation-bundle": "~1.1.0", "jms/di-extra-bundle": "~1.4.0", - "surfnet/stepup-middleware-client-bundle": "dev-feature/preferred-locale", + "surfnet/stepup-middleware-client-bundle": "dev-develop", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-feature/preferred-locale", + "surfnet/stepup-bundle": "dev-develop", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 00c75f3fb..3027ff10d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "a59883d0234216cfda24f08c84cb5601", + "hash": "47e88ab167ef626f6d5a065f5bbe3386", "packages": [ { "name": "beberlei/assert", @@ -1750,16 +1750,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-feature/preferred-locale", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "ade1ad6b364fa096303392c032315683f3551f7b" + "reference": "f0d4419e8be9a8738809ae35b0e2f4c30ac683df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/ade1ad6b364fa096303392c032315683f3551f7b", - "reference": "ade1ad6b364fa096303392c032315683f3551f7b", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/f0d4419e8be9a8738809ae35b0e2f4c30ac683df", + "reference": "f0d4419e8be9a8738809ae35b0e2f4c30ac683df", "shasum": "" }, "require": { @@ -1798,20 +1798,20 @@ "suaas", "surfnet" ], - "time": "2015-06-01 13:26:46" + "time": "2015-06-01 15:00:25" }, { "name": "surfnet/stepup-middleware-client-bundle", - "version": "dev-feature/preferred-locale", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-Middleware-clientbundle.git", - "reference": "29bcb9edaba988e7e263d677bcc3ea96e5b494ab" + "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/29bcb9edaba988e7e263d677bcc3ea96e5b494ab", - "reference": "29bcb9edaba988e7e263d677bcc3ea96e5b494ab", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/929b8a75042ac129d91eb691d773f4cf41081ec1", + "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1", "shasum": "" }, "require": { @@ -1847,7 +1847,7 @@ "Apache-2.0" ], "description": "Symfony2 bundle for consuming the Step-up Middleware API.", - "time": "2015-06-01 12:37:42" + "time": "2015-06-01 15:00:06" }, { "name": "surfnet/stepup-saml-bundle", From 349dc182553cbcb86909176bfd029a1599d77ba1 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Mon, 1 Jun 2015 20:26:49 +0200 Subject: [PATCH 06/36] Use shared controller. --- .../SelfServiceBundle/Controller/LocaleController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php index 7543fb4d4..447e67241 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/LocaleController.php @@ -20,7 +20,6 @@ use Psr\Log\LoggerInterface; use Surfnet\StepupBundle\Command\SwitchLocaleCommand; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; @@ -66,12 +65,4 @@ public function switchLocaleAction(Request $request) return $this->redirect($returnUrl); } - - /** - * @return \Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity - */ - private function getIdentity() - { - return $this->get('security.token_storage')->getToken()->getUser(); - } } From a861bef217278c7b6fcb49c5632409bcb9ffd410 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 12:10:17 +0200 Subject: [PATCH 07/36] Include preferred locale when creating identity. --- .../Security/Authentication/Provider/SamlProvider.php | 11 ++++++----- .../SelfServiceBundle/Service/IdentityService.php | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php index be01655ab..0fd613d3c 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php @@ -63,11 +63,12 @@ public function authenticate(TokenInterface $token) if ($identity === null) { $identity = new Identity(); - $identity->id = Uuid::generate(); - $identity->nameId = $nameId; - $identity->institution = $institution; - $identity->email = $email; - $identity->commonName = $commonName; + $identity->id = Uuid::generate(); + $identity->nameId = $nameId; + $identity->institution = $institution; + $identity->email = $email; + $identity->commonName = $commonName; + $identity->preferredLocale = 'en_GB'; $this->identityService->createIdentity($identity); } elseif ($identity->email !== $email || $identity->commonName !== $commonName) { diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php index 7becad97f..e99cd0d1c 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php @@ -142,11 +142,12 @@ public function findByNameIdAndInstitution($nameId, $institution) public function createIdentity(Identity $identity) { $command = new CreateIdentityCommand(); - $command->id = $identity->id; - $command->nameId = $identity->nameId; - $command->institution = $identity->institution; - $command->email = $identity->email; - $command->commonName = $identity->commonName; + $command->id = $identity->id; + $command->nameId = $identity->nameId; + $command->institution = $identity->institution; + $command->email = $identity->email; + $command->commonName = $identity->commonName; + $command->preferredLocale = $identity->preferredLocale; $this->processCommand($command); } From 59fd5f03053b75478bb8b5045dfc96fa47845483 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 12:11:20 +0200 Subject: [PATCH 08/36] Determine identity's preferred locale based on their Accept header. --- composer.json | 1 + composer.lock | 114 +++++++++++++++++- ...tStepupSelfServiceSelfServiceExtension.php | 4 + .../Locale/PreferredLocaleProvider.php | 27 +++++ .../Locale/RequestStackLocaleProvider.php | 82 +++++++++++++ .../Resources/config/services.yml | 8 ++ .../Authentication/Provider/SamlProvider.php | 12 +- .../Locale/RequestStackLocaleProviderTest.php | 96 +++++++++++++++ 8 files changed, 340 insertions(+), 4 deletions(-) create mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Locale/PreferredLocaleProvider.php create mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Locale/RequestStackLocaleProvider.php create mode 100644 src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Locale/RequestStackLocaleProviderTest.php diff --git a/composer.json b/composer.json index f13355ca6..7b6f22531 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { + "mockery/mockery": "~0.9.0", "sensio/generator-bundle": "~2.3", "ibuildings/qa-tools": "~1.1,>=1.1.27", "liip/rmt": "1.1.*" diff --git a/composer.lock b/composer.lock index 3027ff10d..ed2734e9d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "47e88ab167ef626f6d5a065f5bbe3386", + "hash": "fac0434984988ad361170d367b3dd315", "packages": [ { "name": "beberlei/assert", @@ -1190,7 +1190,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/6df7486cd7181be4e4649e1c7303fc3041a37ae5", + "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/0b467cf9e3de5b80cb7830dc758265204a5fcde5", "reference": "818b0f47ebd352559950e9a64431ff9472e8a9dd", "shasum": "" }, @@ -2945,6 +2945,51 @@ ], "time": "2014-07-22 13:24:11" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v1.2.2", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", + "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "satooshi/php-coveralls": "dev-master" + }, + "type": "library", + "autoload": { + "classmap": [ + "hamcrest" + ], + "files": [ + "hamcrest/Hamcrest.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2015-05-11 14:41:42" + }, { "name": "ibuildings/qa-tools", "version": "1.1.27", @@ -3114,6 +3159,71 @@ ], "time": "2014-10-28 10:33:21" }, + { + "name": "mockery/mockery", + "version": "0.9.4", + "source": { + "type": "git", + "url": "https://github.com/padraic/mockery.git", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b", + "reference": "70bba85e4aabc9449626651f48b9018ede04f86b", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~1.1", + "lib-pcre": ">=7.0", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.9.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", + "homepage": "http://github.com/padraic/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2015-04-02 19:54:00" + }, { "name": "pdepend/pdepend", "version": "2.0.3", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php index 3b5c800e4..37ad19666 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/DependencyInjection/SurfnetStepupSelfServiceSelfServiceExtension.php @@ -37,5 +37,9 @@ public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); + + $container->getDefinition('self_service.locale.request_stack_locale_provider') + ->replaceArgument(1, $container->getParameter('default_locale')) + ->replaceArgument(2, $container->getParameter('locales')); } } diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Locale/PreferredLocaleProvider.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Locale/PreferredLocaleProvider.php new file mode 100644 index 000000000..f1bef77b5 --- /dev/null +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Locale/PreferredLocaleProvider.php @@ -0,0 +1,27 @@ + $supportedLocale) { + if (!is_string($supportedLocale)) { + $parameterName = sprintf('supportedLocales[%s]', $key); + throw InvalidArgumentException::invalidType('string', $parameterName, $supportedLocale); + } + } + + $this->requestStack = $requestStack; + $this->defaultLocale = $defaultLocale; + $this->supportedLocales = $supportedLocales; + } + + public function providePreferredLocale() + { + $preferredLocale = $this->requestStack->getCurrentRequest()->getPreferredLanguage($this->supportedLocales); + + if (!$preferredLocale) { + return $this->defaultLocale; + } + + return $preferredLocale; + } +} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml index c87549d2b..767030979 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml @@ -86,6 +86,7 @@ services: arguments: - @self_service.service.identity - @surfnet_saml.saml.attribute_dictionary + - @self_service.locale.request_stack_locale_provider self_service.security.authentication.listener: class: Surfnet\StepupSelfService\SelfServiceBundle\Security\Firewall\SamlListener @@ -118,3 +119,10 @@ services: class: Surfnet\StepupSelfService\SelfServiceBundle\EventListener\LocaleListener arguments: [ @security.token_storage, @translator ] tags: [{ name: kernel.event_subscriber }] + + self_service.locale.request_stack_locale_provider: + class: Surfnet\StepupSelfService\SelfServiceBundle\Locale\RequestStackLocaleProvider + arguments: + - @request_stack + - '' # See extension + - [] # See extension diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php index 0fd613d3c..e1618243b 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php @@ -21,6 +21,7 @@ use Surfnet\SamlBundle\SAML2\Attribute\AttributeDictionary; use Surfnet\StepupMiddlewareClientBundle\Identity\Dto\Identity; use Surfnet\StepupMiddlewareClientBundle\Uuid\Uuid; +use Surfnet\StepupSelfService\SelfServiceBundle\Locale\PreferredLocaleProvider; use Surfnet\StepupSelfService\SelfServiceBundle\Security\Authentication\Token\SamlToken; use Surfnet\StepupSelfService\SelfServiceBundle\Service\IdentityService; use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; @@ -38,12 +39,19 @@ class SamlProvider implements AuthenticationProviderInterface */ private $attributeDictionary; + /** + * @var \Symfony\Component\HttpFoundation\PreferredLocaleProvider + */ + private $preferredLocaleProvider; + public function __construct( IdentityService $identityService, - AttributeDictionary $attributeDictionary + AttributeDictionary $attributeDictionary, + PreferredLocaleProvider $preferredLocaleProvider ) { $this->identityService = $identityService; $this->attributeDictionary = $attributeDictionary; + $this->preferredLocaleProvider = $preferredLocaleProvider; } /** @@ -68,7 +76,7 @@ public function authenticate(TokenInterface $token) $identity->institution = $institution; $identity->email = $email; $identity->commonName = $commonName; - $identity->preferredLocale = 'en_GB'; + $identity->preferredLocale = $this->preferredLocaleProvider->providePreferredLocale(); $this->identityService->createIdentity($identity); } elseif ($identity->email !== $email || $identity->commonName !== $commonName) { diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Locale/RequestStackLocaleProviderTest.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Locale/RequestStackLocaleProviderTest.php new file mode 100644 index 000000000..399bf597a --- /dev/null +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Tests/Locale/RequestStackLocaleProviderTest.php @@ -0,0 +1,96 @@ +shouldReceive('getPreferredLanguage')->with(['en_GB', 'nl_NL'])->once()->andReturn('nl_NL'); + + $requestStack = m::mock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack->shouldReceive('getCurrentRequest')->with()->once()->andReturn($request); + + $provider = new RequestStackLocaleProvider($requestStack, 'en_GB', ['en_GB', 'nl_NL']); + $this->assertEquals('nl_NL', $provider->providePreferredLocale()); + } + + /** + * @test + */ + public function it_falls_back_to_the_default_locale() + { + $request = m::mock('Symfony\Component\HttpFoundation\Request'); + $request->shouldReceive('getPreferredLanguage')->with(['en_GB', 'nl_NL'])->once()->andReturn(null); + + $requestStack = m::mock('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack->shouldReceive('getCurrentRequest')->with()->once()->andReturn($request); + + $provider = new RequestStackLocaleProvider($requestStack, 'de_DE', ['en_GB', 'nl_NL']); + $this->assertEquals('de_DE', $provider->providePreferredLocale()); + } + + public function non_strings() + { + return [ + 'array' => [array()], + 'integer' => [1], + 'object' => [new \stdClass()], + 'null' => [null], + 'bool' => [false], + 'resource' => [fopen('php://memory', 'w')], + ]; + } + + /** + * @test + * @dataProvider non_strings + * @expectedException Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException + * @expectedExceptionMessage given for "defaultLocale" + * @param mixed $nonString + */ + public function it_requires_the_default_locale_to_be_a_string($nonString) + { + $requestStack = m::mock('Symfony\Component\HttpFoundation\RequestStack'); + + new RequestStackLocaleProvider($requestStack, $nonString, ['en_GB', 'nl_NL']); + } + + /** + * @test + * @dataProvider non_strings + * @expectedException Surfnet\StepupSelfService\SelfServiceBundle\Exception\InvalidArgumentException + * @expectedExceptionMessage given for "supportedLocales[1]" + * @param mixed $nonString + */ + public function it_requires_the_supported_locales_to_be_strings($nonString) + { + $requestStack = m::mock('Symfony\Component\HttpFoundation\RequestStack'); + + new RequestStackLocaleProvider($requestStack, 'nl_NL', ['en_GB', $nonString]); + } +} From 5c20ff989e4ff9d4494e254bb58963da456b6821 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 12:11:44 +0200 Subject: [PATCH 09/36] Correct service name. --- .../SelfServiceBundle/Resources/config/services.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml index 767030979..cdab0ec47 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/config/services.yml @@ -114,8 +114,7 @@ services: arguments: - @session - # Listeners - ra.event_listener.locale: + self_service.event_listener.locale: class: Surfnet\StepupSelfService\SelfServiceBundle\EventListener\LocaleListener arguments: [ @security.token_storage, @translator ] tags: [{ name: kernel.event_subscriber }] From 71580170ed9d9f20e008b7bf19d39e90e822ab88 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 16:39:35 +0200 Subject: [PATCH 10/36] Update to Symfony 2.7 LTS. --- composer.json | 2 +- composer.lock | 59 ++++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index 7b6f22531..ab584e7d6 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "minimum-stability": "stable", "require": { "php": ">=5.4", - "symfony/symfony": "~2.6,>=2.6.6", + "symfony/symfony": "^2.7", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", diff --git a/composer.lock b/composer.lock index ed2734e9d..a52870dc3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "fac0434984988ad361170d367b3dd315", + "hash": "48d2d005dd004fca6a6b2a87baaf664a", "packages": [ { "name": "beberlei/assert", @@ -2130,25 +2130,26 @@ }, { "name": "symfony/symfony", - "version": "v2.6.6", + "version": "v2.7.0", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "48c9e835a877adfb023b8b6d033d9dd14f342b4b" + "reference": "9975b1eca3de4db792a2c3e4e16f676a4aadcd46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/48c9e835a877adfb023b8b6d033d9dd14f342b4b", - "reference": "48c9e835a877adfb023b8b6d033d9dd14f342b4b", + "url": "https://api.github.com/repos/symfony/symfony/zipball/9975b1eca3de4db792a2c3e4e16f676a4aadcd46", + "reference": "9975b1eca3de4db792a2c3e4e16f676a4aadcd46", "shasum": "" }, "require": { "doctrine/common": "~2.3", - "php": ">=5.3.3", + "php": ">=5.3.9", "psr/log": "~1.0", - "twig/twig": "~1.12,>=1.12.3" + "twig/twig": "~1.18" }, "replace": { + "symfony/asset": "self.version", "symfony/browser-kit": "self.version", "symfony/class-loader": "self.version", "symfony/config": "self.version", @@ -2172,7 +2173,6 @@ "symfony/monolog-bridge": "self.version", "symfony/options-resolver": "self.version", "symfony/process": "self.version", - "symfony/propel1-bridge": "self.version", "symfony/property-access": "self.version", "symfony/proxy-manager-bridge": "self.version", "symfony/routing": "self.version", @@ -2203,18 +2203,23 @@ "ircmaxell/password-compat": "~1.0", "monolog/monolog": "~1.11", "ocramius/proxy-manager": "~0.4|~1.0", - "propel/propel1": "~1.6", - "symfony/phpunit-bridge": "~2.7" + "symfony/phpunit-bridge": "self.version" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.7-dev" } }, "autoload": { - "psr-0": { - "Symfony\\": "src/" + "psr-4": { + "Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/", + "Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/", + "Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/", + "Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/", + "Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/", + "Symfony\\Bundle\\": "src/Symfony/Bundle/", + "Symfony\\Component\\": "src/Symfony/Component/" }, "classmap": [ "src/Symfony/Component/HttpFoundation/Resources/stubs", @@ -2229,21 +2234,21 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "The Symfony PHP framework", - "homepage": "http://symfony.com", + "homepage": "https://symfony.com", "keywords": [ "framework" ], - "time": "2015-04-01 16:55:26" + "time": "2015-05-30 16:52:28" }, { "name": "twbs/bootstrap", @@ -2350,25 +2355,25 @@ }, { "name": "twig/twig", - "version": "v1.16.2", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", - "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9f70492f44398e276d1b81c1b43adfe6751c7b7f", + "reference": "9f70492f44398e276d1b81c1b43adfe6751c7b7f", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.2.7" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.16-dev" + "dev-master": "1.18-dev" } }, "autoload": { @@ -2394,7 +2399,7 @@ }, { "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "homepage": "http://twig.sensiolabs.org/contributors", "role": "Contributors" } ], @@ -2403,7 +2408,7 @@ "keywords": [ "templating" ], - "time": "2014-10-17 12:53:44" + "time": "2015-04-19 08:30:27" } ], "packages-dev": [ From 6b5695806d12bc4d58b09833d98f83f70b71f795 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 16:39:53 +0200 Subject: [PATCH 11/36] Disable reporting of E_USER_DEPRECATED errors triggered by Symfony. --- app/console | 2 +- app_dev.php.dist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/console b/app/console index 118fee251..ec53685c1 100755 --- a/app/console +++ b/app/console @@ -17,7 +17,7 @@ $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('- && $env !== 'build'; if ($debug) { - Debug::enable(); + Debug::enable(~E_USER_DEPRECATED); } $kernel = new AppKernel($env, $debug); diff --git a/app_dev.php.dist b/app_dev.php.dist index 6355b73b8..01590cd3a 100644 --- a/app_dev.php.dist +++ b/app_dev.php.dist @@ -4,7 +4,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Debug\Debug; $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; -Debug::enable(); +Debug::enable(~E_USER_DEPRECATED); require_once __DIR__.'/../app/AppKernel.php'; From 638dbfe75e7bd3301dc961e8a99a352618ae03ac Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 16:40:12 +0200 Subject: [PATCH 12/36] Switch from AbstractType#setDefaultOptions() to #configureOptions(). --- .../SelfServiceBundle/Form/Type/AnchorType.php | 4 ++-- .../Form/Type/ProveYubikeyPossessionType.php | 4 ++-- .../SelfServiceBundle/Form/Type/RevokeSecondFactorType.php | 4 ++-- .../SelfServiceBundle/Form/Type/SendSmsChallengeType.php | 4 ++-- .../SelfServiceBundle/Form/Type/VerifyEmailType.php | 4 ++-- .../SelfServiceBundle/Form/Type/VerifySmsChallengeType.php | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php index 3869ca0f3..af185fc89 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php @@ -22,7 +22,7 @@ use Symfony\Component\Form\ButtonTypeInterface; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class AnchorType extends AbstractType implements ButtonTypeInterface { @@ -36,7 +36,7 @@ public function getName() return 'anchor'; } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'route' => null, diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/ProveYubikeyPossessionType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/ProveYubikeyPossessionType.php index df9aa1c91..7b5ab1257 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/ProveYubikeyPossessionType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/ProveYubikeyPossessionType.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class ProveYubikeyPossessionType extends AbstractType { @@ -39,7 +39,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Surfnet\StepupSelfService\SelfServiceBundle\Command\VerifyYubikeyOtpCommand', diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/RevokeSecondFactorType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/RevokeSecondFactorType.php index 035d2d992..6994bbd12 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/RevokeSecondFactorType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/RevokeSecondFactorType.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class RevokeSecondFactorType extends AbstractType { @@ -38,7 +38,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Surfnet\StepupSelfService\SelfServiceBundle\Command\RevokeCommand', diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php index 9a456fec6..4474b58aa 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php @@ -21,7 +21,7 @@ use Surfnet\StepupBundle\Value\PhoneNumber\CountryCodeListing; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class SendSmsChallengeType extends AbstractType { @@ -51,7 +51,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'attr' => ['class' => 'form-inline'], diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifyEmailType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifyEmailType.php index 594db6f21..b06d850d2 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifyEmailType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifyEmailType.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class VerifyEmailType extends AbstractType { @@ -40,7 +40,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Surfnet\StepupSelfService\SelfServiceBundle\Identity\Command\VerifyEmailCommand', diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifySmsChallengeType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifySmsChallengeType.php index 605554e1a..3dcd454fe 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifySmsChallengeType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/VerifySmsChallengeType.php @@ -20,7 +20,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; class VerifySmsChallengeType extends AbstractType { @@ -44,7 +44,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) ]); } - public function setDefaultOptions(OptionsResolverInterface $resolver) + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => 'Surfnet\StepupSelfService\SelfServiceBundle\Command\VerifySmsChallengeCommand', From 880b93673a224072e44e2ab95e9e42192a8b1663 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 16:44:29 +0200 Subject: [PATCH 13/36] Switch to new framework assets configuration. --- app/config/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/config/config.yml b/app/config/config.yml index 8b547f4ea..9277fbfe8 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -16,7 +16,8 @@ framework: validation: { enable_annotations: true } templating: engines: ['twig'] - assets_version: %asset_version% + assets: + version: %asset_version% default_locale: "%default_locale%" trusted_hosts: ~ trusted_proxies: %trusted_proxies% From 9bbb57e754f4cabeb1afadcf75709fba3282ace5 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 2 Jun 2015 16:46:18 +0200 Subject: [PATCH 14/36] Include upgrade-related changes from Stepup bundles. --- composer.json | 4 ++-- composer.lock | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index ab584e7d6..9821ce76d 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ "surfnet/stepup-middleware-client-bundle": "dev-develop", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", - "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-develop", + "surfnet/stepup-saml-bundle": "dev-maintenance/symfony-2.7", + "surfnet/stepup-bundle": "dev-maintenance/symfony-2.7", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index a52870dc3..7127e11d4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "48d2d005dd004fca6a6b2a87baaf664a", + "hash": "aba03c59c6516d324567ca063a795453", "packages": [ { "name": "beberlei/assert", @@ -1750,16 +1750,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-develop", + "version": "dev-maintenance/symfony-2.7", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "f0d4419e8be9a8738809ae35b0e2f4c30ac683df" + "reference": "c1f4fd18712aed612fb908f53cea6fe7ef2a0831" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/f0d4419e8be9a8738809ae35b0e2f4c30ac683df", - "reference": "f0d4419e8be9a8738809ae35b0e2f4c30ac683df", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/c1f4fd18712aed612fb908f53cea6fe7ef2a0831", + "reference": "c1f4fd18712aed612fb908f53cea6fe7ef2a0831", "shasum": "" }, "require": { @@ -1771,7 +1771,7 @@ "sensio/framework-extra-bundle": "~3", "symfony/config": "~2", "symfony/dependency-injection": "~2", - "symfony/form": "~2", + "symfony/form": "^2.7", "symfony/framework-bundle": "~2", "symfony/http-kernel": "~2", "symfony/twig-bridge": "~2", @@ -1798,7 +1798,7 @@ "suaas", "surfnet" ], - "time": "2015-06-01 15:00:25" + "time": "2015-06-02 13:04:33" }, { "name": "surfnet/stepup-middleware-client-bundle", @@ -1851,22 +1851,23 @@ }, { "name": "surfnet/stepup-saml-bundle", - "version": "dev-develop", + "version": "dev-maintenance/symfony-2.7", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-saml-bundle.git", - "reference": "4f4d4d9d04b3d9b1e322ad4cc6579336ba932ed3" + "reference": "4e9457c627b2e01dde930f52d5bce0690179ba6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/34db9134005e4e6ce42662f5d58a9d681e3c1968", - "reference": "4f4d4d9d04b3d9b1e322ad4cc6579336ba932ed3", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/4e9457c627b2e01dde930f52d5bce0690179ba6b", + "reference": "4e9457c627b2e01dde930f52d5bce0690179ba6b", "shasum": "" }, "require": { "ext-openssl": "*", "php": "~5.4", "simplesamlphp/saml2": "dev-master", + "symfony/dependency-injection": "^2.6", "symfony/framework-bundle": "~2.5" }, "require-dev": { @@ -1893,7 +1894,7 @@ "stepup", "surfnet" ], - "time": "2015-04-16 10:02:22" + "time": "2015-06-02 12:25:57" }, { "name": "swiftmailer/swiftmailer", From c3f067aeb3855fbb42668d80ee48349a2d3ed2c6 Mon Sep 17 00:00:00 2001 From: Pieter van der Meulen Date: Tue, 2 Jun 2015 17:05:38 +0200 Subject: [PATCH 15/36] Use local syslog for logging --- app/config/config_prod.yml | 22 ---------------------- app/config/logging.yml | 29 +++++++++++------------------ 2 files changed, 11 insertions(+), 40 deletions(-) diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml index 4eb2c8ce6..54fc4f28f 100644 --- a/app/config/config_prod.yml +++ b/app/config/config_prod.yml @@ -5,25 +5,3 @@ imports: # validation: # cache: apc -monolog: - handlers: - prod-signaler: - type: fingers_crossed - action_level: ERROR - handler: prod_main - bubble: false # if we handle it, nothing else should - prod_main: - type: group - members: - - main_graylog - - main_logfile - - buffered_mailer - buffered_mailer: - type: buffer - handler: swift - swift: - type: swift_mailer - # these email addresses should be configurable and configured correctly - from_email: stepup-error@surfnet.nl - to_email: error@example.com - subject: "[StepUp][SelfService][%kernel.environment%] An Error Occurred!" diff --git a/app/config/logging.yml b/app/config/logging.yml index b102c7f1d..574e34dc5 100644 --- a/app/config/logging.yml +++ b/app/config/logging.yml @@ -1,20 +1,13 @@ monolog: handlers: - main: - type: group - members: - - main_graylog - - main_logfile - main_graylog: - type: buffer - handler: graylog - level: NOTICE - main_logfile: - type: stream - handler: logfile - level: NOTICE - path: %kernel.logs_dir%/%kernel.environment%.log - graylog: - type: gelf - publisher: { hostname: %graylog_hostname% } - formatter: surfnet_stepup.monolog.full_message_exception_gelf_message_formatter + prod-signaler: + type: fingers_crossed + action_level: ERROR + passthru_level: NOTICE # this means that all message of level NOTICE or higher are always logged + handler: main_syslog + bubble: false # if we handle it, nothing else should + main_syslog: + type: syslog + ident: stepup-selfservice + facility: user + From df8a44ae2068562c9f78a4454bbc1847c4ebc5b0 Mon Sep 17 00:00:00 2001 From: DRvanR Date: Wed, 3 Jun 2015 13:39:08 +0200 Subject: [PATCH 16/36] Ensure logging in development still works as should --- app/config/config_dev.yml | 51 +++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index e40ee78bc..ef20b8d4b 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -11,23 +11,44 @@ web_profiler: toolbar: "%debug_toolbar%" intercept_redirects: "%debug_redirects%" +# Be careful not to remove the prod-signaler handler, which overwrites +# the prod-signaler handler defined in logging.yml. The handler defined +# in logging.yml disables bubbling which means that none of the handlers +# below are invoked. Since the current dev setup is incompatible with the +# prod setup defined in logging.yml, this means we won't see any logs in +# the infrastructure currently used (graylog). Overwriting the handler +# here resolves that and reinstates the dev logging setup. +# +# this configuration must be replaced to reflect production setup +# see https://www.pivotaltracker.com/story/show/96056010 +# monolog: + channels: [authentication] handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.debug.log" - level: debug - console: - type: console - bubble: false - # uncomment to get logging in your browser - # you may have to allow bigger header sizes in your Web server configuration - #firephp: - # type: firephp - # level: info - #chromephp: - # type: chromephp - # level: info + prod-signaler: + type: group + members: + - main_graylog + - main_logfile + - main_debuglog + main_graylog: + type: buffer + handler: graylog + level: NOTICE + main_logfile: + type: stream + handler: logfile + level: NOTICE + path: %kernel.logs_dir%/%kernel.environment%.log + main_debuglog: + type: stream + handler: logfile + level: DEBUG + path: "%kernel.logs_dir%/%kernel.environment%.debug.log" + graylog: + type: gelf + publisher: { hostname: %graylog_hostname% } + formatter: surfnet_stepup.monolog.full_message_exception_gelf_message_formatter assetic: use_controller: "%use_assetic_controller%" From 69e3967fdb5fe372b6ba1c1add379dd9c1c5d5eb Mon Sep 17 00:00:00 2001 From: DRvanR Date: Wed, 3 Jun 2015 13:40:39 +0200 Subject: [PATCH 17/36] Remove unused logging channel --- app/config/config_dev.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index ef20b8d4b..91e0ead64 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -23,7 +23,6 @@ web_profiler: # see https://www.pivotaltracker.com/story/show/96056010 # monolog: - channels: [authentication] handlers: prod-signaler: type: group From fb32c1231e6f80b6b657db49149eb2b1b223ca47 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 3 Jun 2015 13:43:39 +0200 Subject: [PATCH 18/36] Update to latest Stepup bundle. --- app/Resources/views/base.html.twig | 2 +- composer.lock | 10 +++++----- .../Form/Type/SendSmsChallengeType.php | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index dff5b13d7..b7800e196 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -33,7 +33,7 @@ {{ 'button.logout'|trans }} - {% set locale_switcher = stepup_locale_switcher('ss_switch_locale', {'return-url': app.request.uri}) %} + {% set locale_switcher = stepup_locale_switcher(app.request.locale, 'ss_switch_locale', {'return-url': app.request.uri}) %} {{ form_start(locale_switcher, { attr: { class: 'form-inline' }}) }} {{ form_widget(locale_switcher.locale) }} {{ form_widget(locale_switcher.switch) }} diff --git a/composer.lock b/composer.lock index 7127e11d4..000fc6aa6 100644 --- a/composer.lock +++ b/composer.lock @@ -1754,12 +1754,12 @@ "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "c1f4fd18712aed612fb908f53cea6fe7ef2a0831" + "reference": "5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/c1f4fd18712aed612fb908f53cea6fe7ef2a0831", - "reference": "c1f4fd18712aed612fb908f53cea6fe7ef2a0831", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280", + "reference": "5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280", "shasum": "" }, "require": { @@ -1798,7 +1798,7 @@ "suaas", "surfnet" ], - "time": "2015-06-02 13:04:33" + "time": "2015-06-03 10:21:18" }, { "name": "surfnet/stepup-middleware-client-bundle", @@ -1810,7 +1810,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/929b8a75042ac129d91eb691d773f4cf41081ec1", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/28d2bef9b51c4eb89b02d6850cff564b2764b5b5", "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1", "shasum": "" }, diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php index 4474b58aa..0598c5c69 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php @@ -33,6 +33,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'horizontal_label_class' => 'sr-only', 'required' => true, 'choice_list' => CountryCodeListing::asChoiceList(), + 'preferred_choices' => [CountryCodeListing::PREFERRED_CHOICE], 'horizontal_input_wrapper_class' => 'foo', ]) ->add('subscriber', 'text', [ From 2394da9a8caad23ae0b0d2e04e2f8f049832b4c4 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 3 Jun 2015 14:15:32 +0200 Subject: [PATCH 19/36] Update call to OptRes::setAllowedTypes() to match new signature. --- .../SelfServiceBundle/Form/Type/AnchorType.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php index af185fc89..84da346ca 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/AnchorType.php @@ -45,9 +45,7 @@ public function configureOptions(OptionsResolver $resolver) $resolver->setRequired(['route']); - $resolver->setAllowedTypes([ - 'route' => 'string', - ]); + $resolver->setAllowedTypes('route', 'string'); } public function buildView(FormView $view, FormInterface $form, array $options) From 68c4000fe192a62cc95f9620f453bc6a1f5cab51 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 3 Jun 2015 16:42:07 +0200 Subject: [PATCH 20/36] Update SendSmsChallengeType, Command to use Country. --- composer.lock | 8 ++++---- .../SelfServiceBundle/Command/SendSmsChallengeCommand.php | 5 +++-- .../SelfServiceBundle/Form/Type/SendSmsChallengeType.php | 5 +++-- .../views/Registration/Sms/sendChallenge.html.twig | 2 +- .../SelfServiceBundle/Service/SmsSecondFactorService.php | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index 000fc6aa6..6803f71bb 100644 --- a/composer.lock +++ b/composer.lock @@ -1754,12 +1754,12 @@ "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280" + "reference": "21801cbe361f246fede06fc9895107ca2b221d0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280", - "reference": "5cce1b8bb5bc74955bdb8901dc93cd1fe41a2280", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/21801cbe361f246fede06fc9895107ca2b221d0d", + "reference": "21801cbe361f246fede06fc9895107ca2b221d0d", "shasum": "" }, "require": { @@ -1798,7 +1798,7 @@ "suaas", "surfnet" ], - "time": "2015-06-03 10:21:18" + "time": "2015-06-03 15:38:36" }, { "name": "surfnet/stepup-middleware-client-bundle", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsChallengeCommand.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsChallengeCommand.php index 0277f4da9..386272a62 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsChallengeCommand.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Command/SendSmsChallengeCommand.php @@ -18,14 +18,15 @@ namespace Surfnet\StepupSelfService\SelfServiceBundle\Command; +use Surfnet\StepupBundle\Value\PhoneNumber\Country; use Symfony\Component\Validator\Constraints as Assert; class SendSmsChallengeCommand { /** - * @var string + * @var Country */ - public $countryCode; + public $country; /** * @Assert\NotBlank(message="ss.send_sms_challenge_command.recipient.may_not_be_empty") diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php index 0598c5c69..8c2f6541d 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Form/Type/SendSmsChallengeType.php @@ -28,12 +28,13 @@ class SendSmsChallengeType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('countryCode', 'choice', [ + ->add('country', 'choice', [ 'label' => /** @Ignore */ 'country code', 'horizontal_label_class' => 'sr-only', 'required' => true, 'choice_list' => CountryCodeListing::asChoiceList(), - 'preferred_choices' => [CountryCodeListing::PREFERRED_CHOICE], + 'preferred_choices' => + ['Surfnet\StepupBundle\Value\PhoneNumber\CountryCodeListing', 'isPreferredChoice'], 'horizontal_input_wrapper_class' => 'foo', ]) ->add('subscriber', 'text', [ diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/Registration/Sms/sendChallenge.html.twig b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/Registration/Sms/sendChallenge.html.twig index a4c0626d0..941691332 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/Registration/Sms/sendChallenge.html.twig +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/Registration/Sms/sendChallenge.html.twig @@ -28,7 +28,7 @@
{{ form_errors(form) }}
- {{ form_widget(form.countryCode) }} + {{ form_widget(form.country) }}
{{ form_widget(form.subscriber) }} diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php index a85f0c297..ca3442523 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/SmsSecondFactorService.php @@ -104,7 +104,7 @@ public function clearSmsVerificationState() public function sendChallenge(SendSmsChallengeCommand $command) { $phoneNumber = new InternationalPhoneNumber( - new CountryCode($command->countryCode), + $command->country->getCountryCode(), new PhoneNumber($command->subscriber) ); From bf70cdc4b8953b4dda6e61a199fde63d454bb6a8 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 3 Jun 2015 18:32:41 +0200 Subject: [PATCH 21/36] Update Stepup bundles to dev-develop. --- composer.json | 4 ++-- composer.lock | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 9821ce76d..ab584e7d6 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ "surfnet/stepup-middleware-client-bundle": "dev-develop", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", - "surfnet/stepup-saml-bundle": "dev-maintenance/symfony-2.7", - "surfnet/stepup-bundle": "dev-maintenance/symfony-2.7", + "surfnet/stepup-saml-bundle": "dev-develop", + "surfnet/stepup-bundle": "dev-develop", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 6803f71bb..4ebc368d6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "aba03c59c6516d324567ca063a795453", + "hash": "48d2d005dd004fca6a6b2a87baaf664a", "packages": [ { "name": "beberlei/assert", @@ -1750,16 +1750,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-maintenance/symfony-2.7", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "21801cbe361f246fede06fc9895107ca2b221d0d" + "reference": "543596b5a3fa294e89a2b47dc53d8ecceb21ce36" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/21801cbe361f246fede06fc9895107ca2b221d0d", - "reference": "21801cbe361f246fede06fc9895107ca2b221d0d", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/543596b5a3fa294e89a2b47dc53d8ecceb21ce36", + "reference": "543596b5a3fa294e89a2b47dc53d8ecceb21ce36", "shasum": "" }, "require": { @@ -1798,7 +1798,7 @@ "suaas", "surfnet" ], - "time": "2015-06-03 15:38:36" + "time": "2015-06-03 16:28:41" }, { "name": "surfnet/stepup-middleware-client-bundle", @@ -1851,16 +1851,16 @@ }, { "name": "surfnet/stepup-saml-bundle", - "version": "dev-maintenance/symfony-2.7", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-saml-bundle.git", - "reference": "4e9457c627b2e01dde930f52d5bce0690179ba6b" + "reference": "410f74d707053162ff043f57fbc114ddfdb65cab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/4e9457c627b2e01dde930f52d5bce0690179ba6b", - "reference": "4e9457c627b2e01dde930f52d5bce0690179ba6b", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/410f74d707053162ff043f57fbc114ddfdb65cab", + "reference": "410f74d707053162ff043f57fbc114ddfdb65cab", "shasum": "" }, "require": { @@ -1894,7 +1894,7 @@ "stepup", "surfnet" ], - "time": "2015-06-02 12:25:57" + "time": "2015-06-03 15:15:11" }, { "name": "swiftmailer/swiftmailer", From b9f536a511ef341e7e4d7d23a9ede2a72ecbf226 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Thu, 11 Jun 2015 13:55:47 +0200 Subject: [PATCH 22/36] Move form errors from 'validators' domain to 'messages'. --- .../translations/messages.en_GB.xliff | 50 +++++++++++++++ .../translations/messages.nl_NL.xliff | 50 +++++++++++++++ .../translations/validators.en_GB.xliff | 62 ------------------- .../translations/validators.nl_NL.xliff | 62 ------------------- .../Resources/views/translations.twig | 20 +++--- 5 files changed, 110 insertions(+), 134 deletions(-) diff --git a/app/Resources/translations/messages.en_GB.xliff b/app/Resources/translations/messages.en_GB.xliff index bf02f492b..f912728a4 100644 --- a/app/Resources/translations/messages.en_GB.xliff +++ b/app/Resources/translations/messages.en_GB.xliff @@ -149,6 +149,46 @@ ss.form.ss_verify_sms_challenge.text.challenge Code + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_expired + Your code has expired. Please request a new code. + + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_request_limit_reached + You have exceeded the limit of three codes; you can no longer request any more codes. Contact your helpdesk or try again later. + + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_response_incorrect + ss.prove_phone_possession.challenge_response_incorrect + + + Resources/views/translations.twig + ss.prove_phone_possession.incorrect_challenge_response + The code you entered does not match. Please try again or request a new code. + + + Resources/views/translations.twig + ss.prove_phone_possession.proof_of_possession_failed + The token could not be created due to unknown reasons. + + + Resources/views/translations.twig + ss.prove_phone_possession.send_sms_challenge_failed + Sending the code by text message failed. + + + Resources/views/translations.twig + ss.prove_phone_possession.too_many_attempts + You have exceeded the limit of ten attempts; you can no longer attempt verification of any more codes. Contact your helpdesk or try again later. + + + Resources/views/translations.twig + ss.prove_yubikey_possession.proof_of_possession_failed + The token could not be created due to unknown reasons. + views/Registration/emailVerificationEmailSent.html.twig ss.registration.email_verification_email_sent.text.email_verification_has_been_sent @@ -497,6 +537,16 @@ An e-mail with your activation code has been sent to the e-mail address %email%. ss.second_factor_list.header.type Token + + Resources/views/translations.twig + ss.verify_yubikey_command.otp.otp_invalid + This Yubikey code was invalid. Please try again. + + + Resources/views/translations.twig + ss.verify_yubikey_command.otp.verification_error + The verification of the Yubikey code failed due to unknown reasons. Try again. + Form/Type/SwitchLocaleType.php stepup_middleware_client.form.switch_locale.switch diff --git a/app/Resources/translations/messages.nl_NL.xliff b/app/Resources/translations/messages.nl_NL.xliff index f12e643ba..fd9d2da48 100644 --- a/app/Resources/translations/messages.nl_NL.xliff +++ b/app/Resources/translations/messages.nl_NL.xliff @@ -149,6 +149,46 @@ ss.form.ss_verify_sms_challenge.text.challenge Code + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_expired + Uw code is verlopen. Vraag een nieuwe code aan. + + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_request_limit_reached + U heeft de limiet van drie codes bereikt; u kunt geen codes meer aanvragen. Neem contact op met uw helpdesk of probeer het later nog eens. + + + Resources/views/translations.twig + ss.prove_phone_possession.challenge_response_incorrect + ss.prove_phone_possession.challenge_response_incorrect + + + Resources/views/translations.twig + ss.prove_phone_possession.incorrect_challenge_response + De ingevoerde code is onjuist. Probeer het nog eens, of vraag een nieuwe code op. + + + Resources/views/translations.twig + ss.prove_phone_possession.proof_of_possession_failed + Het token kon wegens een onbekende reden niet aangemaakt worden. + + + Resources/views/translations.twig + ss.prove_phone_possession.send_sms_challenge_failed + Het versturen van de code per SMS is mislukt. + + + Resources/views/translations.twig + ss.prove_phone_possession.too_many_attempts + U heeft de limiet van tien pogingen bereikt; u kunt geen codes meer verifiëren. Neem contact op met uw helpdesk of probeer het later nog eens. + + + Resources/views/translations.twig + ss.prove_yubikey_possession.proof_of_possession_failed + Het token kon wegens een onbekende reden niet aangemaakt worden. + views/Registration/emailVerificationEmailSent.html.twig ss.registration.email_verification_email_sent.text.email_verification_has_been_sent @@ -496,6 +536,16 @@ Er is een e-mail met activatiecode gestuurd naar het e-mailadres %email%. Volg d ss.second_factor_list.header.type Token + + Resources/views/translations.twig + ss.verify_yubikey_command.otp.otp_invalid + Deze Yubikey code was ongeldig. Probeer het nog eens. + + + Resources/views/translations.twig + ss.verify_yubikey_command.otp.verification_error + Het verifiëren van de Yubikey-code is wegens een onbekende reden niet gelukt. Probeer het opnieuw. + Form/Type/SwitchLocaleType.php stepup_middleware_client.form.switch_locale.switch diff --git a/app/Resources/translations/validators.en_GB.xliff b/app/Resources/translations/validators.en_GB.xliff index f33b44771..1d0c633a8 100644 --- a/app/Resources/translations/validators.en_GB.xliff +++ b/app/Resources/translations/validators.en_GB.xliff @@ -182,46 +182,6 @@ middleware_client.dto.vetted_second_factor.type.must_not_be_blank middleware_client.dto.vetted_second_factor.type.must_not_be_blank - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_expired - Your code has expired. Please request a new code. - - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_request_limit_reached - You have exceeded the limit of three codes; you can no longer request any more codes. Contact your helpdesk or try again later. - - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_response_incorrect - ss.prove_phone_possession.challenge_response_incorrect - - - Resources/views/translations.twig - ss.prove_phone_possession.incorrect_challenge_response - The code you entered does not match. Please try again or request a new code. - - - Resources/views/translations.twig - ss.prove_phone_possession.proof_of_possession_failed - The token could not be created due to unknown reasons. - - - Resources/views/translations.twig - ss.prove_phone_possession.send_sms_challenge_failed - Sending the code by text message failed. - - - Resources/views/translations.twig - ss.prove_phone_possession.too_many_attempts - You have exceeded the limit of ten attempts; you can no longer attempt verification of any more codes. Contact your helpdesk or try again later. - - - Resources/views/translations.twig - ss.prove_yubikey_possession.proof_of_possession_failed - The token could not be created due to unknown reasons. - ss.revoke_own_second_factor_command.identity_id.must_be_string ss.revoke_own_second_factor_command.identity_id.must_be_string @@ -242,18 +202,6 @@ ss.send_sms_challenge_command.recipient.must_be_string SMS challenge recipient must be string. - - ss.send_sms_command.recipient.may_not_be_empty - SMS recipient may not be empty. - - - ss.send_sms_command.recipient.must_be_string - SMS recipient must be string. - - - ss.send_sms_command.recipient.must_consist_of_digits - SMS recipient may consist of digits only. - ss.verify_sms_challenge_command.challenge.may_not_be_empty SMS challenge may not be empty. @@ -270,16 +218,6 @@ ss.verify_yubikey_command.otp.must_be_string Yubikey OTP must be string. - - Resources/views/translations.twig - ss.verify_yubikey_command.otp.otp_invalid - This Yubikey code was invalid. Please try again. - - - Resources/views/translations.twig - ss.verify_yubikey_command.otp.verification_error - The verification of the Yubikey code failed due to unknown reasons. Try again. - diff --git a/app/Resources/translations/validators.nl_NL.xliff b/app/Resources/translations/validators.nl_NL.xliff index 48d76b9ee..9755cc8af 100644 --- a/app/Resources/translations/validators.nl_NL.xliff +++ b/app/Resources/translations/validators.nl_NL.xliff @@ -182,46 +182,6 @@ middleware_client.dto.vetted_second_factor.type.must_not_be_blank middleware_client.dto.vetted_second_factor.type.must_not_be_blank - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_expired - Uw code is verlopen. Vraag een nieuwe code aan. - - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_request_limit_reached - U heeft de limiet van drie codes bereikt; u kunt geen codes meer aanvragen. Neem contact op met uw helpdesk of probeer het later nog eens. - - - Resources/views/translations.twig - ss.prove_phone_possession.challenge_response_incorrect - ss.prove_phone_possession.challenge_response_incorrect - - - Resources/views/translations.twig - ss.prove_phone_possession.incorrect_challenge_response - De ingevoerde code is onjuist. Probeer het nog eens, of vraag een nieuwe code op. - - - Resources/views/translations.twig - ss.prove_phone_possession.proof_of_possession_failed - Het token kon wegens een onbekende reden niet aangemaakt worden. - - - Resources/views/translations.twig - ss.prove_phone_possession.send_sms_challenge_failed - Het versturen van de code per SMS is mislukt. - - - Resources/views/translations.twig - ss.prove_phone_possession.too_many_attempts - U heeft de limiet van tien pogingen bereikt; u kunt geen codes meer verifiëren. Neem contact op met uw helpdesk of probeer het later nog eens. - - - Resources/views/translations.twig - ss.prove_yubikey_possession.proof_of_possession_failed - Het token kon wegens een onbekende reden niet aangemaakt worden. - ss.revoke_own_second_factor_command.identity_id.must_be_string ss.revoke_own_second_factor_command.identity_id.must_be_string @@ -242,18 +202,6 @@ ss.send_sms_challenge_command.recipient.must_be_string SMS challenge recipient must be string. - - ss.send_sms_command.recipient.may_not_be_empty - SMS recipient may not be empty. - - - ss.send_sms_command.recipient.must_be_string - SMS recipient must be string. - - - ss.send_sms_command.recipient.must_consist_of_digits - SMS recipient may consist of digits only. - ss.verify_sms_challenge_command.challenge.may_not_be_empty SMS challenge may not be empty. @@ -270,16 +218,6 @@ ss.verify_yubikey_command.otp.must_be_string Yubikey OTP must be string. - - Resources/views/translations.twig - ss.verify_yubikey_command.otp.otp_invalid - Deze Yubikey code was ongeldig. Probeer het nog eens. - - - Resources/views/translations.twig - ss.verify_yubikey_command.otp.verification_error - Het verifiëren van de Yubikey-code is wegens een onbekende reden niet gelukt. Probeer het opnieuw. - diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig index de1dc8fd3..02e0c9148 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig @@ -16,20 +16,20 @@ {{ 'ss.registration.selector.tiqr.button.use'|trans }} {# SmsController form errors #} -{{ 'ss.prove_phone_possession.send_sms_challenge_failed'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.proof_of_possession_failed'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.incorrect_challenge_response'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.challenge_request_limit_reached'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.challenge_expired'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.too_many_attempts'|trans({}, 'validators') }} +{{ 'ss.prove_phone_possession.send_sms_challenge_failed'|trans }} +{{ 'ss.prove_phone_possession.proof_of_possession_failed'|trans }} +{{ 'ss.prove_phone_possession.incorrect_challenge_response'|trans }} +{{ 'ss.prove_phone_possession.challenge_request_limit_reached'|trans }} +{{ 'ss.prove_phone_possession.challenge_expired'|trans }} +{{ 'ss.prove_phone_possession.too_many_attempts'|trans }} {# SmsController flash messages #} {{ 'ss.registration.sms.alert.no_verification_state'|trans }} {# YubikeyController from errors #} -{{ 'ss.verify_yubikey_command.otp.otp_invalid'|trans({}, 'validators') }} -{{ 'ss.verify_yubikey_command.otp.verification_error'|trans({}, 'validators') }} -{{ 'ss.prove_phone_possession.challenge_response_incorrect'|trans({}, 'validators') }} -{{ 'ss.prove_yubikey_possession.proof_of_possession_failed'|trans({}, 'validators') }} +{{ 'ss.verify_yubikey_command.otp.otp_invalid'|trans }} +{{ 'ss.verify_yubikey_command.otp.verification_error'|trans }} +{{ 'ss.prove_phone_possession.challenge_response_incorrect'|trans }} +{{ 'ss.prove_yubikey_possession.proof_of_possession_failed'|trans }} {# SecondFactorController list #} {{ 'ss.second_factor.list.text.vetted'|trans }} From b1504e03c9e9a636a172d446c6dd4aadeed96cef Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Thu, 11 Jun 2015 14:28:33 +0200 Subject: [PATCH 23/36] Translate other missing translation keys. --- .../translations/messages.en_GB.xliff | 4 ++-- .../translations/messages.nl_NL.xliff | 4 ++-- .../translations/validators.en_GB.xliff | 24 +++++++++++++++++-- .../translations/validators.nl_NL.xliff | 24 +++++++++++++++++-- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/app/Resources/translations/messages.en_GB.xliff b/app/Resources/translations/messages.en_GB.xliff index f912728a4..7db24691f 100644 --- a/app/Resources/translations/messages.en_GB.xliff +++ b/app/Resources/translations/messages.en_GB.xliff @@ -162,7 +162,7 @@ Resources/views/translations.twig ss.prove_phone_possession.challenge_response_incorrect - ss.prove_phone_possession.challenge_response_incorrect + The code you entered does not match the code you received. Resources/views/translations.twig @@ -443,7 +443,7 @@ Resources/views/translations.twig ss.second_factor.list.text.unverified - ss.second_factor.list.text.unverified + You are still to prove your possession of the following token. Resources/views/translations.twig diff --git a/app/Resources/translations/messages.nl_NL.xliff b/app/Resources/translations/messages.nl_NL.xliff index fd9d2da48..f37781ee9 100644 --- a/app/Resources/translations/messages.nl_NL.xliff +++ b/app/Resources/translations/messages.nl_NL.xliff @@ -162,7 +162,7 @@ Resources/views/translations.twig ss.prove_phone_possession.challenge_response_incorrect - ss.prove_phone_possession.challenge_response_incorrect + De code die je ingevoerd hebt komt niet overeen met de code die je hebt ontvangen. Resources/views/translations.twig @@ -442,7 +442,7 @@ Resources/views/translations.twig ss.second_factor.list.text.unverified - ss.second_factor.list.text.unverified + Van het volgende token moet het bezit nog bewezen worden. Resources/views/translations.twig diff --git a/app/Resources/translations/validators.en_GB.xliff b/app/Resources/translations/validators.en_GB.xliff index 1d0c633a8..1d68d3cd5 100644 --- a/app/Resources/translations/validators.en_GB.xliff +++ b/app/Resources/translations/validators.en_GB.xliff @@ -184,11 +184,11 @@ ss.revoke_own_second_factor_command.identity_id.must_be_string - ss.revoke_own_second_factor_command.identity_id.must_be_string + Identity ID must be a string ss.revoke_own_second_factor_command.second_factor_id.must_be_string - ss.revoke_own_second_factor_command.second_factor_id.must_be_string + Second factor ID must be a string ss.send_sms_challenge_command.recipient.may_not_be_empty @@ -218,6 +218,26 @@ ss.verify_yubikey_command.otp.must_be_string Yubikey OTP must be string. + + stepup.send_sms_command.recipient.may_not_be_empty + Please enter your phone number + + + stepup.send_sms_command.recipient.must_be_string + SMS recipient must be a string + + + stepup.send_sms_command.recipient.must_consist_of_digits + Your phone number may only consist of digits + + + stepup.verify_possession_of_phone_command.challenge.may_not_be_empty + Please enter the code you received + + + stepup.verify_possession_of_phone_command.challenge.must_be_string + SMS challenge must be a string + diff --git a/app/Resources/translations/validators.nl_NL.xliff b/app/Resources/translations/validators.nl_NL.xliff index 9755cc8af..12ac5bb5b 100644 --- a/app/Resources/translations/validators.nl_NL.xliff +++ b/app/Resources/translations/validators.nl_NL.xliff @@ -184,11 +184,11 @@ ss.revoke_own_second_factor_command.identity_id.must_be_string - ss.revoke_own_second_factor_command.identity_id.must_be_string + Identity ID must be a string ss.revoke_own_second_factor_command.second_factor_id.must_be_string - ss.revoke_own_second_factor_command.second_factor_id.must_be_string + Second factor ID must be a string ss.send_sms_challenge_command.recipient.may_not_be_empty @@ -218,6 +218,26 @@ ss.verify_yubikey_command.otp.must_be_string Yubikey OTP must be string. + + stepup.send_sms_command.recipient.may_not_be_empty + Vul alstublieft het telefoonnummer in + + + stepup.send_sms_command.recipient.must_be_string + SMS recipient must be a string + + + stepup.send_sms_command.recipient.must_consist_of_digits + Het telefoonnummer mag enkel uit cijfers bestaan + + + stepup.verify_possession_of_phone_command.challenge.may_not_be_empty + Vul alstublieft de code in die u heeft ontvangen + + + stepup.verify_possession_of_phone_command.challenge.must_be_string + SMS challenge must be a string + From 26f04c483ece05716be9c02762cc3f57ca05c7a3 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Tue, 16 Jun 2015 15:50:56 +0200 Subject: [PATCH 24/36] Upgrade Sensio DistributionBundle to suppress deprecation messages --- composer.json | 2 +- composer.lock | 31 +++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index ab584e7d6..99f353f21 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", - "sensio/distribution-bundle": "~3.0", + "sensio/distribution-bundle": "^3.0.21", "sensio/framework-extra-bundle": "~3.0", "incenteev/composer-parameter-handler": "~2.0", "nelmio/security-bundle": "~1.4", diff --git a/composer.lock b/composer.lock index 4ebc368d6..2e4bfa178 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "48d2d005dd004fca6a6b2a87baaf664a", + "hash": "71535f2296cfa353cccb1163f2ec97c8", "packages": [ { "name": "beberlei/assert", @@ -1190,7 +1190,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/0b467cf9e3de5b80cb7830dc758265204a5fcde5", + "url": "https://api.github.com/repos/phiamo/MopaBootstrapBundle/zipball/4d4b6291b47fc70491a4f92105be39d6bcccbb95", "reference": "818b0f47ebd352559950e9a64431ff9472e8a9dd", "shasum": "" }, @@ -1489,29 +1489,36 @@ }, { "name": "sensio/distribution-bundle", - "version": "v3.0.8", + "version": "v3.0.30", "target-dir": "Sensio/Bundle/DistributionBundle", "source": { "type": "git", "url": "https://github.com/sensiolabs/SensioDistributionBundle.git", - "reference": "bc5e96bb4faf6bee7121085951d11b89488952f5" + "reference": "f1758b30096202aeede61f79a1dffd69da091517" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/bc5e96bb4faf6bee7121085951d11b89488952f5", - "reference": "bc5e96bb4faf6bee7121085951d11b89488952f5", + "url": "https://api.github.com/repos/sensiolabs/SensioDistributionBundle/zipball/f1758b30096202aeede61f79a1dffd69da091517", + "reference": "f1758b30096202aeede61f79a1dffd69da091517", "shasum": "" }, "require": { "php": ">=5.3.3", "sensiolabs/security-checker": "~2.0", "symfony/class-loader": "~2.2", - "symfony/form": "~2.2", "symfony/framework-bundle": "~2.3", - "symfony/process": "~2.2", + "symfony/process": "~2.2" + }, + "require-dev": { + "symfony/form": "~2.2", "symfony/validator": "~2.2", "symfony/yaml": "~2.2" }, + "suggest": { + "symfony/form": "If you want to use the configurator", + "symfony/validator": "If you want to use the configurator", + "symfony/yaml": "If you want to use the configurator" + }, "type": "symfony-bundle", "extra": { "branch-alias": { @@ -1538,7 +1545,7 @@ "configuration", "distribution" ], - "time": "2014-11-03 21:16:34" + "time": "2015-06-05 22:32:22" }, { "name": "sensio/framework-extra-bundle", @@ -1758,7 +1765,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/543596b5a3fa294e89a2b47dc53d8ecceb21ce36", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/23f703e235cf2408311d359754bd767432dcb5b1", "reference": "543596b5a3fa294e89a2b47dc53d8ecceb21ce36", "shasum": "" }, @@ -1810,7 +1817,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/28d2bef9b51c4eb89b02d6850cff564b2764b5b5", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/541df9564a8680b6001b0c18a8b01b74f6013158", "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1", "shasum": "" }, @@ -1859,7 +1866,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/410f74d707053162ff043f57fbc114ddfdb65cab", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/05e7adbb0ae123b8b433948aa564a187486b1c64", "reference": "410f74d707053162ff043f57fbc114ddfdb65cab", "shasum": "" }, From 92ec8788347913e9b85d1a556ae13128d3cc4c1f Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 17 Jun 2015 10:51:49 +0200 Subject: [PATCH 25/36] Format JSON to syslog --- app/config/logging.yml | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/config/logging.yml b/app/config/logging.yml index 574e34dc5..945481941 100644 --- a/app/config/logging.yml +++ b/app/config/logging.yml @@ -10,4 +10,4 @@ monolog: type: syslog ident: stepup-selfservice facility: user - + formatter: surfnet_stepup.monolog.json_formatter diff --git a/composer.lock b/composer.lock index 2e4bfa178..ec580e081 100644 --- a/composer.lock +++ b/composer.lock @@ -1426,12 +1426,12 @@ "version": "2.8.0", "source": { "type": "git", - "url": "https://github.com/ramsey/uuid.git", + "url": "https://github.com/ramsey/rhumsaa-uuid.git", "reference": "cca98c652cac412c9c2f109c69e5532f313435fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/cca98c652cac412c9c2f109c69e5532f313435fc", + "url": "https://api.github.com/repos/ramsey/rhumsaa-uuid/zipball/cca98c652cac412c9c2f109c69e5532f313435fc", "reference": "cca98c652cac412c9c2f109c69e5532f313435fc", "shasum": "" }, @@ -1761,12 +1761,12 @@ "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "543596b5a3fa294e89a2b47dc53d8ecceb21ce36" + "reference": "b11ce75c7f00b64b8b000846db6ef1d56dcd490c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/23f703e235cf2408311d359754bd767432dcb5b1", - "reference": "543596b5a3fa294e89a2b47dc53d8ecceb21ce36", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/b11ce75c7f00b64b8b000846db6ef1d56dcd490c", + "reference": "b11ce75c7f00b64b8b000846db6ef1d56dcd490c", "shasum": "" }, "require": { @@ -1805,7 +1805,7 @@ "suaas", "surfnet" ], - "time": "2015-06-03 16:28:41" + "time": "2015-06-17 08:48:36" }, { "name": "surfnet/stepup-middleware-client-bundle", From 049d3d7e948fa874015200dc706471b89bec1791 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Wed, 17 Jun 2015 11:47:37 +0200 Subject: [PATCH 26/36] Format log messages to JSON in file logs as well --- app/config/config_dev.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml index 91e0ead64..cfe93935f 100644 --- a/app/config/config_dev.yml +++ b/app/config/config_dev.yml @@ -39,11 +39,13 @@ monolog: handler: logfile level: NOTICE path: %kernel.logs_dir%/%kernel.environment%.log + formatter: surfnet_stepup.monolog.json_formatter main_debuglog: type: stream handler: logfile level: DEBUG path: "%kernel.logs_dir%/%kernel.environment%.debug.log" + formatter: surfnet_stepup.monolog.json_formatter graylog: type: gelf publisher: { hostname: %graylog_hostname% } From 9a3ccdf47ddd78d1eb421474c48eff657d0e096a Mon Sep 17 00:00:00 2001 From: DRvanR Date: Thu, 18 Jun 2015 13:49:32 +0200 Subject: [PATCH 27/36] Use new version of UpdateIdentityCommand --- composer.json | 2 +- composer.lock | 14 +++++++------- .../SelfServiceBundle/Service/IdentityService.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 99f353f21..4851f1097 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "fortawesome/font-awesome": "~4.2.0", "jms/translation-bundle": "~1.1.0", "jms/di-extra-bundle": "~1.4.0", - "surfnet/stepup-middleware-client-bundle": "dev-develop", + "surfnet/stepup-middleware-client-bundle": "dev-feature/send-institution-with-update-identity-command", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", diff --git a/composer.lock b/composer.lock index ec580e081..e01eb38a9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "71535f2296cfa353cccb1163f2ec97c8", + "hash": "517ae233c2509d6b0879849721942bd8", "packages": [ { "name": "beberlei/assert", @@ -1765,7 +1765,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/b11ce75c7f00b64b8b000846db6ef1d56dcd490c", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/10a75d6bafb65fa233e64236047d67aa37850b3b", "reference": "b11ce75c7f00b64b8b000846db6ef1d56dcd490c", "shasum": "" }, @@ -1809,16 +1809,16 @@ }, { "name": "surfnet/stepup-middleware-client-bundle", - "version": "dev-develop", + "version": "dev-feature/send-institution-with-update-identity-command", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-Middleware-clientbundle.git", - "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1" + "reference": "31f0e00c536aa186514f5bdfc1ebad88e90b4131" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/541df9564a8680b6001b0c18a8b01b74f6013158", - "reference": "929b8a75042ac129d91eb691d773f4cf41081ec1", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/31f0e00c536aa186514f5bdfc1ebad88e90b4131", + "reference": "31f0e00c536aa186514f5bdfc1ebad88e90b4131", "shasum": "" }, "require": { @@ -1854,7 +1854,7 @@ "Apache-2.0" ], "description": "Symfony2 bundle for consuming the Step-up Middleware API.", - "time": "2015-06-01 15:00:06" + "time": "2015-06-18 11:24:53" }, { "name": "surfnet/stepup-saml-bundle", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php index e99cd0d1c..0545827ed 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/IdentityService.php @@ -157,7 +157,7 @@ public function createIdentity(Identity $identity) */ public function updateIdentity(Identity $identity) { - $command = new UpdateIdentityCommand($identity->id); + $command = new UpdateIdentityCommand($identity->id, $identity->institution); $command->email = $identity->email; $command->commonName = $identity->commonName; From 762fbfda344f61756948f077fcb1c0aaa0e25345 Mon Sep 17 00:00:00 2001 From: DRvanR Date: Thu, 18 Jun 2015 14:07:19 +0200 Subject: [PATCH 28/36] Revert middlewareclientbundle to dev-develop --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 4851f1097..99f353f21 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "fortawesome/font-awesome": "~4.2.0", "jms/translation-bundle": "~1.1.0", "jms/di-extra-bundle": "~1.4.0", - "surfnet/stepup-middleware-client-bundle": "dev-feature/send-institution-with-update-identity-command", + "surfnet/stepup-middleware-client-bundle": "dev-develop", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", diff --git a/composer.lock b/composer.lock index e01eb38a9..8d0004240 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "517ae233c2509d6b0879849721942bd8", + "hash": "71535f2296cfa353cccb1163f2ec97c8", "packages": [ { "name": "beberlei/assert", @@ -1809,16 +1809,16 @@ }, { "name": "surfnet/stepup-middleware-client-bundle", - "version": "dev-feature/send-institution-with-update-identity-command", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-Middleware-clientbundle.git", - "reference": "31f0e00c536aa186514f5bdfc1ebad88e90b4131" + "reference": "1cd3513f26a6df7dbce83188e6aa92fcba51bcc7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/31f0e00c536aa186514f5bdfc1ebad88e90b4131", - "reference": "31f0e00c536aa186514f5bdfc1ebad88e90b4131", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/1cd3513f26a6df7dbce83188e6aa92fcba51bcc7", + "reference": "1cd3513f26a6df7dbce83188e6aa92fcba51bcc7", "shasum": "" }, "require": { @@ -1854,7 +1854,7 @@ "Apache-2.0" ], "description": "Symfony2 bundle for consuming the Step-up Middleware API.", - "time": "2015-06-18 11:24:53" + "time": "2015-06-18 12:00:16" }, { "name": "surfnet/stepup-saml-bundle", From 58f304ae9ae19a71a0405c91eda3a4a852f00ed2 Mon Sep 17 00:00:00 2001 From: DRvanR Date: Thu, 18 Jun 2015 14:19:23 +0200 Subject: [PATCH 29/36] Remove the "no second factors yet" flash message --- .../SelfServiceBundle/Controller/EntryPointController.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php index 993d29be9..665bfc4c0 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php @@ -32,8 +32,6 @@ public function decideSecondFactorFlowAction() if ($service->doSecondFactorsExistForIdentity($identity->id)) { return $this->redirect($this->generateUrl('ss_second_factor_list')); } else { - $this->get('session')->getFlashBag()->add('notice', 'ss.registration.selector.alert.no_second_factors_yet'); - return $this->redirect( $this->generateUrl('ss_registration_display_types') ); From f841bac00ba6cb94f442cae7ee73440ebc400738 Mon Sep 17 00:00:00 2001 From: DRvanR Date: Thu, 18 Jun 2015 14:20:53 +0200 Subject: [PATCH 30/36] Remove Translations --- app/Resources/translations/messages.en_GB.xliff | 5 ----- app/Resources/translations/messages.nl_NL.xliff | 7 +------ .../SelfServiceBundle/Resources/views/translations.twig | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/app/Resources/translations/messages.en_GB.xliff b/app/Resources/translations/messages.en_GB.xliff index 7db24691f..2ae9e2680 100644 --- a/app/Resources/translations/messages.en_GB.xliff +++ b/app/Resources/translations/messages.en_GB.xliff @@ -274,11 +274,6 @@ ss.registration.registration_email_sent.title.list_of_ras Location to activate your token - - Resources/views/translations.twig - ss.registration.selector.alert.no_second_factors_yet - You do not have any security tokens yet. - Resources/views/translations.twig ss.registration.selector.sms.alt diff --git a/app/Resources/translations/messages.nl_NL.xliff b/app/Resources/translations/messages.nl_NL.xliff index f37781ee9..06ed1d50d 100644 --- a/app/Resources/translations/messages.nl_NL.xliff +++ b/app/Resources/translations/messages.nl_NL.xliff @@ -274,11 +274,6 @@ ss.registration.registration_email_sent.title.list_of_ras Locatie om je token te activeren - - Resources/views/translations.twig - ss.registration.selector.alert.no_second_factors_yet - Je hebt nog geen token geregistreerd. - Resources/views/translations.twig ss.registration.selector.sms.alt @@ -447,7 +442,7 @@ Resources/views/translations.twig ss.second_factor.list.text.verified - Het volgende token is geregistreerd voor jouw account, maar nog niet geactiveerd. + Het volgende token is geregistreerd voor jouw account, maar nog niet geactiveerd. Er is een e-mail met activatiecode gestuurd naar het e-mailadres %email%. Volg de instructies uit de e-mail om je token te activeren. diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig index 02e0c9148..7ef9a12e0 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/translations.twig @@ -1,6 +1,3 @@ -{# EntryPointController #} -{{ 'ss.registration.selector.alert.no_second_factors_yet'|trans }} - {# src/Surfnet/StepupSelfService/SelfServiceBundle/Resources/views/Registration/partial/secondFactor.html.twig #} {{ 'ss.registration.selector.sms.alt'|trans }} {{ 'ss.registration.selector.sms.title'|trans }} From 6b0e5025fcc91eb61f94b07866419102f587e036 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Thu, 18 Jun 2015 16:46:16 +0200 Subject: [PATCH 31/36] Supply numeric Yubikey public IDs to the middleware --- composer.json | 2 +- composer.lock | 13 +++++++------ .../Service/YubikeySecondFactorService.php | 4 +++- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 99f353f21..c786baad7 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-develop", + "surfnet/stepup-bundle": "dev-feature/numeric-yubikey-ids", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index 8d0004240..5392864ab 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "71535f2296cfa353cccb1163f2ec97c8", + "hash": "d9de1912001b8740a9fb137f4a2281ce", "packages": [ { "name": "beberlei/assert", @@ -1757,19 +1757,20 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-develop", + "version": "dev-feature/numeric-yubikey-ids", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "b11ce75c7f00b64b8b000846db6ef1d56dcd490c" + "reference": "7b9564d18e7426a52d2c4c80c3350e2a3ec1803d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/10a75d6bafb65fa233e64236047d67aa37850b3b", - "reference": "b11ce75c7f00b64b8b000846db6ef1d56dcd490c", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/7b9564d18e7426a52d2c4c80c3350e2a3ec1803d", + "reference": "7b9564d18e7426a52d2c4c80c3350e2a3ec1803d", "shasum": "" }, "require": { + "ext-gmp": "*", "ext-openssl": "*", "graylog2/gelf-php": "~1.1", "guzzlehttp/guzzle": "~4", @@ -1805,7 +1806,7 @@ "suaas", "surfnet" ], - "time": "2015-06-17 08:48:36" + "time": "2015-06-18 15:10:25" }, { "name": "surfnet/stepup-middleware-client-bundle", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php index 0730e2d93..d7dd5f2fe 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php @@ -18,6 +18,7 @@ namespace Surfnet\StepupSelfService\SelfServiceBundle\Service; +use Surfnet\StepupBundle\Value\YubikeyPublicId; use Surfnet\StepupMiddlewareClientBundle\Identity\Command\ProveYubikeyPossessionCommand; use Surfnet\StepupMiddlewareClientBundle\Uuid\Uuid; use Surfnet\StepupSelfService\SelfServiceBundle\Command\VerifyYubikeyOtpCommand; @@ -67,11 +68,12 @@ public function provePossession(VerifyYubikeyOtpCommand $command) } $secondFactorId = Uuid::generate(); + $yubikeyPublicId = YubikeyPublicId::fromModHex(substr($command->otp, 0, -32))->getYubikeyPublicId(); $provePossessionCommand = new ProveYubikeyPossessionCommand(); $provePossessionCommand->identityId = $command->identity; $provePossessionCommand->secondFactorId = $secondFactorId; - $provePossessionCommand->yubikeyPublicId = substr($command->otp, 0, 12); + $provePossessionCommand->yubikeyPublicId = $yubikeyPublicId; $result = $this->commandService->execute($provePossessionCommand); From ea43004633e4354d15b757e88c237045769e2d86 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Fri, 19 Jun 2015 11:51:10 +0200 Subject: [PATCH 32/36] Use StepupBundle's Otp and PublicId --- composer.lock | 8 ++++---- .../Service/YubikeySecondFactorService.php | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 5392864ab..9a1cbd697 100644 --- a/composer.lock +++ b/composer.lock @@ -1761,12 +1761,12 @@ "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "7b9564d18e7426a52d2c4c80c3350e2a3ec1803d" + "reference": "3a3e9501a6e799108012f302dde2332fd0b14c6c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/7b9564d18e7426a52d2c4c80c3350e2a3ec1803d", - "reference": "7b9564d18e7426a52d2c4c80c3350e2a3ec1803d", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/3a3e9501a6e799108012f302dde2332fd0b14c6c", + "reference": "3a3e9501a6e799108012f302dde2332fd0b14c6c", "shasum": "" }, "require": { @@ -1806,7 +1806,7 @@ "suaas", "surfnet" ], - "time": "2015-06-18 15:10:25" + "time": "2015-06-19 09:16:41" }, { "name": "surfnet/stepup-middleware-client-bundle", diff --git a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php index d7dd5f2fe..3dc4a824c 100644 --- a/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php +++ b/src/Surfnet/StepupSelfService/SelfServiceBundle/Service/YubikeySecondFactorService.php @@ -18,6 +18,7 @@ namespace Surfnet\StepupSelfService\SelfServiceBundle\Service; +use Surfnet\StepupBundle\Value\YubikeyOtp; use Surfnet\StepupBundle\Value\YubikeyPublicId; use Surfnet\StepupMiddlewareClientBundle\Identity\Command\ProveYubikeyPossessionCommand; use Surfnet\StepupMiddlewareClientBundle\Uuid\Uuid; @@ -68,12 +69,14 @@ public function provePossession(VerifyYubikeyOtpCommand $command) } $secondFactorId = Uuid::generate(); - $yubikeyPublicId = YubikeyPublicId::fromModHex(substr($command->otp, 0, -32))->getYubikeyPublicId(); + + $otp = YubikeyOtp::fromString($command->otp); + $publicId = YubikeyPublicId::fromOtp($otp); $provePossessionCommand = new ProveYubikeyPossessionCommand(); $provePossessionCommand->identityId = $command->identity; $provePossessionCommand->secondFactorId = $secondFactorId; - $provePossessionCommand->yubikeyPublicId = $yubikeyPublicId; + $provePossessionCommand->yubikeyPublicId = $publicId->getYubikeyPublicId(); $result = $this->commandService->execute($provePossessionCommand); From 2911ba6edc55ec076d95d091fdbf3e3e352bfc75 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Fri, 19 Jun 2015 11:59:01 +0200 Subject: [PATCH 33/36] Update StepupBundle --- composer.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.lock b/composer.lock index 9a1cbd697..92bbe91ae 100644 --- a/composer.lock +++ b/composer.lock @@ -1761,12 +1761,12 @@ "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "3a3e9501a6e799108012f302dde2332fd0b14c6c" + "reference": "d9e483840e0394355289b5a6974e4deaccfdeb56" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/3a3e9501a6e799108012f302dde2332fd0b14c6c", - "reference": "3a3e9501a6e799108012f302dde2332fd0b14c6c", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/d9e483840e0394355289b5a6974e4deaccfdeb56", + "reference": "d9e483840e0394355289b5a6974e4deaccfdeb56", "shasum": "" }, "require": { @@ -1806,7 +1806,7 @@ "suaas", "surfnet" ], - "time": "2015-06-19 09:16:41" + "time": "2015-06-19 09:55:51" }, { "name": "surfnet/stepup-middleware-client-bundle", From 6775b50a09a5891a0309443c7e546b2402acca8f Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Fri, 19 Jun 2015 12:15:52 +0200 Subject: [PATCH 34/36] Update StepupBundle --- composer.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.lock b/composer.lock index 92bbe91ae..b23906fef 100644 --- a/composer.lock +++ b/composer.lock @@ -1867,7 +1867,7 @@ }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/05e7adbb0ae123b8b433948aa564a187486b1c64", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/cdad0d6597f2577ec7c0c69bb3099a6d2ddc45ad", "reference": "410f74d707053162ff043f57fbc114ddfdb65cab", "shasum": "" }, From 5336fb965bac04dd30af8ccb3c3c2b9cca998927 Mon Sep 17 00:00:00 2001 From: Reinier Kip Date: Fri, 19 Jun 2015 13:36:37 +0200 Subject: [PATCH 35/36] Switch StepupBundle to the develop branch --- composer.json | 2 +- composer.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index c786baad7..99f353f21 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-feature/numeric-yubikey-ids", + "surfnet/stepup-bundle": "dev-develop", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index b23906fef..df2b78f08 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "d9de1912001b8740a9fb137f4a2281ce", + "hash": "71535f2296cfa353cccb1163f2ec97c8", "packages": [ { "name": "beberlei/assert", @@ -1757,16 +1757,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-feature/numeric-yubikey-ids", + "version": "dev-develop", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "d9e483840e0394355289b5a6974e4deaccfdeb56" + "reference": "38e51b79287948932774ce44942a0877b1aeb23e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/d9e483840e0394355289b5a6974e4deaccfdeb56", - "reference": "d9e483840e0394355289b5a6974e4deaccfdeb56", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/38e51b79287948932774ce44942a0877b1aeb23e", + "reference": "38e51b79287948932774ce44942a0877b1aeb23e", "shasum": "" }, "require": { @@ -1806,7 +1806,7 @@ "suaas", "surfnet" ], - "time": "2015-06-19 09:55:51" + "time": "2015-06-19 11:32:32" }, { "name": "surfnet/stepup-middleware-client-bundle", From 8910bf3a79f46959160147fef939bd103ecb1bbd Mon Sep 17 00:00:00 2001 From: DRvanR Date: Fri, 19 Jun 2015 14:03:36 +0200 Subject: [PATCH 36/36] Stabilize dependencies --- composer.json | 6 +++--- composer.lock | 37 +++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 99f353f21..7366c4451 100644 --- a/composer.json +++ b/composer.json @@ -23,11 +23,11 @@ "fortawesome/font-awesome": "~4.2.0", "jms/translation-bundle": "~1.1.0", "jms/di-extra-bundle": "~1.4.0", - "surfnet/stepup-middleware-client-bundle": "dev-develop", + "surfnet/stepup-middleware-client-bundle": "^1.0", "guzzlehttp/guzzle": "~4", "simplesamlphp/saml2": "dev-master", - "surfnet/stepup-saml-bundle": "dev-develop", - "surfnet/stepup-bundle": "dev-develop", + "surfnet/stepup-saml-bundle": "^1.0", + "surfnet/stepup-bundle": "^1.0", "symfony/swiftmailer-bundle": "~2.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index df2b78f08..91763727a 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "71535f2296cfa353cccb1163f2ec97c8", + "hash": "6eb470b6b29c044302244eb5bd458886", "packages": [ { "name": "beberlei/assert", @@ -1757,16 +1757,16 @@ }, { "name": "surfnet/stepup-bundle", - "version": "dev-develop", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-bundle.git", - "reference": "38e51b79287948932774ce44942a0877b1aeb23e" + "reference": "7e201ac7f5b870a142a85d3a44f1e2ebb8b31933" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/38e51b79287948932774ce44942a0877b1aeb23e", - "reference": "38e51b79287948932774ce44942a0877b1aeb23e", + "url": "https://api.github.com/repos/SURFnet/Stepup-bundle/zipball/7e201ac7f5b870a142a85d3a44f1e2ebb8b31933", + "reference": "7e201ac7f5b870a142a85d3a44f1e2ebb8b31933", "shasum": "" }, "require": { @@ -1806,20 +1806,20 @@ "suaas", "surfnet" ], - "time": "2015-06-19 11:32:32" + "time": "2015-06-19 11:44:48" }, { "name": "surfnet/stepup-middleware-client-bundle", - "version": "dev-develop", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-Middleware-clientbundle.git", - "reference": "1cd3513f26a6df7dbce83188e6aa92fcba51bcc7" + "reference": "c4c35c790acb4be964980e64b461c03a034e2066" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/1cd3513f26a6df7dbce83188e6aa92fcba51bcc7", - "reference": "1cd3513f26a6df7dbce83188e6aa92fcba51bcc7", + "url": "https://api.github.com/repos/SURFnet/Stepup-Middleware-clientbundle/zipball/c4c35c790acb4be964980e64b461c03a034e2066", + "reference": "c4c35c790acb4be964980e64b461c03a034e2066", "shasum": "" }, "require": { @@ -1855,20 +1855,20 @@ "Apache-2.0" ], "description": "Symfony2 bundle for consuming the Step-up Middleware API.", - "time": "2015-06-18 12:00:16" + "time": "2015-06-19 09:21:37" }, { "name": "surfnet/stepup-saml-bundle", - "version": "dev-develop", + "version": "1.0.0", "source": { "type": "git", "url": "https://github.com/SURFnet/Stepup-saml-bundle.git", - "reference": "410f74d707053162ff043f57fbc114ddfdb65cab" + "reference": "8f336c442d3dc9d045bff498c4b27de65213565a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/cdad0d6597f2577ec7c0c69bb3099a6d2ddc45ad", - "reference": "410f74d707053162ff043f57fbc114ddfdb65cab", + "url": "https://api.github.com/repos/SURFnet/Stepup-saml-bundle/zipball/8f336c442d3dc9d045bff498c4b27de65213565a", + "reference": "8f336c442d3dc9d045bff498c4b27de65213565a", "shasum": "" }, "require": { @@ -1902,7 +1902,7 @@ "stepup", "surfnet" ], - "time": "2015-06-03 15:15:11" + "time": "2015-06-19 10:11:01" }, { "name": "swiftmailer/swiftmailer", @@ -4271,10 +4271,7 @@ "minimum-stability": "stable", "stability-flags": { "mopa/bootstrap-bundle": 20, - "surfnet/stepup-middleware-client-bundle": 20, - "simplesamlphp/saml2": 20, - "surfnet/stepup-saml-bundle": 20, - "surfnet/stepup-bundle": 20 + "simplesamlphp/saml2": 20 }, "prefer-stable": false, "prefer-lowest": false,