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
|
||||
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]
|
||||
# Folder for storing local calendars,
|
||||
# created if not present
|
||||
|
@ -56,7 +56,6 @@ VERSION = "git"
|
||||
|
||||
def _check(request, function):
|
||||
"""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:
|
||||
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")},
|
||||
"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
|
||||
_CONFIG_PARSER = ConfigParser()
|
||||
|
@ -29,7 +29,7 @@ in them for XML requests (all but PUT).
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from radicale import client, config, ical
|
||||
from radicale import client, config, ical, log
|
||||
|
||||
|
||||
NAMESPACES = {
|
||||
@ -83,11 +83,11 @@ def propfind(path, xml_request, calendar, depth):
|
||||
"""Read and answer PROPFIND requests.
|
||||
|
||||
Read rfc4918-9.1 for info.
|
||||
|
||||
|
||||
"""
|
||||
# Reading request
|
||||
root = ET.fromstring(xml_request)
|
||||
|
||||
|
||||
prop_element = root.find(_tag("D", "prop"))
|
||||
prop_list = prop_element.getchildren()
|
||||
props = [prop.tag for prop in prop_list]
|
||||
|
Loading…
Reference in New Issue
Block a user