mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
oidc login
This commit is contained in:
parent
6cafd65690
commit
3d0b16600c
2 changed files with 20 additions and 11 deletions
|
|
@ -91,10 +91,19 @@ class SnappyMailHelper
|
||||||
*/
|
*/
|
||||||
if ($doLogin && $aCredentials[1] && $aCredentials[2]) {
|
if ($doLogin && $aCredentials[1] && $aCredentials[2]) {
|
||||||
try {
|
try {
|
||||||
|
$ocSession = \OC::$server->getSession();
|
||||||
|
if ($ocSession->get('is_oidc')) {
|
||||||
|
$pwd = new \SnappyMail\SensitiveString($aCredentials[1]);
|
||||||
|
$oAccount = $oActions->LoginProcess($aCredentials[1], $pwd);
|
||||||
|
if ($oAccount) {
|
||||||
|
$oActions->SetSignMeToken($oAccount);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2]);
|
$oAccount = $oActions->LoginProcess($aCredentials[1], $aCredentials[2]);
|
||||||
if ($oAccount && $oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DefaultOff) === \RainLoop\Enumerations\SignMeType::DefaultOn) {
|
if ($oAccount && $oConfig->Get('login', 'sign_me_auto', \RainLoop\Enumerations\SignMeType::DefaultOff) === \RainLoop\Enumerations\SignMeType::DefaultOn) {
|
||||||
$oActions->SetSignMeToken($oAccount);
|
$oActions->SetSignMeToken($oAccount);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// Login failure, reset password to prevent more attempts
|
// Login failure, reset password to prevent more attempts
|
||||||
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
|
$sUID = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
|
|
@ -140,22 +149,22 @@ class SnappyMailHelper
|
||||||
// If the current user ID is identical to login ID (not valid when using account switching),
|
// If the current user ID is identical to login ID (not valid when using account switching),
|
||||||
// this has the second priority.
|
// this has the second priority.
|
||||||
if ($ocSession['snappymail-nc-uid'] == $sUID) {
|
if ($ocSession['snappymail-nc-uid'] == $sUID) {
|
||||||
/*
|
|
||||||
// If OpenID Connect (OIDC) is enabled and used for login, use this.
|
// If OpenID Connect (OIDC) is enabled and used for login, use this.
|
||||||
// https://apps.nextcloud.com/apps/oidc_login
|
// https://apps.nextcloud.com/apps/oidc_login
|
||||||
// DISABLED https://github.com/the-djmaze/snappymail/issues/1420#issuecomment-1933045917
|
|
||||||
if ($config->getAppValue('snappymail', 'snappymail-autologin-oidc', false)) {
|
if ($config->getAppValue('snappymail', 'snappymail-autologin-oidc', false)) {
|
||||||
if ($ocSession->get('is_oidc')) {
|
if ($ocSession->get('is_oidc')) {
|
||||||
// IToken->getPassword() ???
|
// IToken->getPassword() ???
|
||||||
if ($sAccessToken = $ocSession->get('oidc_access_token')) {
|
if ($sAccessToken = $ocSession->get('oidc_access_token')) {
|
||||||
return [$sUID, 'oidc@nextcloud', $sAccessToken];
|
$sEmail = $config->getUserValue($sUID, 'settings', 'email');
|
||||||
|
return [$sUID, $sEmail, $sAccessToken];
|
||||||
}
|
}
|
||||||
\SnappyMail\Log::debug('Nextcloud', 'OIDC access_token missing');
|
\SnappyMail\Log::debug('Nextcloud', 'OIDC access_token missing');
|
||||||
} else {
|
} else {
|
||||||
\SnappyMail\Log::debug('Nextcloud', 'No OIDC login');
|
\SnappyMail\Log::debug('Nextcloud', 'No OIDC login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
// Only use the user's password in the current session if they have
|
// Only use the user's password in the current session if they have
|
||||||
// enabled auto-login using Nextcloud username or email address.
|
// enabled auto-login using Nextcloud username or email address.
|
||||||
$sEmail = '';
|
$sEmail = '';
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,13 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
|
|
||||||
$this->addTemplate('templates/PopupsNextcloudFiles.html');
|
$this->addTemplate('templates/PopupsNextcloudFiles.html');
|
||||||
$this->addTemplate('templates/PopupsNextcloudCalendars.html');
|
$this->addTemplate('templates/PopupsNextcloudCalendars.html');
|
||||||
/*
|
|
||||||
$this->addHook('login.credentials.step-2', 'loginCredentials2');
|
$this->addHook('login.credentials.step-2', 'loginCredentials2');
|
||||||
$this->addHook('login.credentials', 'loginCredentials');
|
$this->addHook('login.credentials', 'loginCredentials');
|
||||||
$this->addHook('imap.before-login', 'beforeLogin');
|
$this->addHook('imap.before-login', 'beforeLogin');
|
||||||
$this->addHook('smtp.before-login', 'beforeLogin');
|
$this->addHook('smtp.before-login', 'beforeLogin');
|
||||||
$this->addHook('sieve.before-login', 'beforeLogin');
|
$this->addHook('sieve.before-login', 'beforeLogin');
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
\SnappyMail\Log::debug('Nextcloud', 'NOT integrated');
|
\SnappyMail\Log::debug('Nextcloud', 'NOT integrated');
|
||||||
// \OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-no-embed');
|
// \OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-no-embed');
|
||||||
|
|
@ -87,7 +87,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
|
public function beforeLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
|
||||||
{
|
{
|
||||||
$oSettings->username = \OC::$server->getUserSession()->getUser()->getUID();
|
$oSettings->username = \OC::$server->getUserSession()->getUser()->getUID();
|
||||||
/*
|
|
||||||
// https://apps.nextcloud.com/apps/oidc_login
|
// https://apps.nextcloud.com/apps/oidc_login
|
||||||
// DISABLED https://github.com/the-djmaze/snappymail/issues/1420#issuecomment-1933045917
|
// DISABLED https://github.com/the-djmaze/snappymail/issues/1420#issuecomment-1933045917
|
||||||
if (\OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-autologin-oidc', false)
|
if (\OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-autologin-oidc', false)
|
||||||
|
|
@ -100,7 +100,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
|
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue