Support SSL for IMAP authentication
Based on Nikita Koshikov's commit: https://github.com/interlegis/Radicale/commit/000fc2a
This commit is contained in:
parent
a01e4d18e1
commit
2738d10830
7
config
7
config
@ -38,7 +38,7 @@ stock = utf-8
|
|||||||
|
|
||||||
[auth]
|
[auth]
|
||||||
# Authentication method
|
# Authentication method
|
||||||
# Value: None | htpasswd | LDAP | PAM | courier
|
# Value: None | htpasswd | IMAP | LDAP | PAM | courier
|
||||||
type = None
|
type = None
|
||||||
|
|
||||||
# Usernames used for public collections, separated by a comma
|
# Usernames used for public collections, separated by a comma
|
||||||
@ -71,6 +71,11 @@ ldap_password =
|
|||||||
# LDAP scope of the search
|
# LDAP scope of the search
|
||||||
ldap_scope = OneLevel
|
ldap_scope = OneLevel
|
||||||
|
|
||||||
|
# IMAP Configuration
|
||||||
|
imap_hostname = localhost
|
||||||
|
imap_port = 143
|
||||||
|
imap_ssl = False
|
||||||
|
|
||||||
# PAM group user should be member of
|
# PAM group user should be member of
|
||||||
pam_group_membership =
|
pam_group_membership =
|
||||||
|
|
||||||
|
@ -34,20 +34,26 @@ import imaplib
|
|||||||
|
|
||||||
from .. import config, log
|
from .. import config, log
|
||||||
|
|
||||||
IMAP_SERVER = config.get("auth", "imap_auth_host_name")
|
IMAP_SERVER = config.get("auth", "imap_hostname")
|
||||||
IMAP_SERVER_PORT = config.get("auth", "imap_auth_host_port")
|
IMAP_SERVER_PORT = config.get("auth", "imap_port")
|
||||||
|
IMAP_USE_SSL = config.get("auth", "imap_ssl")
|
||||||
|
|
||||||
|
|
||||||
def is_authenticated(user, password):
|
def is_authenticated(user, password):
|
||||||
"""Check if ``user``/``password`` couple is valid."""
|
"""Check if ``user``/``password`` couple is valid."""
|
||||||
|
|
||||||
log.LOGGER.debug(
|
log.LOGGER.debug(
|
||||||
"[IMAP AUTH] Connecting to %s:%s." % (IMAP_SERVER, IMAP_SERVER_PORT,))
|
"Connecting to IMAP server %s:%s." % (IMAP_SERVER, IMAP_SERVER_PORT,))
|
||||||
|
|
||||||
|
connection_is_secure = False
|
||||||
|
if IMAP_USE_SSL:
|
||||||
|
connection = imaplib.IMAP4_SSL(host=IMAP_SERVER, port=IMAP_SERVER_PORT)
|
||||||
|
connection_is_secure = True
|
||||||
|
else:
|
||||||
connection = imaplib.IMAP4(host=IMAP_SERVER, port=IMAP_SERVER_PORT)
|
connection = imaplib.IMAP4(host=IMAP_SERVER, port=IMAP_SERVER_PORT)
|
||||||
|
|
||||||
server_is_local = (IMAP_SERVER == "localhost")
|
server_is_local = (IMAP_SERVER == "localhost")
|
||||||
|
|
||||||
connection_is_secure = False
|
|
||||||
try:
|
try:
|
||||||
connection.starttls()
|
connection.starttls()
|
||||||
log.LOGGER.debug("IMAP server connection changed to TLS.")
|
log.LOGGER.debug("IMAP server connection changed to TLS.")
|
||||||
|
@ -55,8 +55,9 @@ INITIAL_CONFIG = {
|
|||||||
"private_users": "private",
|
"private_users": "private",
|
||||||
"htpasswd_filename": "/etc/radicale/users",
|
"htpasswd_filename": "/etc/radicale/users",
|
||||||
"htpasswd_encryption": "crypt",
|
"htpasswd_encryption": "crypt",
|
||||||
"imap_auth_host_name": "localhost",
|
"imap_hostname": "localhost",
|
||||||
"imap_auth_host_port": "143",
|
"imap_port": "143",
|
||||||
|
"imap_ssl": "False",
|
||||||
"ldap_url": "ldap://localhost:389/",
|
"ldap_url": "ldap://localhost:389/",
|
||||||
"ldap_base": "ou=users,dc=example,dc=com",
|
"ldap_base": "ou=users,dc=example,dc=com",
|
||||||
"ldap_attribute": "uid",
|
"ldap_attribute": "uid",
|
||||||
|
Loading…
Reference in New Issue
Block a user