summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2016-06-09 15:01:57 +0200
committerMorris Jobke <hey@morrisjobke.de>2016-06-09 15:01:57 +0200
commitfc3ad7d5f7acb018329b22d5120c03cd07feecd6 (patch)
treeefa1958da450eb72ae93bb54dd3fe23a21aba682 /core
parentb928305bb30ade5635a203408090f4ae376278ba (diff)
parentbb67acff9137a96f8ed002da6c8edf7aae8a7ec8 (diff)
downloadnextcloud-server-fc3ad7d5f7acb018329b22d5120c03cd07feecd6.tar.gz
nextcloud-server-fc3ad7d5f7acb018329b22d5120c03cd07feecd6.zip
Merge pull request #25 from nextcloud/downstream-160608
Downstream 2016-06-08
Diffstat (limited to 'core')
-rw-r--r--core/Application.php3
-rw-r--r--core/Command/Encryption/DecryptAll.php14
-rw-r--r--core/Controller/TokenController.php36
-rw-r--r--core/Controller/TwoFactorChallengeController.php9
-rw-r--r--core/Middleware/TwoFactorMiddleware.php5
-rw-r--r--core/css/styles.css4
-rw-r--r--core/templates/twofactorselectchallenge.php3
-rw-r--r--core/templates/twofactorshowchallenge.php1
8 files changed, 60 insertions, 15 deletions
diff --git a/core/Application.php b/core/Application.php
index 25e2fa76273..a87917b626a 100644
--- a/core/Application.php
+++ b/core/Application.php
@@ -120,7 +120,8 @@ class Application extends App {
$c->query('AppName'),
$c->query('Request'),
$c->query('UserManager'),
- $c->query('OC\Authentication\Token\DefaultTokenProvider'),
+ $c->query('ServerContainer')->query('OC\Authentication\Token\IProvider'),
+ $c->query('TwoFactorAuthManager'),
$c->query('SecureRandom')
);
});
diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php
index 8d7d26f3d23..d060918a506 100644
--- a/core/Command/Encryption/DecryptAll.php
+++ b/core/Command/Encryption/DecryptAll.php
@@ -111,7 +111,8 @@ class DecryptAll extends Command {
$this->addArgument(
'user',
InputArgument::OPTIONAL,
- 'user for which you want to decrypt all files (optional)'
+ 'user for which you want to decrypt all files (optional)',
+ ''
);
}
@@ -127,8 +128,16 @@ class DecryptAll extends Command {
return;
}
+ $uid = $input->getArgument('user');
+ //FIXME WHEN https://github.com/owncloud/core/issues/24994 is fixed
+ if ($uid === null) {
+ $message = 'your ownCloud';
+ } else {
+ $message = "$uid's account";
+ }
+
$output->writeln("\n");
- $output->writeln('You are about to start to decrypt all files stored in your ownCloud.');
+ $output->writeln("You are about to start to decrypt all files stored in $message.");
$output->writeln('It will depend on the encryption module and your setup if this is possible.');
$output->writeln('Depending on the number and size of your files this can take some time');
$output->writeln('Please make sure that no user access his files during this process!');
@@ -140,6 +149,7 @@ class DecryptAll extends Command {
$result = $this->decryptAll->decryptAll($input, $output, $user);
if ($result === false) {
$output->writeln(' aborted.');
+ $output->writeln('Server side encryption remains enabled');
$this->config->setAppValue('core', 'encryption_enabled', 'yes');
}
$this->resetSingleUserAndTrashbin();
diff --git a/core/Controller/TokenController.php b/core/Controller/TokenController.php
index 42cc29bad10..13b1db9044a 100644
--- a/core/Controller/TokenController.php
+++ b/core/Controller/TokenController.php
@@ -1,4 +1,5 @@
<?php
+
/**
* @author Christoph Wurst <christoph@owncloud.com>
*
@@ -23,22 +24,27 @@ namespace OC\Core\Controller;
use OC\AppFramework\Http;
use OC\Authentication\Token\DefaultTokenProvider;
+use OC\Authentication\Token\IProvider;
use OC\Authentication\Token\IToken;
-use OC\User\Manager;
+use OC\Authentication\TwoFactorAuth\Manager as TwoFactorAuthManager;
+use OC\User\Manager as UserManager;
+use OCA\User_LDAP\User\Manager;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
-use OCP\AppFramework\Http\Response;
use OCP\IRequest;
use OCP\Security\ISecureRandom;
class TokenController extends Controller {
- /** @var Manager */
+ /** @var UserManager */
private $userManager;
- /** @var DefaultTokenProvider */
+ /** @var IProvider */
private $tokenProvider;
+ /** @var TwoFactorAuthManager */
+ private $twoFactorAuthManager;
+
/** @var ISecureRandom */
private $secureRandom;
@@ -49,12 +55,12 @@ class TokenController extends Controller {
* @param DefaultTokenProvider $tokenProvider
* @param ISecureRandom $secureRandom
*/
- public function __construct($appName, IRequest $request, Manager $userManager, DefaultTokenProvider $tokenProvider,
- ISecureRandom $secureRandom) {
+ public function __construct($appName, IRequest $request, UserManager $userManager, IProvider $tokenProvider, TwoFactorAuthManager $twoFactorAuthManager, ISecureRandom $secureRandom) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
$this->tokenProvider = $tokenProvider;
$this->secureRandom = $secureRandom;
+ $this->twoFactorAuthManager = $twoFactorAuthManager;
}
/**
@@ -70,18 +76,26 @@ class TokenController extends Controller {
*/
public function generateToken($user, $password, $name = 'unknown client') {
if (is_null($user) || is_null($password)) {
- $response = new Response();
+ $response = new JSONResponse();
$response->setStatus(Http::STATUS_UNPROCESSABLE_ENTITY);
return $response;
}
- $loginResult = $this->userManager->checkPassword($user, $password);
- if ($loginResult === false) {
- $response = new Response();
+ $loginName = $user;
+ $user = $this->userManager->checkPassword($loginName, $password);
+ if ($user === false) {
+ $response = new JSONResponse();
$response->setStatus(Http::STATUS_UNAUTHORIZED);
return $response;
}
+
+ if ($this->twoFactorAuthManager->isTwoFactorAuthenticated($user)) {
+ $resp = new JSONResponse();
+ $resp->setStatus(Http::STATUS_UNAUTHORIZED);
+ return $resp;
+ }
+
$token = $this->secureRandom->generate(128);
- $this->tokenProvider->generateToken($token, $loginResult->getUID(), $user, $password, $name, IToken::PERMANENT_TOKEN);
+ $this->tokenProvider->generateToken($token, $user->getUID(), $loginName, $password, $name, IToken::PERMANENT_TOKEN);
return [
'token' => $token,
];
diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php
index 499898de3bc..edaf3378cd8 100644
--- a/core/Controller/TwoFactorChallengeController.php
+++ b/core/Controller/TwoFactorChallengeController.php
@@ -62,6 +62,13 @@ class TwoFactorChallengeController extends Controller {
}
/**
+ * @return string
+ */
+ protected function getLogoutAttribute() {
+ return \OC_User::getLogoutAttribute();
+ }
+
+ /**
* @NoAdminRequired
* @NoCSRFRequired
*
@@ -75,6 +82,7 @@ class TwoFactorChallengeController extends Controller {
$data = [
'providers' => $providers,
'redirect_url' => $redirect_url,
+ 'logout_attribute' => $this->getLogoutAttribute(),
];
return new TemplateResponse($this->appName, 'twofactorselectchallenge', $data, 'guest');
}
@@ -106,6 +114,7 @@ class TwoFactorChallengeController extends Controller {
$data = [
'error' => $error,
'provider' => $provider,
+ 'logout_attribute' => $this->getLogoutAttribute(),
'template' => $tmpl->fetchPage(),
];
return new TemplateResponse($this->appName, 'twofactorshowchallenge', $data, 'guest');
diff --git a/core/Middleware/TwoFactorMiddleware.php b/core/Middleware/TwoFactorMiddleware.php
index aa82897ad46..0bad8a2c40f 100644
--- a/core/Middleware/TwoFactorMiddleware.php
+++ b/core/Middleware/TwoFactorMiddleware.php
@@ -82,6 +82,11 @@ class TwoFactorMiddleware extends Middleware {
return;
}
+ if ($controller instanceof \OC\Core\Controller\LoginController && $methodName === 'logout') {
+ // Don't block the logout page, to allow canceling the 2FA
+ return;
+ }
+
if ($this->userSession->isLoggedIn()) {
$user = $this->userSession->getUser();
diff --git a/core/css/styles.css b/core/css/styles.css
index df9509baa19..475c4fa3fb3 100644
--- a/core/css/styles.css
+++ b/core/css/styles.css
@@ -38,6 +38,10 @@ body {
display: inline-block;
}
+a.two-factor-cancel {
+ color: #fff;
+}
+
.float-spinner {
height: 32px;
display: none;
diff --git a/core/templates/twofactorselectchallenge.php b/core/templates/twofactorselectchallenge.php
index 14d599aab3e..4209beac4e6 100644
--- a/core/templates/twofactorselectchallenge.php
+++ b/core/templates/twofactorselectchallenge.php
@@ -18,4 +18,5 @@
</li>
<?php endforeach; ?>
</ul>
-</fieldset> \ No newline at end of file
+</fieldset>
+<a class="two-factor-cancel" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel login')) ?></a>
diff --git a/core/templates/twofactorshowchallenge.php b/core/templates/twofactorshowchallenge.php
index 66f5ed312ec..c5ee9aca4b4 100644
--- a/core/templates/twofactorshowchallenge.php
+++ b/core/templates/twofactorshowchallenge.php
@@ -17,3 +17,4 @@ $template = $_['template'];
<span class="warning"><?php p($l->t('An error occured while verifying the token')); ?></span>
<?php endif; ?>
<?php print_unescaped($template); ?>
+<a class="two-factor-cancel" <?php print_unescaped($_['logout_attribute']); ?>><?php p($l->t('Cancel login')) ?></a>