1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-05 06:27:37 +00:00

www/baikal: import IMAP auth backend from sabre/dav master

To authenticate against an IMAP server, you'll need to:

1) Change the authBackend in Core/Frameworks/Baikal/Core/Server.php:135 to
   $authBackend = new \Sabre\DAV\Auth\Backend\IMAP(IMAP_OPEN);

2) Set the IMAP_OPEN configuration entry in Specific/config.php, e.g.,
   define("IMAP_OPEN", '{192.168.1.1:993/imap/ssl/novalidate-cert}INBOX');

Obtained from: https://github.com/fruux/sabre-dav/blob/master/lib/DAV/Auth/Backend/IMAP.php
This commit is contained in:
Pietro Cerutti 2017-04-13 12:34:51 +00:00
parent b4aabf7cfc
commit 84835614cd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=438440
3 changed files with 86 additions and 2 deletions

View File

@ -3,7 +3,7 @@
PORTNAME= baikal
PORTVERSION= 0.4.6
PORTREVISION= 2
PORTREVISION= 3
CATEGORIES= www
MASTER_SITES= https://github.com/fruux/Baikal/releases/download/${PORTVERSION}/
@ -14,7 +14,8 @@ LICENSE= GPLv3
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= php zip
USE_PHP= ctype dom filter json mbstring openssl pdo_sqlite session xml xmlreader xmlwriter
USE_PHP= ctype dom filter imap json mbstring openssl pdo_sqlite \
session xml xmlreader xmlwriter
WRKSRC= ${WRKDIR}/${PORTNAME}
NO_BUILD= yes

View File

@ -0,0 +1,82 @@
--- /dev/null 12:27:00 UTC
+++ vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Sabre\DAV\Auth\Backend;
+
+/**
+ * This is an authentication backend that uses imap.
+ *
+ * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
+ * @author Michael Niewöhner (foss@mniewoehner.de)
+ * @author rosali (https://github.com/rosali)
+ * @author Evert Pot (http://evertpot.com/)
+ * @license http://sabre.io/license/ Modified BSD License
+ */
+class IMAP extends AbstractBasic {
+
+ /**
+ * IMAP server in the form {host[:port][/flag1/flag2...]}
+ * @see http://php.net/manual/en/function.imap-open.php
+ *
+ * @var string
+ */
+ protected $mailbox;
+
+ /**
+ * Creates the backend object.
+ *
+ * @param string $mailbox
+ */
+ function __construct($mailbox) {
+
+ $this->mailbox = $mailbox;
+
+ }
+
+ /**
+ * Connects to an IMAP server and tries to authenticate
+ *
+ * @param string $username
+ * @param string $password
+ * @return bool
+ */
+ protected function imapOpen($username, $password) {
+
+ $success = false;
+
+ try {
+ $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1);
+ if ($imap)
+ $success = true;
+ } catch (\ErrorException $e) {
+ error_log($e->getMessage());
+ }
+
+ $errors = imap_errors();
+ if ($errors)
+ foreach ($errors as $error)
+ error_log($error);
+
+ if (isset($imap) && $imap)
+ imap_close($imap);
+
+ return $success;
+
+ }
+
+ /**
+ * Validates a username and password by trying to authenticate against IMAP
+ *
+ * @param string $username
+ * @param string $password
+ * @return bool
+ */
+ protected function validateUserPass($username, $password) {
+
+ return $this->imapOpen($username, $password);
+
+ }
+
+}

View File

@ -376,6 +376,7 @@
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Backend/BackendInterface.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Backend/BasicCallBack.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Backend/File.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Backend/PDO.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Auth/Plugin.php
%%WWWDIR%%/vendor/sabre/dav/lib/DAV/Browser/GuessContentType.php