Skip to content

Commit 32aafe6

Browse files
committed
Allow SSO authentication to provide a user secret
Implementing PR #24837 from immerda Signed-off-by: MichaIng <[email protected]>
1 parent ad6e975 commit 32aafe6

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
@@ -89,6 +89,7 @@
8989
'OCP\\Authentication\\Exceptions\\PasswordUnavailableException' => $baseDir . '/lib/public/Authentication/Exceptions/PasswordUnavailableException.php',
9090
'OCP\\Authentication\\IAlternativeLogin' => $baseDir . '/lib/public/Authentication/IAlternativeLogin.php',
9191
'OCP\\Authentication\\IApacheBackend' => $baseDir . '/lib/public/Authentication/IApacheBackend.php',
92+
'OCP\\Authentication\\IProvideUserSecretBackend' => $baseDir . '/lib/public/Authentication/IProvideUserSecretBackend.php',
9293
'OCP\\Authentication\\LoginCredentials\\ICredentials' => $baseDir . '/lib/public/Authentication/LoginCredentials/ICredentials.php',
9394
'OCP\\Authentication\\LoginCredentials\\IStore' => $baseDir . '/lib/public/Authentication/LoginCredentials/IStore.php',
9495
'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
@@ -118,6 +118,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
118118
'OCP\\Authentication\\Exceptions\\PasswordUnavailableException' => __DIR__ . '/../../..' . '/lib/public/Authentication/Exceptions/PasswordUnavailableException.php',
119119
'OCP\\Authentication\\IAlternativeLogin' => __DIR__ . '/../../..' . '/lib/public/Authentication/IAlternativeLogin.php',
120120
'OCP\\Authentication\\IApacheBackend' => __DIR__ . '/../../..' . '/lib/public/Authentication/IApacheBackend.php',
121+
'OCP\\Authentication\\IProvideUserSecretBackend' => __DIR__ . '/../../..' . '/lib/public/Authentication/IProvideUserSecretBackend.php',
121122
'OCP\\Authentication\\LoginCredentials\\ICredentials' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/ICredentials.php',
122123
'OCP\\Authentication\\LoginCredentials\\IStore' => __DIR__ . '/../../..' . '/lib/public/Authentication/LoginCredentials/IStore.php',
123124
'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
// setup the filesystem
183187
OC_Util::setupFS($uid);
184188
// first call the post_login hooks, the login-process needs to be
@@ -190,7 +194,7 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
190194
'post_login',
191195
[
192196
'uid' => $uid,
193-
'password' => null,
197+
'password' => $password,
194198
'isTokenLogin' => false,
195199
]
196200
);
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)