3636olcTLSCertificateKeyFile: %(serverkey)s
3737olcTLSVerifyClient: try
3838
39+ # "frontend" config applies to all databases
40+ dn: olcDatabase={-1}frontend,cn=config
41+ objectClass: olcDatabaseConfig
42+ objectClass: olcFrontendConfig
43+ %(access)s
44+
3945dn: cn=module,cn=config
4046objectClass: olcModuleList
4147cn: module
@@ -182,7 +188,7 @@ class SlapdObject:
182188
183189 .. versionchanged:: UNRELEASED
184190
185- Added ldaps_uri attribute
191+ Added ldaps_uri and access attributes
186192 """
187193 slapd_conf_template = SLAPD_CONF_TEMPLATE
188194 database = 'mdb'
@@ -247,6 +253,11 @@ def __init__(self):
247253 self .clientcert = os .path .join (HERE , 'certs/client.pem' )
248254 self .clientkey = os .path .join (HERE , 'certs/client.key' )
249255
256+ self .access = [
257+ 'to attrs=userPassword by self write by anonymous auth by * none' ,
258+ 'to * by * read' ,
259+ ]
260+
250261 @property
251262 def root_dn (self ):
252263 return 'cn={self.root_cn},{self.suffix}' .format (self = self )
@@ -340,6 +351,15 @@ def _avail_tcp_port(self):
340351 """
341352 return self ._avail_tcp_ports (1 )
342353
354+ def gen_access (self ):
355+ """generate a list of 'olcAccess' lines from the self.access list.
356+ """
357+
358+ ret = []
359+ for i ,line in enumerate (self .access ):
360+ ret .append ('olcAccess: {%d}%s' % (i , line ))
361+ return ret
362+
343363 def gen_config (self ):
344364 """
345365 generates a slapd.conf and returns it as one string
@@ -360,6 +380,7 @@ def gen_config(self):
360380 'cafile' : self .cafile ,
361381 'servercert' : self .servercert ,
362382 'serverkey' : self .serverkey ,
383+ 'access' : '' , # '\n'.join(self.gen_access()),
363384 }
364385 return self .slapd_conf_template % config_dict
365386
0 commit comments