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
@@ -53,6 +53,7 @@ const (
|
||||
clientCertificateKeyField = "attributes.client_certificate_key"
|
||||
certificatesField = "attributes.certificates"
|
||||
accountAttributesMapField = "attributes.account_attribute_maps"
|
||||
derefAliasesField = "attributes.dereference_aliases"
|
||||
)
|
||||
|
||||
func (s Service) authenticateLdap(ctx context.Context, req *pbs.AuthenticateRequest, authResults *auth.VerifyResults) (*pbs.AuthenticateResponse, error) {
|
||||
@@ -257,6 +258,12 @@ func toStorageLdapAuthMethod(ctx context.Context, scopeId string, in *pb.AuthMet
|
||||
}
|
||||
opts = append(opts, ldap.WithUrls(ctx, urls...))
|
||||
}
|
||||
if attrs.GetMaximumPageSize() > 0 {
|
||||
opts = append(opts, ldap.WithMaximumPageSize(ctx, attrs.MaximumPageSize))
|
||||
}
|
||||
if attrs.GetDereferenceAliases().GetValue() != "" {
|
||||
opts = append(opts, ldap.WithDerefAliases(ctx, ldap.DerefAliasType(attrs.GetDereferenceAliases().GetValue())))
|
||||
}
|
||||
}
|
||||
u, err := ldap.NewAuthMethod(ctx, scopeId, opts...)
|
||||
if err != nil {
|
||||
@@ -325,6 +332,12 @@ func validateLdapAttributes(ctx context.Context, attrs *pb.LdapAuthMethodAttribu
|
||||
badFields[accountAttributesMapField] = fmt.Sprintf("invalid %s (unable to parse)", accountAttributesMapField)
|
||||
}
|
||||
}
|
||||
if attrs.GetDereferenceAliases().GetValue() != "" {
|
||||
d := ldap.DerefAliasType(attrs.GetDereferenceAliases().GetValue())
|
||||
if err := d.IsValid(ctx); err != nil {
|
||||
badFields[derefAliasesField] = fmt.Sprintf("%s is not a valid %s", attrs.GetDereferenceAliases().GetValue(), derefAliasesField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func validateAuthenticateLdapRequest(req *pbs.AuthenticateRequest) error {
|
||||
|
||||
Reference in new issue
Block a user