Skip to content

Commit e347da0

Browse files
committed
Allow SSO authentication to provide a user secret
Implementing PR #24837 from immerda Signed-off-by: MichaIng <micha@dietpi.com>
1 parent 99a1468 commit e347da0

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
@@ -172,7 +172,11 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
172172
$userSession = \OC::$server->getUserSession();
173173
$userSession->setLoginName($uid);
174174
$request = OC::$server->getRequest();
175-
$userSession->createSessionToken($request, $uid, $uid);
175+
$password = null;
176+
if ($backend instanceof \OCP\Authentication\IProvideUserSecretBackend) {
177+
$password = $backend->getCurrentUserSecret();
178+
}
179+
$userSession->createSessionToken($request, $uid, $uid, $password);
176180
// setup the filesystem
177181
OC_Util::setupFS($uid);
178182
// first call the post_login hooks, the login-process needs to be
@@ -184,7 +188,7 @@ public static function loginWithApache(\OCP\Authentication\IApacheBackend $backe
184188
'post_login',
185189
[
186190
'uid' => $uid,
187-
'password' => '',
191+
'password' => $password ?? '',
188192
'isTokenLogin' => false,
189193
]
190194
);
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 <micha@dietpi.com>
4+
*
5+
* @author MichaIng <micha@dietpi.com>
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)