Merge pull request #13 from tchapi/feature/imap_auth

Add IMAP as an auth backend
This commit is contained in:
tchap 2020-10-20 16:35:06 +02:00 committed by GitHub
commit f2a4ef5a3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 6 deletions

6
.env
View File

@ -43,9 +43,13 @@ ADMIN_PASSWORD=test
AUTH_REALM=SabreDAV
# Auth Method for the frontend
# "Basic" or "Digest"
# "Basic", "Digest" or "IMAP"
AUTH_METHOD=Digest
# In case of IMAP Auth, you must specify the url of the mailbox in the following format {host[:port][/flag1/flag2...]}.
# See https://www.php.net/manual/en/function.imap-open.php for more details
IMAP_AUTH_URL=null
# Do we enable caldav and carddav ?
CALDAV_ENABLED=true
CARDDAV_ENABLED=true

View File

@ -56,9 +56,11 @@ c. The auth Realm and method for HTTP auth
```
AUTH_REALM=SabreDAV
AUTH_METHOD=Digest # can be "Basic" or "Digest"
AUTH_METHOD=Digest # can be "Basic", "Digest" or "IMAP"
```
> In case you use the `IMAP` auth type, you must specify the auth url (the "mailbox" url) in `IMAP_AUTH_URL`. See https://www.php.net/manual/en/function.imap-open.php for more details.
d. The global flags to enable CalDAV, CardDAV and WebDAV
```

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 532 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 399 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 476 KiB

View File

@ -9,4 +9,5 @@ twig:
calDAVEnabled: '%env(bool:CALDAV_ENABLED)%'
cardDAVEnabled: '%env(bool:CARDDAV_ENABLED)%'
webDAVEnabled: '%env(bool:WEBDAV_ENABLED)%'
authRealm: '%env(AUTH_REALM)%'
authRealm: '%env(AUTH_REALM)%'
authMethod: '%env(AUTH_METHOD)%'

View File

@ -37,6 +37,7 @@ services:
$authRealm: "%env(AUTH_REALM)%"
$publicDir: "%env(PUBLIC_DIR)%"
$tmpDir: "%env(TMP_DIR)%"
$IMAPAuthUrl: "%env(IMAP_AUTH_URL)%"
App\Security\LoginFormAuthenticator:
arguments:

View File

@ -18,6 +18,7 @@ class DAVController extends AbstractController
{
const AUTH_DIGEST = 'Digest';
const AUTH_BASIC = 'Basic';
const AUTH_IMAP = 'IMAP';
/**
* Is CalDAV enabled?
@ -110,7 +111,14 @@ class DAVController extends AbstractController
*/
protected $server;
public function __construct(\Swift_Mailer $mailer, TwigEnvironment $twig, BasicAuth $basicAuthBackend, UrlGeneratorInterface $router, EntityManagerInterface $entityManager, bool $calDAVEnabled = true, bool $cardDAVEnabled = true, bool $webDAVEnabled = false, ?string $inviteAddress, ?string $authMethod, ?string $authRealm, ?string $publicDir, ?string $tmpDir)
/**
* IMAP mailbox URL used for authentication.
*
* @var string
*/
protected $IMAPAuthUrl;
public function __construct(\Swift_Mailer $mailer, TwigEnvironment $twig, BasicAuth $basicAuthBackend, UrlGeneratorInterface $router, EntityManagerInterface $entityManager, bool $calDAVEnabled = true, bool $cardDAVEnabled = true, bool $webDAVEnabled = false, ?string $inviteAddress, ?string $authMethod, ?string $authRealm, ?string $publicDir, ?string $tmpDir, ?string $IMAPAuthUrl)
{
$this->calDAVEnabled = $calDAVEnabled;
$this->cardDAVEnabled = $cardDAVEnabled;
@ -130,6 +138,8 @@ class DAVController extends AbstractController
$this->basicAuthBackend = $basicAuthBackend;
$this->IMAPAuthUrl = $IMAPAuthUrl;
$this->initServer();
}
@ -152,6 +162,9 @@ class DAVController extends AbstractController
case self::AUTH_DIGEST:
$authBackend = new \Sabre\DAV\Auth\Backend\PDO($pdo);
break;
case self::AUTH_IMAP:
$authBackend = new \Sabre\DAV\Auth\Backend\IMAP($this->IMAPAuthUrl);
break;
case self::AUTH_BASIC:
default:
$authBackend = $this->basicAuthBackend;

View File

@ -39,7 +39,7 @@
<ul class="list-group">
<li class="list-group-item list-group-item-primary">{{ "dashboard.version"|trans }} : <code>{{ version }}</code> (SabreDAV <code>{{ sabredav_version }}</code>)</li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.auth_realm"|trans }} : <code>{{ authRealm }}</code></li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.auth"|trans }} : <code>{{ authMethod }}</code> ({{ "dashboard.auth_realm"|trans }}: <code>{{ authRealm }}</code>)</li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.invite_from_address"|trans }} : <code>{{ invite_from_address|default('Not set') }}</code></li>
<li class="list-group-item list-group-item-secondary">{{ "dashboard.server_timezone"|trans }} : <code>{{ timezone }}</code> <a class="small ml-2" target="_blank" href="https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone">{{ "dashboard.how_to_change_it"|trans }}</a></li>

View File

@ -89,9 +89,13 @@
<source>dashboard.version</source>
<target>Version</target>
</trans-unit>
<trans-unit id="zNewm0r" resname="dashboard.auth">
<source>dashboard.auth</source>
<target>Auth</target>
</trans-unit>
<trans-unit id="q.9wpuM" resname="dashboard.auth_realm">
<source>dashboard.auth_realm</source>
<target>Auth Realm</target>
<target>Realm</target>
</trans-unit>
<trans-unit id="w84LMcB" resname="dashboard.invite_from_address">
<source>dashboard.invite_from_address</source>