feat: add API support for additional LDAP auth method fields. (#3679)
* feat (auth/ldap): add Repo support for max page size and deref aliases (#3670) * chore: update cap/ldap dependency This latest version of cap/ldap adds support for MaxPageSize and DerefAliases * feat (auth/ldap): add MaxPageSize and DerefAliases to storage proto * feat (api/authmethods): add new ldap fields. Add support for maximum_page_size and dereference_aliases * feat (auth/ldap): schema changes to support new LDAP attributes * feat (auth/ldap): add Repo support for max page size and deref aliases * feat (handlers/ldap): add support for new fields (#3674) Added API support for new ldap fields: MaximumPageSize and DereferenceAliases * chore: add CHANGELOG entry for new api auth ldap fields
This commit is contained in:
28 files changed
+1166
-237
No files matched your search
@@ -31,7 +31,8 @@ type AuthMethod struct {
|
||||
//
|
||||
// Supports the options: WithUrls, WithName, WithDescription, WithStartTLS,
|
||||
// WithInsecureTLS, WithDiscoverDN, WithAnonGroupSearch, WithUpnDomain,
|
||||
// WithUserSearchConf, WithGroupSearchConf, WithCertificates, WithBindCredential
|
||||
// WithUserSearchConf, WithGroupSearchConf, WithCertificates,
|
||||
// WithBindCredential, WithDerefAliases, WithMaximumPageSize
|
||||
// are the only valid options and all other options are ignored.
|
||||
func NewAuthMethod(ctx context.Context, scopeId string, opt ...Option) (*AuthMethod, error) {
|
||||
const op = "ldap.NewAuthMethod"
|
||||
@@ -69,6 +70,8 @@ func NewAuthMethod(ctx context.Context, scopeId string, opt ...Option) (*AuthMet
|
||||
Certificates: opts.withCertificates,
|
||||
ClientCertificate: opts.withClientCertificate,
|
||||
ClientCertificateKey: opts.withClientCertificateKey,
|
||||
DereferenceAliases: string(opts.withDerefAliases),
|
||||
MaximumPageSize: uint32(opts.withMaximumPageSize),
|
||||
},
|
||||
}
|
||||
if len(opts.withAccountAttributeMap) > 0 {
|
||||
@@ -139,6 +142,7 @@ type convertedValues struct {
|
||||
ClientCertificate any
|
||||
BindCredential any
|
||||
AccountAttributeMaps []any
|
||||
DerefAliases any
|
||||
}
|
||||
|
||||
// convertValueObjects converts the embedded value objects. It will return an
|
||||
@@ -180,6 +184,11 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues
|
||||
if converted.AccountAttributeMaps, err = am.convertAccountAttributeMaps(ctx); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if am.DereferenceAliases != "" {
|
||||
if converted.DerefAliases, err = am.convertDerefAliases(ctx); err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
|
||||
return converted, nil
|
||||
}
|
||||
@@ -286,6 +295,21 @@ func (am *AuthMethod) convertBindCredential(ctx context.Context) (any, error) {
|
||||
return bc, nil
|
||||
}
|
||||
|
||||
// convertDerefAliases converts an embedded deref aliases entry into
|
||||
// an any type. It will return an error if the AuthMethod's public id is not
|
||||
// set.
|
||||
func (am *AuthMethod) convertDerefAliases(ctx context.Context) (any, error) {
|
||||
const op = "ldap.(AuthMethod).convertDerefAliases"
|
||||
if am.PublicId == "" {
|
||||
return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id")
|
||||
}
|
||||
da, err := NewDerefAliases(ctx, am.PublicId, DerefAliasType(am.DereferenceAliases))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return da, nil
|
||||
}
|
||||
|
||||
// convertAccountAttributeMaps converts the embedded account attribute maps from
|
||||
// []string to []interface{} where each slice element is a *AccountAttributeMap. It
|
||||
// will return an error if the AuthMethod's public id is not set or it can
|
||||
|
||||
Reference in new issue
Block a user