diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-12-21 21:23:12 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-21 21:23:12 +0300 |
commit | 35c76b4910aba9a3bf16ce2c930513286d2dfabf (patch) | |
tree | 454fc6d5a4010b624aac83f209bb2ebeaf1c6abf /plugins/TwoFactorAuth | |
parent | 94b4c656b731e8c56b0fc51456bde61e34562d1c (diff) |
QR code library adds several new files to vendor dir that is breaking build (#13889)
* replace qrcode library
* use lower correctness
* lets use best correctness
* fix some tests
* fix tests
Diffstat (limited to 'plugins/TwoFactorAuth')
9 files changed, 39 insertions, 33 deletions
diff --git a/plugins/TwoFactorAuth/Controller.php b/plugins/TwoFactorAuth/Controller.php index 72bee05c88..fdbe4fb8ef 100644 --- a/plugins/TwoFactorAuth/Controller.php +++ b/plugins/TwoFactorAuth/Controller.php @@ -152,9 +152,6 @@ class Controller extends \Piwik\Plugin\Controller public function onLoginSetupTwoFactorAuth() { // called when 2fa is required, but user has not yet set up 2fa - $this->validator->checkCanUseTwoFa(); - $this->validator->check2FaNotEnabled(); - $this->validator->check2FaIsRequired(); return $this->setupTwoFactorAuth($standalone = true); } @@ -249,7 +246,7 @@ class Controller extends \Piwik\Plugin\Controller $view->AccessErrorString = $accessErrorString; $view->isAlreadyUsing2fa = $this->twoFa->isUserUsingTwoFactorAuthentication($login); $view->newSecret = $secret; - $view->authImage = $this->getQRUrl($view->description, $view->gatitle); + $view->twoFaBarCodeSetupUrl = $this->getTwoFaBarCodeSetupUrl($secret); $view->codes = $this->recoveryCodeDao->getAllRecoveryCodesForLogin($login); $view->standalone = $standalone; @@ -294,15 +291,8 @@ class Controller extends \Piwik\Plugin\Controller )); } - public function showQrCode() + private function getTwoFaBarCodeSetupUrl($secret) { - $this->validator->checkCanUseTwoFa(); - - $session = $this->make2faSession(); - $secret = $session->secret; - if (empty($secret)) { - throw new Exception('Not available'); - } $title = $this->settings->twoFactorAuthTitle->getValue(); $descr = Piwik::getCurrentUserLogin(); @@ -311,10 +301,7 @@ class Controller extends \Piwik\Plugin\Controller $url .= '&issuer='.urlencode($title); } - $qrCode = new QrCode($url); - - header('Content-Type: '.$qrCode->getContentType()); - echo $qrCode->get(); + return $url; } protected function getQRUrl($description, $title) diff --git a/plugins/TwoFactorAuth/TwoFactorAuth.php b/plugins/TwoFactorAuth/TwoFactorAuth.php index e83599b8cd..6bfe0d9ac5 100644 --- a/plugins/TwoFactorAuth/TwoFactorAuth.php +++ b/plugins/TwoFactorAuth/TwoFactorAuth.php @@ -48,6 +48,7 @@ class TwoFactorAuth extends \Piwik\Plugin { $jsFiles[] = "plugins/TwoFactorAuth/javascripts/twofactorauth.js"; $jsFiles[] = "plugins/TwoFactorAuth/angularjs/setuptwofactor/setuptwofactor.controller.js"; + $jsFiles[] = "libs/bower_components/qrcode.js/qrcode.js"; } public function deleteRecoveryCodes($returnedValue, $params) diff --git a/plugins/TwoFactorAuth/angularjs/setuptwofactor/setuptwofactor.controller.js b/plugins/TwoFactorAuth/angularjs/setuptwofactor/setuptwofactor.controller.js index 66514e17ad..9055b8a7c9 100644 --- a/plugins/TwoFactorAuth/angularjs/setuptwofactor/setuptwofactor.controller.js +++ b/plugins/TwoFactorAuth/angularjs/setuptwofactor/setuptwofactor.controller.js @@ -37,6 +37,12 @@ } $timeout(function () { + + var qrcode = new QRCode(document.getElementById("qrcode"), { + text: window.twoFaBarCodeSetupUrl + }); + angular.element('#qrcode').attr('title', ''); // do not show secret on hover + angular.element('.backupRecoveryCode').click(function () { self.hasDownloadedRecoveryCode = true; $timeout(function () { @@ -51,4 +57,4 @@ } }); } -})();
\ No newline at end of file +})(); diff --git a/plugins/TwoFactorAuth/stylesheets/twofactorauth.less b/plugins/TwoFactorAuth/stylesheets/twofactorauth.less index 8e4465538b..747277de16 100644 --- a/plugins/TwoFactorAuth/stylesheets/twofactorauth.less +++ b/plugins/TwoFactorAuth/stylesheets/twofactorauth.less @@ -5,12 +5,21 @@ margin-left: 20px; } } +.setupTwoFactorAuthentication { + #qrcode { + width:256px; + height: 256px; + } +} + +.loginSection { + #qrcode, + .backupRecoveryCodesAlert { + margin-top: 16px; + } +} .userSettings2FA .twoFaStatusEnabled, .twoFactorSetupFinished .successMessage { color:#43a047; } - -.loginSection .backupRecoveryCodesAlert { - margin-top: 16px; -}
\ No newline at end of file diff --git a/plugins/TwoFactorAuth/templates/_setupTwoFactorAuth.twig b/plugins/TwoFactorAuth/templates/_setupTwoFactorAuth.twig index df16baef23..7409e63775 100644 --- a/plugins/TwoFactorAuth/templates/_setupTwoFactorAuth.twig +++ b/plugins/TwoFactorAuth/templates/_setupTwoFactorAuth.twig @@ -24,10 +24,10 @@ <p>{{ 'TwoFactorAuth_SetupAuthenticatorOnDeviceStep1'|translate }} <a rel="noreferrer noopener" href="https://github.com/andOTP/andOTP#downloads">andOTP</a>, <a rel="noreferrer noopener" href="https://authy.com/guides/github/">Authy</a>, <a rel="noreferrer noopener" href="https://support.1password.com/one-time-passwords/">1Password</a>, <a rel="noreferrer noopener" href="https://helpdesk.lastpass.com/multifactor-authentication-options/lastpass-authenticator/">LastPass Authenticator</a>, {{ 'General_Or'|translate }} <a rel="noreferrer noopener" href="https://support.google.com/accounts/answer/1066447">Google Authenticator</a>. </p> <p>{{ 'TwoFactorAuth_SetupAuthenticatorOnDeviceStep2'|translate('<a href="javascript:void(0)" onclick="piwikHelper.modalConfirm(\'#setupTwoFAsecretConfirm\')">', '</a>')|raw }}<br/> - <img id="qrcode" src="{{ authImage|raw }}"> - <br /> - <button ng-show="setup2fa.step == 2" ng-click="setup2fa.nextStep()" class="btn goToStep3">{{ 'General_Next'|translate }}</button> - </p> + <div id="qrcode" title=""></div> + <br /> + <button ng-show="setup2fa.step == 2" ng-click="setup2fa.nextStep()" class="btn goToStep3">{{ 'General_Next'|translate }}</button> + </p> </div> <a name="twoFactorStep3" id="twoFactorStep3" style="opacity: 0"></a> @@ -65,6 +65,9 @@ </div> </div> +<script type="text/javascript"> + window.twoFaBarCodeSetupUrl = {{ twoFaBarCodeSetupUrl|json_encode|raw }}; +</script> <div id="setupTwoFAsecretConfirm" class="ui-confirm"> <h2>{{ 'TwoFactorAuth_Your2FaAuthSecret'|translate }}</h2> diff --git a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step2.png b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step2.png index 542e76f94a..80b1b5f669 100644 --- a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step2.png +++ b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aa0c4bb2fc87e7cae1a94050e7db7227a2563a18deda4631e7652705ccfa7fb2 -size 137012 +oid sha256:38ff826e3a31aac524bd5199bc5559f2b464a3b613f070ba4fc7c6365fcd6d4e +size 146470 diff --git a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step3.png b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step3.png index 667a311b2a..218fbe102f 100644 --- a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step3.png +++ b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_forced_step3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b78696df8055d60c904b7e286c3e48139d1e029b80cd77a1055d4c2c825a9596 -size 176231 +oid sha256:0cacd1a674acb3d025a6967f2476b55847af196c62273a06e9a5f3aa77c74fe9 +size 185441 diff --git a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step2.png b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step2.png index 6140fb3007..474486f7df 100644 --- a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step2.png +++ b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step2.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ade3b15b8921bcbbe83b703d1434183458f0e4ad192d003adb087c0c19b8745b -size 93245 +oid sha256:f5a3d9c0bf5c0cacfbcf1b7062a9741a5f2b3cbe093448dd3ffac81202c84f3b +size 93330 diff --git a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step3.png b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step3.png index 82b5252fab..6960b50d5b 100644 --- a/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step3.png +++ b/plugins/TwoFactorAuth/tests/UI/expected-screenshots/TwoFactorAuth_twofa_setup_step3.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0522e7ddd0d587bbb1733f41c6e236bd8ae360abe323e1a10e70dd3d6efb0342 -size 121373 +oid sha256:ea30e34f67d85fad191e90f6d10f63275bd243a7357b020e9875babd1a2e2f47 +size 121508 |