Skip to content

Commit

Permalink
Add support to multiple LDAP Servers
Browse files Browse the repository at this point in the history
- Add support to multiple LDAP Servers using ServerList option
- Updating examples to use ServerList
- Refactor print DEBUG params
- Updating docs
  • Loading branch information
wiltonsr committed Oct 17, 2024
1 parent d626ff6 commit c3941e8
Show file tree
Hide file tree
Showing 7 changed files with 308 additions and 173 deletions.
8 changes: 6 additions & 2 deletions examples/conf-from-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ services:
- traefik.http.routers.whoami.middlewares=ldap_auth
# ldapAuth Options=================================================================================
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.logLevel=DEBUG
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.url=ldap://ldap.forumsys.com
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.port=389
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.baseDN=dc=example,dc=com
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.attribute=uid
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[0].url=ldap://ldap.forumsys.com
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[0].port=389
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[0].weight=20
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[1].url=ldap://ldap2.forumsys.com
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[1].port=636
- traefik.http.middlewares.ldap_auth.plugin.ldapAuth.serverList[1].weight=10
# AllowedGroups and AllowedUsers are not supported with labels, because multiple value labels are separated with commas
# SearchFilter must not escape curly braces when using labels
# - traefik.http.middlewares.ldap_auth.plugin.ldapAuth.searchFilter=({{.Attribute}}={{.Username}})
Expand Down
19 changes: 14 additions & 5 deletions examples/dynamic-conf/ldapAuth-conf.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
[http.middlewares]
[http.middlewares.my-ldapAuth.plugin.ldapAuth]
Attribute = "uid"
BaseDN = "dc=example,dc=com"
Enabled = "true"
LogLevel = "DEBUG"
Port = "389"
Url = "ldap://ldap.forumsys.com"
AllowedGroups = ["ou=mathematicians,dc=example,dc=com","ou=italians,ou=scientists,dc=example,dc=com"]
Attribute = "uid"
BaseDN = "dc=example,dc=com"
AllowedGroups = [
"ou=mathematicians,dc=example,dc=com",
"ou=italians,ou=scientists,dc=example,dc=com",
]
AllowedUsers = ["euler", "uid=euclid,dc=example,dc=com"]
# SearchFilter must escape curly braces when using toml file
# https://toml.io/en/v1.0.0#string
# SearchFilter = '''(\{\{.Attribute\}\}=\{\{.Username\}\})'''
[[http.middlewares.my-ldapAuth.plugin.ldapAuth.ServerList]]
Url = "ldaps://ldap2.forumsys.com"
Port = "636"
Weight = 10
[[http.middlewares.my-ldapAuth.plugin.ldapAuth.ServerList]]
Url = "ldap://ldap.forumsys.com"
Port = "389"
Weight = 5
17 changes: 14 additions & 3 deletions examples/dynamic-conf/ldapAuth-conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ http:
ldapAuth:
Enabled: true
LogLevel: "DEBUG"
Url: "ldap://ldap.forumsys.com"
Port: 389
BaseDN: "dc=example,dc=com"
Attribute: "uid"
BaseDN: "dc=example,dc=com"
AllowedGroups:
- ou=mathematicians,dc=example,dc=com
- ou=italians,ou=scientists,dc=example,dc=com
Expand All @@ -18,3 +16,16 @@ http:
# SearchFilter must escape curly braces when using yml file
# https://yaml.org/spec/1.1/#id872840
# SearchFilter: (\{\{.Attribute\}\}=\{\{.Username\}\})
ServerList:
- Url: "ldap://ldap.forumsys.com"
Port: 389
Weight: 10
- Url: "ldap://ldap4.forumsys.com"
Port: 636
Weight: 9
- Url: "ldap://ldap3.forumsys.com"
Port: 389
Weight: 11
- Url: "ldap://ldap2.forumsys.com"
Port: 636
Weight: 12
10 changes: 7 additions & 3 deletions examples/dynamic-conf/ldapAuth-tls-conf.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[http.middlewares]
[http.middlewares.my-ldapAuth.plugin.ldapAuth]
Attribute = "uid"
BaseDN = "cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org"
Enabled = true
LogLevel = "DEBUG"
Port = "636"
Attribute = "uid"
BaseDN = "cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org"
[[http.middlewares.my-ldapAuth.plugin.ldapAuth.ServerList]]
Url = "ldaps://ipa.demo1.freeipa.org"
Port = "636"
Weight = 10
MinVersionTLS = "tls.VersionTLS10"
MaxVersionTLS = "tls.VersionTLS13"
CertificateAuthority = '''
-----BEGIN CERTIFICATE-----
MIIFWzCCA8OgAwIBAgIBCDANBgkqhkiG9w0BAQsFADA8MRowGAYDVQQKDBFERU1P
Expand Down
128 changes: 66 additions & 62 deletions examples/dynamic-conf/ldapAuth-tls-conf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,70 @@ http:
ldapAuth:
Enabled: true
LogLevel: "DEBUG"
Url: "ldaps://ipa.demo1.freeipa.org"
Port: 636
BaseDN: "cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org"
Attribute: "uid"
CertificateAuthority: |-
-----BEGIN CERTIFICATE-----
MIIFWzCCA8OgAwIBAgIBCDANBgkqhkiG9w0BAQsFADA8MRowGAYDVQQKDBFERU1P
MS5GUkVFSVBBLk9SRzEeMBwGA1UEAwwVQ2VydGlmaWNhdGUgQXV0aG9yaXR5MB4X
DTIzMDQyMDEzMzYxNFoXDTI1MDQyMDEzMzYxNFowPDEaMBgGA1UECgwRREVNTzEu
RlJFRUlQQS5PUkcxHjAcBgNVBAMMFWlwYS5kZW1vMS5mcmVlaXBhLm9yZzCCASIw
DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMEzBE9i2gqOMM2HKyNnM7Ih5+mv
duVmE5D+5raJtqA1eNZkNrQmSaKwS9cnHGX+2/zSY1FDkZnIhGXySPf0/7fxCuG/
J9MvRlecGnJTWOCvPIVhkvd5PyTKkClmsk4ojx2IwCU6q2nvy0zvSxhhzd2UpOL6
y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FexXtqfLLeGjFTu2a9rw
bB6mM3GKmMszwif/i9uO/NeK1LlmN6g1vy07HtjQWh2LUa9AbeIp6s1UUcruCGem
FSzLRmcOY4wi0gGm8Vwg9MRtS6sUe7bfM7uPXwIDAQABo4GpMIGmMB8GA1UdIwQY
MBaAFKFAgcvZmgX3tnFhcPQ5i4jZ+xE9MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
AQH/BAQDAgHGMB0GA1UdDgQWBBShQIHL2ZoF97ZxYXD0OYuI2fsRPTBDBggrBgEF
BQcBAQQ3MDUwMwYIKwYBBQUHMAGGJ2h0dHA6Ly9pcGEtY2EuZGVtbzEuZnJlZWlw
YS5vcmcvY2Evb2NzcDANBgkqhkiG9w0BAQsFAAOCAYEAH0du998ux4CkH/W9/2l0
GnnHE5GbBBcGd4zEIxxoe0kYm7MKJjXL9gDRZ3RMseEhy0mAX8cixA7xmg/IFgM9
TFHoHbTUNgEzLZtOYl5Qccp48ZV1XLrzfK1DorEH6tgza0X2rNJ7RU25sq9i687Y
S0Tt6W3CNkOnQed7blDbxfZJOq7gvqiTFy09a5OXv2AxpkmRrLwFWd/+4Whbsji1
wiwTD+t7gDTGizqINEsJ3lT+2dDp+mAxPKTd4XiTE4aBPVc4LBxHDnMzqFxa1qzG
v/BL+aa3FkahD/zMm6/B70iApFOFeCrng/1Q7DxUsBWWuzS+oVdm8MEUWtHxANC5
VG91hbzs4jBAig6AY1hGe49oOabkM1IGhp/TIySAaogA4BFS9DNV1TyNZ4Y9PO61
JZHjzfXOLIdSlluwsBJem4Lj6Xdw8epzANA0CVnEQ5R1Aql0uRlSsAuhcsleCYJC
4gbTjx3PDQLm4BUvsNZ62knVDJPvjAX4nOybumpLAVKg
-----END CERTIFICATE-----
BaseDN: "cn=users,cn=accounts,dc=demo1,dc=freeipa,dc=org"
ServerList:
- Url: "ldaps://ipa.demo1.freeipa.org"
Port: 636
Weight: 10
MinVersionTLS: "tls.VersionTLS10"
MaxVersionTLS: "tls.VersionTLS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