From 3089e59d7f048c4846e14ff1f0935f3529e3bc77 Mon Sep 17 00:00:00 2001 From: reind33r Date: Thu, 26 Sep 2019 11:30:27 +0000 Subject: [PATCH] changed IMAP4 to IMAP4_ssl --- README.md | 5 ++--- radicale_imap/__init__.py | 35 ++++++++++++++++------------------- setup.py | 12 ++++++------ 3 files changed, 24 insertions(+), 28 deletions(-) mode change 100755 => 100644 setup.py diff --git a/README.md b/README.md index 0957e98..21b29f6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Radicale IMAP authentication plugin IMAP authentication plugin for [Radicale](http://radicale.org/). -This is a simplification fork of [RadicaleIMAP](https://github.com/Unrud/RadicaleIMAP). +This is a fork of [radicale-imap](https://github.com/comzeradd/radicale-imap) that uses IMAP4_SSL instead of IMAP4 to initiate connection. ## Installation @@ -11,8 +11,7 @@ This is a simplification fork of [RadicaleIMAP](https://github.com/Unrud/Radical [auth] type = radicale_imap - imap_host = address:port - imap_secure = True + imaps_host = address:port ## License diff --git a/radicale_imap/__init__.py b/radicale_imap/__init__.py index 40824bc..b260e8f 100644 --- a/radicale_imap/__init__.py +++ b/radicale_imap/__init__.py @@ -1,6 +1,7 @@ # radicale-imap IMAP authentication plugin for Radicale. # Copyright (C) 2017 Unrud # Copyright (C) 2018 Nikos Roussos . +# Copyright (C) 2019 Louis Guidez . # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,18 +29,14 @@ class Auth(BaseAuth): [auth] type = radicale_imap - imap_host = example.com:143 - imap_secure = True + imaps_host = example.com:143 """ def is_authenticated(self, user, password): # Parse configuration options host = '' - if self.configuration.has_option('auth', 'imap_host'): - host = self.configuration.get('auth', 'imap_host') - secure = True - if self.configuration.has_option('auth', 'imap_secure'): - secure = self.configuration.getboolean('auth', 'imap_secure') + if self.configuration.has_option('auth', 'imaps_host'): + host = self.configuration.get('auth', 'imaps_host') try: if ':' in host: address, port = host.rsplit(':', maxsplit=1) @@ -50,23 +47,23 @@ def is_authenticated(self, user, password): raise RuntimeError( 'Failed to parse address %r: %s' % (host, e)) from e - # Attempt connection with IMAP server + # Attempt connection with IMAPs server try: - connection = imaplib.IMAP4(host=address, port=port) + connection = imaplib.IMAP4_SSL(host=address, port=port) except (OSError, imaplib.IMAP4.error) as e: - raise RuntimeError('Failed to communicate with IMAP server %r: ' + raise RuntimeError('Failed to communicate with IMAPs server %r: ' '%s' % (host, e)) from e # Upgrade connection to StartTLS - context = ssl.create_default_context() - if not secure: - context.check_hostname = False - context.verify_mode = ssl.CERT_NONE - try: - connection.starttls(context) - except (imaplib.IMAP4.error, ssl.CertificateError) as e: - raise RuntimeError('Failed to establish secure connection with %r: %s' - % (host, e)) from e + # context = ssl.create_default_context() + # if not secure: + # context.check_hostname = False + # context.verify_mode = ssl.CERT_NONE + # try: + # connection.starttls(context) + # except (imaplib.IMAP4.error, ssl.CertificateError) as e: + # raise RuntimeError('Failed to establish secure connection with %r: %s' + # % (host, e)) from e # Attempt to authenticate user try: diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index 134741c..9828c1a --- a/setup.py +++ b/setup.py @@ -2,12 +2,12 @@ setup( - name='radicale-imap', - version='0.1.2', - author='Nikos Roussos', - author_email='nikos@roussos.cc', - url='https://gitlab.com/comzeradd/radicale-imap/', - description='Radicale IMAP authentication plugin', + name='radicale-imaps', + version='0.1.0', + author='Louis Guidez', + author_email='louis@hostux.fr', + url='https://github.com/reind33r/radicale-imaps', + description='Radicale IMAPs authentication plugin', include_package_data=True, zip_safe=False, packages=find_packages(),