Author: tmckay
Date: 2012-05-01 15:57:45 +0000 (Tue, 01 May 2012)
New Revision: 5352
Modified:
trunk/cumin/etc/cumin.conf
trunk/cumin/python/cumin/authenticator.py
Log:
Add defaults for auth mechanism parsing.
Let 'ldap=' be dropped if the mechanism begins with "ldap://".
Allow parameters to be dropped for script capabilities.
Assume a script has all capabilities if none are specified
Modified: trunk/cumin/etc/cumin.conf
===================================================================
--- trunk/cumin/etc/cumin.conf 2012-04-27 16:46:08 UTC (rev 5351)
+++ trunk/cumin/etc/cumin.conf 2012-05-01 15:57:45 UTC (rev 5352)
@@ -28,12 +28,14 @@
# job servers. If the Aviary locator is used, this value will be overriden
# but must still be non-empty to enable use of Aviary job servers.
# Default value is shown. Uncomment and leave the value blank to disable.
+# More details in 'Some parameter explanations by section' below.
# aviary-job-servers:
http://localhost:9090
# The value for this parameter is a comma separated list of URLs for Aviary
# query servers. If the Aviary locator is used, this value will be overriden
# but must still be non-empty to enable use of Aviary query servers.
# Default value is shown. Uncomment and leave the value blank to disable.
+# More details in 'Some parameter explanations by section' below.
# aviary-query-servers:
http://localhost:9091
# The locator allows Cumin to retrive values for Aviary job servers and
@@ -41,7 +43,8 @@
# values for aviary-job-servers and aviary-query-servers will be overriden
# (but those parameters must still be non-empty to be enabled).
# Default is empty string (aviary locator will not be used). Uncomment the
-# following line and edit as needed to enable.
+# following line and edit as needed to enable. More details in
+# 'Some parameter explanations by section' below.
# aviary-locator:
http://localhost:9000
# Full path to private key file used for ssl communication with aviary servers.
@@ -252,6 +255,14 @@
## query servers to be used, even if aviary-locator
## has been set.
+## aviary-locator:
http://localhost:9000
+## Specifies the URI for the aviary locator. This is
+## a single value, not a list of URIs. The form of
+## the URI is the same as that of aviary-job-servers.
+## The port will default to 9000 and the path will
+## default to /services/locator/locate. Other defaults
+## are as noted for aviary-job-servers.
+
## log-max-mb: 10
## Maximum size in MB of *.log files created by cumin.
## A log file reaching maximum size will be rolled over.
Modified: trunk/cumin/python/cumin/authenticator.py
===================================================================
--- trunk/cumin/python/cumin/authenticator.py 2012-04-27 16:46:08 UTC (rev 5351)
+++ trunk/cumin/python/cumin/authenticator.py 2012-05-01 15:57:45 UTC (rev 5352)
@@ -30,7 +30,9 @@
log.info("Initializing %s", self)
myurl = url.split("=",1)[1]
try:
- self.url = ldapurl.LDAPUrl(myurl)
+ self.url = ldapurl.LDAPUrl(myurl,
+ scope=ldapurl.LDAP_SCOPE_SUBTREE,
+ filterstr="uid=%s")
log.info("Authenticator: parsed LDAP url successfully.")
except Exception,e:
log.error("Authenticator: cannot parse LDAP url %s", e)
@@ -144,23 +146,29 @@
self.cap = []
me = self.__class__.__name__
for a in commandline.split(','):
- param,val = a.split('=')
+ # Allow capability with a null value
+ args = a.split('=')
+ if len(args) == 1:
+ args.append("")
+ param,val = args
self.params[param] = val
if self.params.has_key('script') and \
os.access(self.params['script'], os.X_OK):
- if self.params.has_key('auth'):
- log.debug("Authenticator: adding auth capability to %s", me)
- self.cap.append('a')
- if self.params.has_key('change'):
- log.debug("Authenticator: adding change capability to %s", me)
- self.cap.append('c')
- if self.params.has_key('list'):
- log.debug("Authenticator: adding list capability to %s", me)
- self.cap.append('l')
- if self.params.has_key('find'):
- log.debug("Authenticator: adding find capability to %s", me)
- self.cap.append('f')
+
+ # Allow default with all operations and no specific
+ # parameters per operation. The convention here is
+ # to store the first letter in self.cap, but anything
+ # unambiguous would do.
+ if len(self.params) == 1:
+ self.cap = ['a','c','l','f']
+ log.debug("Authenticator: adding all capabilities to %s", me)
+ else:
+ msg = "Authenticator: adding %s capability to %s"
+ for cap in ("auth", "change", "list",
"find"):
+ if self.params.has_key(cap):
+ log.debug(msg % (cap, me))
+ self.cap.append(cap[0])
else:
log.error('Authenticator: script parameter missing or target file '\
'not executable in %s', me)
@@ -262,8 +270,13 @@
"ldap mechanism not available")
for authmech in app.authmech:
if authmech != "internal":
+ # Allow initial ldap= to be skipped
try:
- mechname = authmech.split('=')[0]
+ if authmech.startswith("ldap://"):
+ mechname = "ldap"
+ authmech = "ldap=" + authmech
+ else:
+ mechname = authmech.split('=',1)[0]
log.info("Authenticator: adding auth mechanism %s",
mechname)
classname = authen_map[mechname]
except KeyError: