Skip to content

Commit 5464c18

Browse files
authored
Add LDAP support to AtlasDatabaseUser (#2334)
1 parent 9dacbb5 commit 5464c18

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

api/v1/atlasdatabaseuser_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,13 @@ type AtlasDatabaseUserSpec struct {
110110
// +kubebuilder:validation:Enum:=NONE;MANAGED;CUSTOMER
111111
// +optional
112112
X509Type string `json:"x509Type,omitempty"`
113+
114+
// Part of the Lightweight Directory Access Protocol (LDAP) record that
115+
// the database uses to authenticate this database user on the LDAP host.
116+
// +kubebuilder:default:=NONE
117+
// +kubebuilder:validation:Enum:=NONE;GROUP;USER
118+
// +optional
119+
LDAPAuthType string `json:"ldapAuthType,omitempty"`
113120
}
114121

115122
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

config/crd/bases/atlas.mongodb.com_atlasdatabaseusers.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,16 @@ spec:
120120
- value
121121
type: object
122122
type: array
123+
ldapAuthType:
124+
default: NONE
125+
description: |-
126+
Part of the Lightweight Directory Access Protocol (LDAP) record that
127+
the database uses to authenticate this database user on the LDAP host.
128+
enum:
129+
- NONE
130+
- GROUP
131+
- USER
132+
type: string
123133
oidcAuthType:
124134
default: NONE
125135
description: |-

internal/controller/atlasdatabaseuser/databaseuser_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,7 @@ func TestHasChanged(t *testing.T) {
21162116
OIDCAuthType: "NONE",
21172117
AWSIAMType: "NONE",
21182118
X509Type: "NONE",
2119+
LDAPAuthType: "NONE",
21192120
},
21202121
ProjectID: "project-id",
21212122
},
@@ -2126,6 +2127,7 @@ func TestHasChanged(t *testing.T) {
21262127
OIDCAuthType: "NONE",
21272128
AWSIAMType: "NONE",
21282129
X509Type: "NONE",
2130+
LDAPAuthType: "NONE",
21292131
},
21302132
ProjectID: "project-id",
21312133
},
@@ -2141,6 +2143,7 @@ func TestHasChanged(t *testing.T) {
21412143
OIDCAuthType: "NONE",
21422144
AWSIAMType: "NONE",
21432145
X509Type: "MANAGED",
2146+
LDAPAuthType: "NONE",
21442147
},
21452148
ProjectID: "project-id",
21462149
},
@@ -2151,6 +2154,7 @@ func TestHasChanged(t *testing.T) {
21512154
OIDCAuthType: "NONE",
21522155
AWSIAMType: "NONE",
21532156
X509Type: "NONE",
2157+
LDAPAuthType: "NONE",
21542158
},
21552159
ProjectID: "project-id",
21562160
},
@@ -2166,6 +2170,7 @@ func TestHasChanged(t *testing.T) {
21662170
OIDCAuthType: "NONE",
21672171
AWSIAMType: "NONE",
21682172
X509Type: "NONE",
2173+
LDAPAuthType: "NONE",
21692174
},
21702175
ProjectID: "project-id",
21712176
},
@@ -2176,6 +2181,7 @@ func TestHasChanged(t *testing.T) {
21762181
OIDCAuthType: "NONE",
21772182
AWSIAMType: "NONE",
21782183
X509Type: "NONE",
2184+
LDAPAuthType: "NONE",
21792185
},
21802186
ProjectID: "project-id",
21812187
},

internal/translation/dbuser/conversion.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func fromAtlas(dbUser *admin.CloudDatabaseUser) (*User, error) {
133133
OIDCAuthType: dbUser.GetOidcAuthType(),
134134
AWSIAMType: dbUser.GetAwsIAMType(),
135135
X509Type: dbUser.GetX509Type(),
136+
LDAPAuthType: dbUser.GetLdapAuthType(),
136137
},
137138
}
138139
if err := normalize(u.AtlasDatabaseUserSpec); err != nil {
@@ -161,6 +162,7 @@ func toAtlas(au *User) (*admin.CloudDatabaseUser, error) {
161162
Username: au.Username,
162163
Password: pointer.MakePtrOrNil(au.Password),
163164
OidcAuthType: pointer.MakePtrOrNil(au.OIDCAuthType),
165+
LdapAuthType: pointer.MakePtrOrNil(au.LDAPAuthType),
164166
}, nil
165167
}
166168

internal/translation/dbuser/conversion_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ func TestDiffSpecs(t *testing.T) {
272272
spec.OIDCAuthType = "IDP_GROUP"
273273
spec.AWSIAMType = "USER"
274274
spec.X509Type = "MANAGED"
275+
spec.LDAPAuthType = "GROUP"
275276
return spec
276277
}(),
277278
},
@@ -282,6 +283,7 @@ func TestDiffSpecs(t *testing.T) {
282283
"oidcAuthType",
283284
"awsIamType",
284285
"x509Type",
286+
"ldapAuthType",
285287
},
286288
},
287289

0 commit comments

Comments
 (0)