mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-26 16:26:44 +03:00
Redesign Nextcloud OIDC login #1420
This commit is contained in:
parent
66c9091b88
commit
59fea00a31
6 changed files with 20 additions and 6 deletions
|
|
@ -79,6 +79,8 @@ If your IMAP server only accepts usernames without a domain (for example the lda
|
|||
If the user sets his credentials for the mailbox in his personal account under "Settings -> Additional settings", these credentials are used by SnappyMail to login.
|
||||
If no personal credentials are defined the mail address of the Nextcloud user and his password are used by SnappyMail to login. SnappyMail will lookup the "Domain" settings for a configuration that meets the domain part of the mail address passed as username.
|
||||
|
||||
#### Option 4: Attempt to automatically login with OIDC when active
|
||||
|
||||
### Auto-connection for all Nextcloud users
|
||||
If your Nextcloud users base is synchronized with an email system, then it is possible that Nextcloud credentials could be used right away to access the centralized email system. In the SnappyMail admin settings, the Nextcloud administrator can then tick the "Automatically login with Nextcloud/Nextcloud user credentials" checkbox.
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class FetchController extends Controller {
|
|||
isset($_POST['snappymail-autologin']) ? '1' === $_POST['snappymail-autologin'] : false);
|
||||
$this->config->setAppValue('snappymail', 'snappymail-autologin-with-email',
|
||||
isset($_POST['snappymail-autologin']) ? '2' === $_POST['snappymail-autologin'] : false);
|
||||
$this->config->setAppValue('snappymail', 'snappymail-autologin-oidc', isset($_POST['snappymail-autologin-oidc']));
|
||||
$this->config->setAppValue('snappymail', 'snappymail-no-embed', isset($_POST['snappymail-no-embed']));
|
||||
} else {
|
||||
return new JSONResponse([
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class AdminSettings implements ISettings
|
|||
$keys = [
|
||||
'snappymail-autologin',
|
||||
'snappymail-autologin-with-email',
|
||||
'snappymail-autologin-oidc',
|
||||
'snappymail-no-embed'
|
||||
];
|
||||
$parameters = [];
|
||||
|
|
|
|||
|
|
@ -152,6 +152,12 @@ class SnappyMailHelper
|
|||
if ($sPassword) {
|
||||
$sPassword = static::decodePassword($sPassword, $sUID);
|
||||
}
|
||||
if ($config->getAppValue('snappymail', 'snappymail-autologin-oidc', false) && $ocSession->get('is_oidc')) {
|
||||
$sAccessToken = $ocSession->get('oidc_access_token');
|
||||
if ($sAccessToken) {
|
||||
$sPassword = $sAccessToken;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the user has set credentials for SnappyMail in their personal
|
||||
|
|
|
|||
|
|
@ -38,6 +38,13 @@
|
|||
</div>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<input id="snappymail-autologin-oidc" name="snappymail-autologin-oidc" type="checkbox" class="checkbox" <?php if ($_['snappymail-autologin-oidc']) echo 'checked="checked"'; ?>>
|
||||
<label for="snappymail-autologin-oidc">
|
||||
<?php echo($l->t('Attempt to automatically login with OIDC when active')); ?>
|
||||
</label>
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
<input id="snappymail-no-embed" name="snappymail-no-embed" type="checkbox" class="checkbox" <?php if ($_['snappymail-no-embed']) echo 'checked="checked"'; ?>>
|
||||
<label for="snappymail-no-embed">
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
RELEASE = '2024-02-05',
|
||||
CATEGORY = 'Integrations',
|
||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||
REQUIRED = '2.27.0';
|
||||
REQUIRED = '2.34.0';
|
||||
|
||||
public function Init() : void
|
||||
{
|
||||
|
|
@ -70,7 +70,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
|
||||
public function oidcLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
|
||||
{
|
||||
if ($this->Config()->Get('plugin', 'oidc', false)
|
||||
if (\OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-autologin-oidc', false)
|
||||
&& \OC::$server->getSession()->get('is_oidc')
|
||||
// && $oClient->supportsAuthType('OAUTHBEARER') // v2.28
|
||||
) {
|
||||
|
|
@ -219,7 +219,7 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
if ($sCustomEmail) {
|
||||
$sEmail = $sCustomEmail;
|
||||
}
|
||||
if ($this->Config()->Get('plugin', 'oidc', false)) {
|
||||
if ($config->getAppValue('snappymail', 'snappymail-autologin-oidc', false)) {
|
||||
if (\OC::$server->getSession()->get('is_oidc')) {
|
||||
$sEmail = "{$sUID}@nextcloud";
|
||||
$aResult['DevPassword'] = \OC::$server->getSession()->get('oidc_access_token');
|
||||
|
|
@ -333,9 +333,6 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(true),
|
||||
\RainLoop\Plugins\Property::NewInstance('calendar')->SetLabel('Enable "Put ICS in calendar"')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(false),
|
||||
\RainLoop\Plugins\Property::NewInstance('oidc')->SetLabel('Login with OIDC')
|
||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||
->SetDefaultValue(false)
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue