-
Notifications
You must be signed in to change notification settings - Fork 45
/
active_directory_settings.go
417 lines (326 loc) · 12 KB
/
active_directory_settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"encoding/json"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
"github.com/go-openapi/validate"
)
// ActiveDirectorySettings Elasticsearch Security Active Directory realm configuration
//
// swagger:model ActiveDirectorySettings
type ActiveDirectorySettings struct {
// When true, bindDb credentials are ignored
// Required: true
BindAnonymously *bool `json:"bind_anonymously"`
// The distinguished name of the user that is used to bind to the Active Directory and perform searches.
BindDn string `json:"bind_dn,omitempty"`
// The user password that is used to bind to the Active Directory server.
BindPassword string `json:"bind_password,omitempty"`
// The SSL trusted CA certificate bundle URL. The bundle should be a zip file containing a single keystore file 'keystore.ks' in the directory '/active_directory/:id/truststore', where :id is the value of the [id] field.
CertificateURL string `json:"certificate_url,omitempty"`
// The password to the certificate bundle URL truststore
CertificateURLTruststorePassword string `json:"certificate_url_truststore_password,omitempty"`
// The format of the truststore file. Should be jks to use the Java Keystore format or PKCS12 to use PKCS#12 files. The default is jks.
// Enum: [jks PKCS12]
CertificateURLTruststoreType string `json:"certificate_url_truststore_type,omitempty"`
// Specifies the domain name of the Active Directory (the forest root domain name).
// Required: true
DomainName *string `json:"domain_name"`
// When true, enables the security realm
Enabled *bool `json:"enabled,omitempty"`
// The Active Directory group search configuration
GroupSearch *ActiveDirectoryGroupSearch `json:"group_search,omitempty"`
// The identifier for the security realm
// Required: true
ID *string `json:"id"`
// The Active Directory load balancing behavior
LoadBalance *ActiveDirectorySecurityRealmLoadBalance `json:"load_balance,omitempty"`
// The friendly name of the security realm
// Required: true
Name *string `json:"name"`
// The order that the security realm is evaluated
Order int32 `json:"order,omitempty"`
// Advanced configuration options in YAML format. Any settings defined here will override any configuration set via the API. Note that all keys should omit the 'xpack.security.authc.realms.active_directory.{realm_id}' prefix. For example, when the realm ID is set to 'ad1', the advanced configuration 'xpack.security.authc.realms.active_directory.ad1.ssl.verification_mode: full' should be added as 'ssl.verification_mode: full'.
OverrideYaml string `json:"override_yaml,omitempty"`
// The role mapping rules associated with the security realm
RoleMappings *ActiveDirectorySecurityRealmRoleMappingRules `json:"role_mappings,omitempty"`
// The Active Directory URLs used to authenticate against, in the format ldap[s]://server:port. Note that ldap and ldaps protocols cannot be mixed together.
// Required: true
Urls []string `json:"urls"`
// The Active Directory user search configuration.
UserSearch *ActiveDirectoryUserSearch `json:"user_search,omitempty"`
}
// Validate validates this active directory settings
func (m *ActiveDirectorySettings) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateBindAnonymously(formats); err != nil {
res = append(res, err)
}
if err := m.validateCertificateURLTruststoreType(formats); err != nil {
res = append(res, err)
}
if err := m.validateDomainName(formats); err != nil {
res = append(res, err)
}
if err := m.validateGroupSearch(formats); err != nil {
res = append(res, err)
}
if err := m.validateID(formats); err != nil {
res = append(res, err)
}
if err := m.validateLoadBalance(formats); err != nil {
res = append(res, err)
}
if err := m.validateName(formats); err != nil {
res = append(res, err)
}
if err := m.validateRoleMappings(formats); err != nil {
res = append(res, err)
}
if err := m.validateUrls(formats); err != nil {
res = append(res, err)
}
if err := m.validateUserSearch(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *ActiveDirectorySettings) validateBindAnonymously(formats strfmt.Registry) error {
if err := validate.Required("bind_anonymously", "body", m.BindAnonymously); err != nil {
return err
}
return nil
}
var activeDirectorySettingsTypeCertificateURLTruststoreTypePropEnum []interface{}
func init() {
var res []string
if err := json.Unmarshal([]byte(`["jks","PKCS12"]`), &res); err != nil {
panic(err)
}
for _, v := range res {
activeDirectorySettingsTypeCertificateURLTruststoreTypePropEnum = append(activeDirectorySettingsTypeCertificateURLTruststoreTypePropEnum, v)
}
}
const (
// ActiveDirectorySettingsCertificateURLTruststoreTypeJks captures enum value "jks"
ActiveDirectorySettingsCertificateURLTruststoreTypeJks string = "jks"
// ActiveDirectorySettingsCertificateURLTruststoreTypePKCS12 captures enum value "PKCS12"
ActiveDirectorySettingsCertificateURLTruststoreTypePKCS12 string = "PKCS12"
)
// prop value enum
func (m *ActiveDirectorySettings) validateCertificateURLTruststoreTypeEnum(path, location string, value string) error {
if err := validate.EnumCase(path, location, value, activeDirectorySettingsTypeCertificateURLTruststoreTypePropEnum, true); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateCertificateURLTruststoreType(formats strfmt.Registry) error {
if swag.IsZero(m.CertificateURLTruststoreType) { // not required
return nil
}
// value enum
if err := m.validateCertificateURLTruststoreTypeEnum("certificate_url_truststore_type", "body", m.CertificateURLTruststoreType); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateDomainName(formats strfmt.Registry) error {
if err := validate.Required("domain_name", "body", m.DomainName); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateGroupSearch(formats strfmt.Registry) error {
if swag.IsZero(m.GroupSearch) { // not required
return nil
}
if m.GroupSearch != nil {
if err := m.GroupSearch.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("group_search")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("group_search")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) validateID(formats strfmt.Registry) error {
if err := validate.Required("id", "body", m.ID); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateLoadBalance(formats strfmt.Registry) error {
if swag.IsZero(m.LoadBalance) { // not required
return nil
}
if m.LoadBalance != nil {
if err := m.LoadBalance.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("load_balance")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("load_balance")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) validateName(formats strfmt.Registry) error {
if err := validate.Required("name", "body", m.Name); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateRoleMappings(formats strfmt.Registry) error {
if swag.IsZero(m.RoleMappings) { // not required
return nil
}
if m.RoleMappings != nil {
if err := m.RoleMappings.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("role_mappings")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("role_mappings")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) validateUrls(formats strfmt.Registry) error {
if err := validate.Required("urls", "body", m.Urls); err != nil {
return err
}
return nil
}
func (m *ActiveDirectorySettings) validateUserSearch(formats strfmt.Registry) error {
if swag.IsZero(m.UserSearch) { // not required
return nil
}
if m.UserSearch != nil {
if err := m.UserSearch.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("user_search")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("user_search")
}
return err
}
}
return nil
}
// ContextValidate validate this active directory settings based on the context it is used
func (m *ActiveDirectorySettings) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateGroupSearch(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateLoadBalance(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateRoleMappings(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateUserSearch(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *ActiveDirectorySettings) contextValidateGroupSearch(ctx context.Context, formats strfmt.Registry) error {
if m.GroupSearch != nil {
if err := m.GroupSearch.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("group_search")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("group_search")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) contextValidateLoadBalance(ctx context.Context, formats strfmt.Registry) error {
if m.LoadBalance != nil {
if err := m.LoadBalance.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("load_balance")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("load_balance")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) contextValidateRoleMappings(ctx context.Context, formats strfmt.Registry) error {
if m.RoleMappings != nil {
if err := m.RoleMappings.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("role_mappings")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("role_mappings")
}
return err
}
}
return nil
}
func (m *ActiveDirectorySettings) contextValidateUserSearch(ctx context.Context, formats strfmt.Registry) error {
if m.UserSearch != nil {
if err := m.UserSearch.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("user_search")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("user_search")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *ActiveDirectorySettings) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *ActiveDirectorySettings) UnmarshalBinary(b []byte) error {
var res ActiveDirectorySettings
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}