Skip to content

Commit 929aaaa

Browse files
authored
Merge pull request #27929 from nextcloud/enh/allowSsoToProvideSecret
Allow SSO authentication to provide a user secret
2 parents 6a6ce39 + 21b3e87 commit 929aaaa

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
'OCP\\Authentication\\Exceptions\\PasswordUnavailableException' => $baseDir . '/lib/public/Authentication/Exceptions/PasswordUnavailableException.php',
9191
'OCP\\Authentication\\IAlternativeLogin' => $baseDir . '/lib/public/Authentication/IAlternativeLogin.php',
9292
'OCP\\Authentication\\IApacheBackend' => $baseDir . '/lib/public/Authentication/IApacheBackend.php',
93+
'OCP\\Authentication\\IProvideUserSecretBackend' => $baseDir . '/lib/public/Authentication/IProvideUserSecretBackend.php',
9394
'OCP\\Authentication\\LoginCredentials\\ICredentials' => $baseDir . '/lib/public/Authentication/LoginCredentials/ICredentials.php',
9495
'OCP\\Authentication\\LoginCredentials\\IStore' => $baseDir . '/lib/public/Authentication/LoginCredentials/IStore.php',
9596
'OCP\\Authentication\\TwoFactorAuth\\ALoginSetupController' => $baseDir . '/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
123123
'OCP\\Authentication\\Exceptions\\PasswordUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Authentication/Exceptions/PasswordUnavailableException.php',
124124
'OCP\\Authentication\\IAlternativeLogin' => __DIR__ . '/../../..' . '/lib/public/Authentication/IAlternativeLogin.php',
125125
'OCP\\Authentication\\IApacheBackend' => __DIR__ . '/../../..' . '/lib/public/Authentication/IApacheBackend.php',
126+
'OCP\\Authentication\\IProvideUserSecretBackend' => __DIR__ . '/../../..' . '/lib/public/Authentication/IProvideUserSecretBackend.php',
126127
'OCP\\Authentication\\LoginCredentials\\ICredentials' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/ICredentials.php',
127128
'OCP\\Authentication\\LoginCredentials\\IStore' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/IStore.php',
128129
'OCP\\Authentication\\TwoFactorAuth\\ALoginSetupController' => __DIR__ . '/../../..' . '/lib/public/Authentication/TwoFactorAuth/ALoginSetupController.php',

lib/private/legacy/OC_User.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,11 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
178178
}
179179
$userSession->setLoginName($uid);
180180
$request = OC::$server->getRequest();
181-
$userSession->createSessionToken($request, $uid, $uid);
181+
$password = null;
182+
if ($backend instanceof \OCP\Authentication\IProvideUserSecretBackend) {
183+
$password = $backend->getCurrentUserSecret();
184+
}
185+
$userSession->createSessionToken($request, $uid, $uid, $password);
182186
$userSession->createRememberMeToken($userSession->getUser());
183187
// setup the filesystem
184188
OC_Util::setupFS($uid);
@@ -191,7 +195,7 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
191195
'post_login',
192196
[
193197
'uid' => $uid,
194-
'password' => null,
198+
'password' => $password,
195199
'isTokenLogin' => false,
196200
]
197201
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2021, MichaIng <[email protected]>
4+
*
5+
* @author MichaIng <[email protected]>
6+
*
7+
* @license AGPL-3.0
8+
*
9+
* This code is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License, version 3,
11+
* as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License, version 3,
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>
20+
*
21+
*/
22+
// use OCP namespace for all classes that are considered public.
23+
// This means that they should be used by apps instead of the internal ownCloud classes
24+
25+
namespace OCP\Authentication;
26+
27+
/**
28+
* Interface IProvideUserSecretBackend
29+
*
30+
* @since 23.0.0
31+
*/
32+
interface IProvideUserSecretBackend {
33+
34+
/**
35+
* Optionally returns a stable per-user secret. This secret is for
36+
* instance used to secure file encryption keys.
37+
* @return string
38+
* @since 23.0.0
39+
*/
40+
public function getCurrentUserSecret(): string;
41+
}

0 commit comments

Comments
 (0)