Merge commit 'refs/merge-requests/8' of gitorious.org:radicale/radicale into merge-requests/8
This commit is contained in:
commit
43a1886546
10
config
10
config
@ -38,6 +38,16 @@ filename = /etc/radicale/users
|
|||||||
# Value: plain | sha1 | crypt
|
# Value: plain | sha1 | crypt
|
||||||
encryption = crypt
|
encryption = crypt
|
||||||
|
|
||||||
|
[authLdap]
|
||||||
|
#LDAP Host
|
||||||
|
LDAPServer = 127.0.0.1
|
||||||
|
#Fields to create a LDAP bind
|
||||||
|
#Value to add before the user name in a LDAP bind
|
||||||
|
LDAPPrepend = uid=
|
||||||
|
#Value to add after the user name in a LDAP bind
|
||||||
|
LDAPAppend = ou=users,dc=exmaple,dc=dom
|
||||||
|
#=> uid=corentin,ou=users,dc=exmaple,dc=dom
|
||||||
|
|
||||||
[storage]
|
[storage]
|
||||||
# Folder for storing local calendars,
|
# Folder for storing local calendars,
|
||||||
# created if not present
|
# created if not present
|
||||||
|
@ -56,7 +56,6 @@ VERSION = "git"
|
|||||||
|
|
||||||
def _check(request, function):
|
def _check(request, function):
|
||||||
"""Check if user has sufficient rights for performing ``request``."""
|
"""Check if user has sufficient rights for performing ``request``."""
|
||||||
# If we have no calendar or no acl, don't check rights
|
|
||||||
if not request._calendar or not request.server.acl:
|
if not request._calendar or not request.server.acl:
|
||||||
return function(request)
|
return function(request)
|
||||||
|
|
||||||
|
28
radicale/acl/authLdap.py
Normal file
28
radicale/acl/authLdap.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import ldap
|
||||||
|
import radicale
|
||||||
|
|
||||||
|
LDAPSERVER = config.get("authLdap", "LDAPServer")
|
||||||
|
LDAPPREPEND = config.get("authLdap", "LDAPPrepend")
|
||||||
|
LDAPAPPEND = config.get("authLdap", "LDAPAppend")
|
||||||
|
|
||||||
|
def has_right(owner, user, password):
|
||||||
|
if user == None:
|
||||||
|
user=""
|
||||||
|
if password == None:
|
||||||
|
password=""
|
||||||
|
if owner != user:
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
radicale.log.LOGGER.info("Open LDAP server connexion")
|
||||||
|
l=ldap.open(LDAPSERVER, 389)
|
||||||
|
cn="%s%s,%s" % (LDAPPREPEND, user, LDAPAPPEND)
|
||||||
|
radicale.log.LOGGER.info("LDAP bind with dn: %s" % (cn))
|
||||||
|
l.simple_bind_s(cn, password);
|
||||||
|
radicale.log.LOGGER.info("LDAP bind ok")
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
radicale.log.LOGGER.info("Nu such credential")
|
||||||
|
return False
|
@ -56,7 +56,11 @@ INITIAL_CONFIG = {
|
|||||||
"folder": os.path.expanduser("~/.config/radicale/calendars")},
|
"folder": os.path.expanduser("~/.config/radicale/calendars")},
|
||||||
"logging": {
|
"logging": {
|
||||||
"config": "/etc/radicale/logging",
|
"config": "/etc/radicale/logging",
|
||||||
"debug": "False"}}
|
"debug": "False"},
|
||||||
|
"authLdap": {
|
||||||
|
"LDAPServer": "127.0.0.1",
|
||||||
|
"LDAPPrepend": "uid=",
|
||||||
|
"LDAPAppend": "ou=users,dc=example,dc=com"}}
|
||||||
|
|
||||||
# Create a ConfigParser and configure it
|
# Create a ConfigParser and configure it
|
||||||
_CONFIG_PARSER = ConfigParser()
|
_CONFIG_PARSER = ConfigParser()
|
||||||
|
@ -29,7 +29,7 @@ in them for XML requests (all but PUT).
|
|||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
from radicale import client, config, ical
|
from radicale import client, config, ical, log
|
||||||
|
|
||||||
|
|
||||||
NAMESPACES = {
|
NAMESPACES = {
|
||||||
|
Loading…
Reference in New Issue
Block a user