mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Nextcloud plugin integrate OIDC from #756
This commit is contained in:
parent
14ee6f1b5b
commit
a889fc262a
5 changed files with 38 additions and 2 deletions
|
|
@ -4,8 +4,8 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
{
|
{
|
||||||
const
|
const
|
||||||
NAME = 'Nextcloud',
|
NAME = 'Nextcloud',
|
||||||
VERSION = '2.22',
|
VERSION = '2.23',
|
||||||
RELEASE = '2023-03-28',
|
RELEASE = '2023-04-11',
|
||||||
CATEGORY = 'Integrations',
|
CATEGORY = 'Integrations',
|
||||||
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
DESCRIPTION = 'Integrate with Nextcloud v20+',
|
||||||
REQUIRED = '2.27.0';
|
REQUIRED = '2.27.0';
|
||||||
|
|
@ -34,6 +34,9 @@ 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('imap.before-login', 'oidcLogin');
|
||||||
|
$this->addHook('smtp.before-login', 'oidcLogin');
|
||||||
|
$this->addHook('sieve.before-login', 'oidcLogin');
|
||||||
} else {
|
} else {
|
||||||
// \OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-no-embed');
|
// \OC::$server->getConfig()->getAppValue('snappymail', 'snappymail-no-embed');
|
||||||
$this->addHook('main.content-security-policy', 'ContentSecurityPolicy');
|
$this->addHook('main.content-security-policy', 'ContentSecurityPolicy');
|
||||||
|
|
@ -62,6 +65,20 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
return static::IsIntegrated() && \OC::$server->getUserSession()->isLoggedIn();
|
return static::IsIntegrated() && \OC::$server->getUserSession()->isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function oidcLogin(\RainLoop\Model\Account $oAccount, \MailSo\Net\NetClient $oClient, \MailSo\Net\ConnectSettings $oSettings) : void
|
||||||
|
{
|
||||||
|
if ($this->Config()->Get('plugin', 'oidc', false)
|
||||||
|
&& \OC::$server->getSession()->get('is_oidc')
|
||||||
|
// && $oClient->supportsAuthType('OAUTHBEARER') // v2.28
|
||||||
|
) {
|
||||||
|
$sAccessToken = \OC::$server->getSession()->get('oidc_access_token');
|
||||||
|
if ($sAccessToken) {
|
||||||
|
$oSettings->Password = $sAccessToken;
|
||||||
|
\array_unshift($oSettings->SASLMechanisms, 'OAUTHBEARER');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
\OC::$server->getCalendarManager();
|
\OC::$server->getCalendarManager();
|
||||||
\OC::$server->getLDAPProvider();
|
\OC::$server->getLDAPProvider();
|
||||||
|
|
@ -254,6 +271,9 @@ class NextcloudPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||||
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
->SetDefaultValue(true),
|
->SetDefaultValue(true),
|
||||||
\RainLoop\Plugins\Property::NewInstance('calendar')->SetLabel('Enable "Put ICS in calendar"')
|
\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)
|
->SetType(\RainLoop\Enumerations\PluginPropertyType::BOOL)
|
||||||
->SetDefaultValue(false)
|
->SetDefaultValue(false)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@ class ImapClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsAuthType(string $sasl_type) : bool
|
||||||
|
{
|
||||||
|
return $this->hasCapability("AUTH={$sasl_type}");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,7 @@ abstract class NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract public function supportsAuthType(string $sasl_type) : bool;
|
||||||
// abstract public function Login(ConnectSettings $oSettings) : self;
|
// abstract public function Login(ConnectSettings $oSettings) : self;
|
||||||
abstract public function Logout() : void;
|
abstract public function Logout() : void;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,11 @@ class SieveClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsAuthType(string $sasl_type) : bool
|
||||||
|
{
|
||||||
|
return \in_array(\strtoupper($sasl_type), $this->aAuth);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ class SmtpClient extends \MailSo\Net\NetClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function supportsAuthType(string $sasl_type) : bool
|
||||||
|
{
|
||||||
|
return \in_array(\strtoupper($sasl_type), $this->aAuthTypes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
* @throws \MailSo\RuntimeException
|
* @throws \MailSo\RuntimeException
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue