diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2016-08-29 19:19:44 +0200 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2016-09-05 08:51:13 +0200 |
commit | 8acb734854484e2ffd235929f6e7d0ba4c273844 (patch) | |
tree | 3269bc6cc60b51d4fd507d91e8eca3a4ecc262cd /core | |
parent | 8b484eedf029b8e1a9dcef0efb09db381888c4b0 (diff) | |
download | nextcloud-server-8acb734854484e2ffd235929f6e7d0ba4c273844.tar.gz nextcloud-server-8acb734854484e2ffd235929f6e7d0ba4c273844.zip |
add 2fa backup codes app
* add backup codes app unit tests
* add integration tests for the backup codes app
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/TwoFactorChallengeController.php | 9 | ||||
-rw-r--r-- | core/css/styles.css | 2 | ||||
-rw-r--r-- | core/shipped.json | 2 | ||||
-rw-r--r-- | core/templates/twofactorselectchallenge.php | 10 | ||||
-rw-r--r-- | core/templates/twofactorshowchallenge.php | 10 |
5 files changed, 30 insertions, 3 deletions
diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php index 48dea062812..b2614138123 100644 --- a/core/Controller/TwoFactorChallengeController.php +++ b/core/Controller/TwoFactorChallengeController.php @@ -82,9 +82,11 @@ class TwoFactorChallengeController extends Controller { public function selectChallenge($redirect_url) { $user = $this->userSession->getUser(); $providers = $this->twoFactorManager->getProviders($user); + $backupProvider = $this->twoFactorManager->getBackupProvider($user); $data = [ 'providers' => $providers, + 'backupProvider' => $backupProvider, 'redirect_url' => $redirect_url, 'logout_attribute' => $this->getLogoutAttribute(), ]; @@ -107,6 +109,12 @@ class TwoFactorChallengeController extends Controller { return new RedirectResponse($this->urlGenerator->linkToRoute('core.TwoFactorChallenge.selectChallenge')); } + $backupProvider = $this->twoFactorManager->getBackupProvider($user); + if (!is_null($backupProvider) && $backupProvider->getId() === $provider->getId()) { + // Don't show the backup provider link if we're already showing that provider's challenge + $backupProvider = null; + } + if ($this->session->exists('two_factor_auth_error')) { $this->session->remove('two_factor_auth_error'); $error = true; @@ -118,6 +126,7 @@ class TwoFactorChallengeController extends Controller { $data = [ 'error' => $error, 'provider' => $provider, + 'backupProvider' => $backupProvider, 'logout_attribute' => $this->getLogoutAttribute(), 'template' => $tmpl->fetchPage(), ]; diff --git a/core/css/styles.css b/core/css/styles.css index 25bc2d086d5..efc49e02a17 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -45,7 +45,7 @@ body { border: none !important; } -.two-factor-cancel { +.two-factor-link { display: inline-block; padding: 12px; color: rgba(255, 255, 255, .75); diff --git a/core/shipped.json b/core/shipped.json index f944d9d4c11..0ddaf68eb64 100644 --- a/core/shipped.json +++ b/core/shipped.json @@ -28,6 +28,7 @@ "survey_client", "systemtags", "templateeditor", + "twofactor_backupcodes", "theming", "updatenotification", "user_external", @@ -39,6 +40,7 @@ "files", "dav", "federatedfilesharing", + "twofactor_backupcodes", "workflowengine" ] } diff --git a/core/templates/twofactorselectchallenge.php b/core/templates/twofactorselectchallenge.php index 1948499e604..5cfba8bcb47 100644 --- a/core/templates/twofactorselectchallenge.php +++ b/core/templates/twofactorselectchallenge.php @@ -19,4 +19,12 @@ </ul> </p> </div> -<a class="two-factor-cancel" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel log in')) ?></a> +<a class="two-factor-link" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel log in')) ?></a> +<?php if (!is_null($_['backupProvider'])): ?> +<a class="two-factor-link" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', + [ + 'challengeProviderId' => $_['backupProvider']->getId(), + 'redirect_url' => $_['redirect_url'], + ] + )) ?>"><?php p($l->t('Use backup code')) ?></a> +<?php endif; diff --git a/core/templates/twofactorshowchallenge.php b/core/templates/twofactorshowchallenge.php index fb161921675..197de8a288e 100644 --- a/core/templates/twofactorshowchallenge.php +++ b/core/templates/twofactorshowchallenge.php @@ -16,4 +16,12 @@ $template = $_['template']; <?php endif; ?> <?php print_unescaped($template); ?> </div> -<a class="two-factor-cancel" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel log in')) ?></a> +<a class="two-factor-link" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel log in')) ?></a> +<?php if (!is_null($_['backupProvider'])): ?> +<a class="two-factor-link" href="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.showChallenge', + [ + 'challengeProviderId' => $_['backupProvider']->getId(), + 'redirect_url' => $_['redirect_url'], + ] + )) ?>"><?php p($l->t('Use backup code')) ?></a> +<?php endif; |