2020-08-18 07:25:32 +00:00
|
|
|
#x
|
|
|
|
|
2020-08-18 07:45:47 +00:00
|
|
|
class wmdeit_ldap (
|
2020-08-18 07:25:32 +00:00
|
|
|
$log_level = 0,
|
|
|
|
|
2020-08-25 20:56:26 +00:00
|
|
|
$configdn,
|
|
|
|
$configpw,
|
2020-08-18 07:25:32 +00:00
|
|
|
$syncrepl_providers = [
|
|
|
|
],
|
|
|
|
|
2020-08-25 20:56:26 +00:00
|
|
|
$database,
|
|
|
|
$rootdn,
|
|
|
|
$rootpw,
|
2021-05-31 13:06:55 +00:00
|
|
|
$starttls = "no",
|
2020-08-18 07:25:32 +00:00
|
|
|
|
|
|
|
$serverid,
|
|
|
|
$simple_bind_tls = "128",
|
|
|
|
|
|
|
|
$schema_path = '/etc/ldap/schema',
|
2020-08-21 09:51:37 +00:00
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
$schema = [
|
2020-08-21 09:51:37 +00:00
|
|
|
"core",
|
|
|
|
"cosine",
|
|
|
|
"inetorgperson",
|
|
|
|
# "nis",
|
|
|
|
"rfc2307bis",
|
|
|
|
"krb5-kdc",
|
2020-08-18 07:25:32 +00:00
|
|
|
"samba",
|
2021-05-28 18:27:13 +00:00
|
|
|
"ppolicy",
|
2020-08-21 09:51:37 +00:00
|
|
|
|
|
|
|
# "samba",
|
2020-08-18 07:25:32 +00:00
|
|
|
# "nis",
|
|
|
|
# "rfc2307bis",
|
|
|
|
# "solaris",
|
2020-08-21 09:51:37 +00:00
|
|
|
# "dnszone",
|
|
|
|
# "univention",
|
|
|
|
# "univention-objecttype",
|
|
|
|
# "krb5-kdc",
|
|
|
|
# "directory",
|
|
|
|
# "policy",
|
|
|
|
# "msgpo",
|
|
|
|
# "dhcp",
|
|
|
|
# "univention-dhcp",
|
|
|
|
# "mail",
|
2020-08-18 07:25:32 +00:00
|
|
|
# "automount",
|
2020-08-21 09:51:37 +00:00
|
|
|
# "user",
|
|
|
|
# "self-service-passwordreset",
|
|
|
|
# "univention-saml",
|
|
|
|
# "univention-virtual-machine-manager",
|
|
|
|
# "nagios",
|
|
|
|
# "share",
|
|
|
|
# "network",
|
|
|
|
# "portal",
|
|
|
|
# "univention-default",
|
|
|
|
# "univention-app",
|
|
|
|
# "univention-object-metadata",
|
|
|
|
# "univention-ldap-extension",
|
|
|
|
# "license",
|
|
|
|
# "ppolicy",
|
|
|
|
# "template",
|
|
|
|
# "lock",
|
|
|
|
# "udm-extension",
|
|
|
|
# "custom-attribute",
|
|
|
|
# "univention-syntax",
|
|
|
|
# "openssh",
|
2020-08-18 13:33:56 +00:00
|
|
|
# "nextcloud",
|
|
|
|
# "openproject",
|
|
|
|
# "networkaccess",
|
2020-08-18 07:25:32 +00:00
|
|
|
|
|
|
|
],
|
|
|
|
$ssldir = "/etc/ldap/ssl",
|
|
|
|
|
2020-08-27 17:08:54 +00:00
|
|
|
$acl = {
|
|
|
|
# Super access to local root user
|
|
|
|
'0 to *' => [
|
|
|
|
'by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage',
|
|
|
|
'by * break',
|
|
|
|
],
|
|
|
|
# Admin rights for members of Admin group
|
|
|
|
'1 to *' => [
|
2020-08-27 18:31:11 +00:00
|
|
|
"by set=\"user & [cn=Administrators,ou=Groups,$database]/member\" write",
|
2020-08-27 17:08:54 +00:00
|
|
|
'by * break'
|
|
|
|
],
|
2021-05-28 18:27:13 +00:00
|
|
|
# System rights for members of Adm group
|
|
|
|
'2 to *' => [
|
|
|
|
"by set=\"user & [cn=Adm,ou=Groups,ou=System,$database]/member\" write",
|
|
|
|
'by * break'
|
|
|
|
],
|
|
|
|
# System rights for members of Adm group
|
|
|
|
'3 to *' => [
|
|
|
|
"by set=\"user & [cn=ReadOnlyAdm,ou=Groups,ou=System,$database]/member\" read",
|
|
|
|
'by * break'
|
|
|
|
],
|
|
|
|
|
2020-08-27 17:08:54 +00:00
|
|
|
# let users modify their passwords, and disable read acess to all others
|
2021-05-31 13:06:55 +00:00
|
|
|
'4 to attrs=userPassword filter=(!(memberof=cn=NOLOGIN,ou=Groups,dc=wikimedia,dc=de))' => [
|
|
|
|
# '4 to attrs=userPassword' => [
|
2020-08-27 17:08:54 +00:00
|
|
|
"by self write",
|
|
|
|
"by anonymous auth",
|
|
|
|
"by * none",
|
|
|
|
],
|
|
|
|
# let users read all
|
2021-05-28 18:27:13 +00:00
|
|
|
'5 to attr=entry,objectClass,givenName,cn,displayName' => [
|
2020-08-27 17:08:54 +00:00
|
|
|
"by anonymous break",
|
|
|
|
"by * read",
|
|
|
|
],
|
2020-09-11 07:04:56 +00:00
|
|
|
# let anonymous users list uids
|
2021-05-28 18:27:13 +00:00
|
|
|
"6 to dn.subtree=\"$database\" attrs=entry,objectClass,uid" => [
|
2020-08-27 17:08:54 +00:00
|
|
|
"by anonymous read",
|
|
|
|
"by * break",
|
|
|
|
],
|
2020-09-11 07:04:56 +00:00
|
|
|
# deny access to anything else
|
2021-05-28 18:27:13 +00:00
|
|
|
'7 to *' => [
|
2020-08-27 17:08:54 +00:00
|
|
|
"by * none",
|
|
|
|
]
|
|
|
|
|
|
|
|
},
|
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
){
|
|
|
|
$clientcert = $facts[clientcert]
|
|
|
|
|
|
|
|
$pubcert = "$ssldir/cert.pem"
|
|
|
|
$privkey = "$ssldir/priv.pem"
|
|
|
|
$cacert = "$ssldir/ca.pem"
|
|
|
|
|
2020-08-21 09:51:37 +00:00
|
|
|
|
|
|
|
# required modules
|
|
|
|
openldap::server::module { 'back_mdb':
|
|
|
|
ensure => present
|
|
|
|
} ->
|
|
|
|
openldap::server::module { 'memberof':
|
|
|
|
ensure => present,
|
|
|
|
} ->
|
|
|
|
openldap::server::module { 'syncprov':
|
|
|
|
ensure => present,
|
2021-05-28 18:27:13 +00:00
|
|
|
}
|
|
|
|
# openldap::server::module { 'ppolicy':
|
|
|
|
# ensure => absent,
|
|
|
|
# }
|
|
|
|
|
2020-08-21 09:51:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
package { "heimdal-kdc":
|
|
|
|
ensure => installed,
|
|
|
|
}->
|
|
|
|
package {"slapd-smbk5pwd":
|
|
|
|
ensure => installed,
|
|
|
|
} ->
|
|
|
|
openldap::server::module { 'smbk5pwd':
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
|
2020-08-18 13:23:59 +00:00
|
|
|
class { 'openldap::server':
|
|
|
|
ssl_ca => "$cacert",
|
|
|
|
ssl_cert => "$pubcert",
|
|
|
|
ssl_key => "$privkey",
|
|
|
|
ldaps_ifs => ['/'],
|
2020-08-21 09:51:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# delete all schema and databases created by default during installation
|
|
|
|
# This is some kind of a dirty hack because we use
|
2020-09-11 07:04:56 +00:00
|
|
|
# in "before =>" and "require =>" some internal classes of module openldap
|
2020-08-21 09:51:37 +00:00
|
|
|
exec { 'wmdemanaged':
|
|
|
|
before => Class['::openldap::server::config'],
|
|
|
|
require => Class['::openldap::server::install'],
|
|
|
|
|
|
|
|
creates => "/etc/ldap/wmde.managed",
|
|
|
|
command => @(CMD/L),
|
2020-09-11 07:04:56 +00:00
|
|
|
/usr/sbin/service slapd stop &&
|
|
|
|
rm -rf '/etc/ldap/slapd.d/cn=config/cn=schema' &&
|
|
|
|
rm -rf '/etc/ldap/slapd.d/cn=config/cn=schema.ldif' &&
|
|
|
|
rm -rf '/etc/ldap/slapd.d/cn=config/olcDatabase={1}mdb.ldif' &&
|
|
|
|
/usr/sbin/service slapd start &&
|
|
|
|
touch /etc/ldap/wmde.managed
|
|
|
|
| CMD
|
2020-08-21 09:51:37 +00:00
|
|
|
}
|
2020-08-18 13:23:59 +00:00
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
|
|
|
|
# SSL stuff ... copy CA cert and keys used by puppet agent to
|
|
|
|
# a separate directory and make them accesible by openldap
|
|
|
|
file { "$ssldir":
|
|
|
|
ensure => directory,
|
|
|
|
owner => "openldap",
|
|
|
|
group => "openldap",
|
|
|
|
mode => "0600",
|
|
|
|
} ->
|
|
|
|
file { "$cacert": # copy CA cert
|
|
|
|
ensure => file,
|
|
|
|
source => "/var/lib/puppet/ssl/certs/ca.pem",
|
|
|
|
owner => "openldap",
|
|
|
|
group => "openldap",
|
|
|
|
mode => "0600",
|
|
|
|
} ->
|
|
|
|
file { "$pubcert": # copy public key
|
|
|
|
ensure => file,
|
|
|
|
source => "/var/lib/puppet/ssl/certs/$clientcert.pem",
|
|
|
|
owner => "openldap",
|
|
|
|
group => "openldap",
|
|
|
|
mode => "0600",
|
|
|
|
} ->
|
|
|
|
file { "$privkey": # copy private key
|
|
|
|
ensure => file,
|
|
|
|
source => "/var/lib/puppet/ssl/private_keys/$clientcert.pem",
|
|
|
|
owner => "openldap",
|
|
|
|
group => "openldap",
|
|
|
|
mode => "0600",
|
2020-08-21 09:51:37 +00:00
|
|
|
}
|
2020-08-18 07:25:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
# openldap::server::globalconf { 'TLSCACertificateFile':
|
|
|
|
# ensure => present,
|
|
|
|
# value => { "TLSCACertificateFile"=>"$ssldir/ca.pem" }
|
|
|
|
# }
|
|
|
|
|
|
|
|
# openldap::server::globalconf { 'TLSCertificateKeyFile':
|
|
|
|
# ensure => present,
|
|
|
|
# value => { "TLSCertificateKeyFile"=>"$ssldir/privkey.pem" }
|
|
|
|
# }
|
|
|
|
|
|
|
|
# openldap::server::globalconf { 'TLSCertificateFile':
|
|
|
|
# ensure => present,
|
|
|
|
# value => "$ssldir/pubkey.pem"
|
|
|
|
# }
|
|
|
|
|
|
|
|
openldap::server::globalconf { 'LogLevel':
|
|
|
|
ensure => present,
|
|
|
|
value => { "LogLevel"=>"$log_level" }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
openldap::server::globalconf { 'Security':
|
|
|
|
ensure => present,
|
|
|
|
value => { 'Security' => [ "simple_bind=$simple_bind_tls", 'ssf=0', "tls=0" ] },
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# add schemas
|
|
|
|
$schema.each | $s | {
|
2020-08-21 09:51:37 +00:00
|
|
|
$ensure = present
|
2020-08-18 07:25:32 +00:00
|
|
|
file { "$schema_path/$s.schema":
|
|
|
|
ensure => file,
|
2020-08-18 13:33:56 +00:00
|
|
|
content => file ("wmdeit_ldap/schema/$s.schema"),
|
2020-08-18 07:25:32 +00:00
|
|
|
|
|
|
|
}->
|
|
|
|
openldap::server::schema { "$s":
|
2020-08-21 09:51:37 +00:00
|
|
|
ensure => $ensure,
|
2020-08-18 07:25:32 +00:00
|
|
|
path => "$schema_path/$s.schema",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
openldap::server::globalconf { 'ServerID':
|
|
|
|
ensure => present,
|
|
|
|
value => { "ServerID"=>"$serverid" }
|
|
|
|
}
|
|
|
|
# ensure config database is present and dn and pw are set
|
|
|
|
openldap::server::database { 'cn=config':
|
|
|
|
ensure => present,
|
|
|
|
backend => config,
|
|
|
|
rootdn => $configdn,
|
|
|
|
rootpw => $configpw
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-21 12:14:05 +00:00
|
|
|
# class { 'java':
|
|
|
|
# distribution => 'jre',
|
|
|
|
# version => "8"
|
|
|
|
# }
|
2020-08-21 12:50:14 +00:00
|
|
|
#
|
2020-08-21 19:28:40 +00:00
|
|
|
|
2020-08-21 09:51:37 +00:00
|
|
|
# openldap::server::globalconf { 'TLSVerifyClient':
|
|
|
|
# ensure => present,
|
|
|
|
# value => { "TLSVerifyClient"=>"never" }
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Build list of syncrepl-entries, store it in $syncrepl
|
2020-09-11 07:04:56 +00:00
|
|
|
if !empty ($syncrepl_providers) {
|
|
|
|
$mirrormode=true
|
|
|
|
$syncrepl = $syncrepl_providers.map |Integer $index, $provider| {
|
|
|
|
$i = $index+1
|
2021-05-31 13:06:55 +00:00
|
|
|
"rid=00$i provider=${provider[proto]}://${provider[host]}:${provider[port]} binddn=\"$rootdn\" bindmethod=simple credentials=$rootpw searchbase=\"$database\" scope=sub attrs=\"*,+\" filter=\"(objectClass=*)\" type=refreshAndPersist tls_cacert=$cacert tls_key=$privkey tls_cert=$pubcert starttls=$starttls retry=\"3 60 6 300 30 +\" timeout=1"
|
2020-09-11 07:04:56 +00:00
|
|
|
}
|
|
|
|
$syncrepl_providers.each |Integer $index, $provider| {
|
|
|
|
if $provider[ip] {
|
|
|
|
host{"host_$index":
|
|
|
|
name => $provider[host],
|
|
|
|
ip => $provider[ip],
|
|
|
|
ensure => present,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-21 09:51:37 +00:00
|
|
|
|
2020-09-11 07:04:56 +00:00
|
|
|
}
|
2020-08-21 09:51:37 +00:00
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
# create the main database
|
|
|
|
openldap::server::database { "$database":
|
2020-08-21 09:51:37 +00:00
|
|
|
backend => mdb,
|
2020-08-18 07:25:32 +00:00
|
|
|
ensure => present,
|
|
|
|
rootdn => $rootdn,
|
|
|
|
rootpw => $rootpw,
|
2020-09-11 07:04:56 +00:00
|
|
|
syncrepl => $syncrepl,
|
2020-08-18 07:25:32 +00:00
|
|
|
mirrormode => $mirrormode,
|
2020-08-27 17:08:54 +00:00
|
|
|
}
|
|
|
|
->
|
|
|
|
openldap::server::overlay { "memberof on $database":
|
|
|
|
ensure => present,
|
2021-05-28 18:27:13 +00:00
|
|
|
options => {
|
|
|
|
'olcMemberOfGroupOC' => 'groupOfMembers'
|
|
|
|
}
|
2020-08-27 17:08:54 +00:00
|
|
|
}
|
2020-09-11 07:04:56 +00:00
|
|
|
->
|
|
|
|
openldap::server::overlay { "syncprov on $database":
|
|
|
|
ensure => present,
|
|
|
|
}
|
2020-08-27 17:08:54 +00:00
|
|
|
->
|
2021-05-31 13:06:55 +00:00
|
|
|
# openldap::server::overlay { "smbk5pwd on $database":
|
|
|
|
# ensure => present,
|
|
|
|
# }
|
|
|
|
|
2021-05-28 18:27:13 +00:00
|
|
|
# openldap::server::overlay { "ppolicy on $database":
|
|
|
|
# ensure => absent,
|
|
|
|
# }
|
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
|
2020-08-27 17:08:54 +00:00
|
|
|
# $acls.each |Integer $i, $acl | {
|
|
|
|
# notify{"Set ACL $i $acl":}
|
2020-08-21 09:51:37 +00:00
|
|
|
# openldap::server::access { "{$i}$acl":
|
2020-08-27 17:08:54 +00:00
|
|
|
# openldap::server::access { "$i on $database":
|
2020-08-21 09:51:37 +00:00
|
|
|
# suffix => "$database",
|
|
|
|
# ensure => present,
|
2020-08-27 17:08:54 +00:00
|
|
|
# access => $acl['access'],
|
|
|
|
# what => $acl['to'],
|
2020-08-21 09:51:37 +00:00
|
|
|
# }
|
|
|
|
# }
|
2020-08-27 17:08:54 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
openldap::server::access_wrapper { $database :
|
|
|
|
acl => $acl,
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-18 07:25:32 +00:00
|
|
|
|
2020-08-21 09:51:37 +00:00
|
|
|
#'''''##################################################################################################
|
|
|
|
#
|
|
|
|
#
|
2020-08-18 07:25:32 +00:00
|
|
|
|
2020-08-27 17:08:54 +00:00
|
|
|
# openldap::server::access { '{0}to * by set="user/uid & [cn=Domain Admins,cn=groups,dc=wikimedia,dc=de]/memberUid" write by * break on $database':
|
2020-08-18 07:25:32 +00:00
|
|
|
# suffix => "$database",
|
2020-08-27 17:08:54 +00:00
|
|
|
# access => '{0}to * by set="user/uid & [cn=Domain Admins,cn=groups,dc=wikimedia,dc=de]/memberUid" write by * break',
|
2020-08-18 07:25:32 +00:00
|
|
|
# ensure => present,
|
|
|
|
# }
|
2020-08-27 17:08:54 +00:00
|
|
|
#
|
2020-08-18 07:25:32 +00:00
|
|
|
# openldap::server::access { '{1}to * by set="user/uid & [cn=Administrators,cn=Builtin,dc=wikimedia,dc=de]/memberUid" write by * break':
|
|
|
|
# suffix => "$database",
|
|
|
|
# ensure => present,
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# openldap::server::access { '{2}to * by dn.exact=gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth manage by * break':
|
|
|
|
# suffix => "$database",
|
|
|
|
# ensure => present,
|
|
|
|
## }
|
|
|
|
|
|
|
|
# openldap::server::access { '{3}to attrs=userPassword by self write by anonymous auth by dn="cn=admin,dc=wikimedia,dc=de" write by * none':
|
|
|
|
# suffix => "$database",
|
|
|
|
## ensure => present,
|
|
|
|
# }
|
|
|
|
|
|
|
|
# openldap::server::access { '{4}to dn.base="" by * read':
|
|
|
|
# suffix => "$database",
|
|
|
|
# ensure => present,
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# openldap::server::access { '{5}to * by self write by dn="cn=admin,dc=wikimedia,dc=de" write by * read':
|
|
|
|
# suffix => "$database",
|
|
|
|
# ensure => present,
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# openldap::server::dbindex { 'uid pres,eq':
|
|
|
|
# ensure => present,
|
|
|
|
# suffix => "$database",
|
|
|
|
# }
|
|
|
|
# openldap::server::dbindex { 'sn eq,approx,sub':
|
|
|
|
# ensure => present,
|
|
|
|
# suffix => "$database",
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|