Skip to content

Commit ad27518

Browse files
committed
Provide a method for adding custom LDAP CA cert
This update allows a custom CA cert to be mounted for Postgres LDAP authentication. This uses the existing spec.config.files method to mount a Secret containing the ca.crt file. The required path and file name is 'ldap/ca.crt'. Issue: PGO-1000
1 parent 198fdf8 commit ad27518

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

internal/patroni/config.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,19 @@ func instanceEnvironment(
450450
Name: "PATRONICTL_CONFIG_FILE",
451451
Value: configDirectory,
452452
},
453+
// This allows a custom CA certificate to be mounted for Postgres LDAP
454+
// authentication via spec.config.files.
455+
// - https://wiki.postgresql.org/wiki/LDAP_Authentication_against_AD
456+
//
457+
// When setting the TLS_CACERT for LDAP as an environment variable, 'LDAP'
458+
// must be appended as a prefix.
459+
// - https://www.openldap.org/software/man.cgi?query=ldap.conf
460+
//
461+
// Testing with LDAPTLS_CACERTDIR did not work as expected during testing.
462+
{
463+
Name: "LDAPTLS_CACERT",
464+
Value: "/etc/postgres/ldap/ca.crt",
465+
},
453466
}
454467

455468
return variables

internal/patroni/config_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,8 @@ func TestInstanceEnvironment(t *testing.T) {
838838
value: '*:8008'
839839
- name: PATRONICTL_CONFIG_FILE
840840
value: /etc/patroni
841+
- name: LDAPTLS_CACERT
842+
value: /etc/postgres/ldap/ca.crt
841843
`))
842844

843845
t.Run("MatchingPorts", func(t *testing.T) {
@@ -880,6 +882,8 @@ func TestInstanceEnvironment(t *testing.T) {
880882
value: '*:8008'
881883
- name: PATRONICTL_CONFIG_FILE
882884
value: /etc/patroni
885+
- name: LDAPTLS_CACERT
886+
value: /etc/postgres/ldap/ca.crt
883887
`))
884888
})
885889
}

internal/patroni/reconcile_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ containers:
184184
value: '*:8008'
185185
- name: PATRONICTL_CONFIG_FILE
186186
value: /etc/patroni
187+
- name: LDAPTLS_CACERT
188+
value: /etc/postgres/ldap/ca.crt
187189
livenessProbe:
188190
failureThreshold: 3
189191
httpGet:

0 commit comments

Comments
 (0)