Skip to content

Commit

Permalink
Add AuthenticationStrategy, ManagerDn, ManagerPassword, IdentityStrat…
Browse files Browse the repository at this point in the history
…egy properties for LDAP integration
  • Loading branch information
pashtet04 committed Jun 16, 2023
1 parent bfebbe8 commit cdb44e7
Show file tree
Hide file tree
Showing 8 changed files with 97 additions and 17 deletions.
12 changes: 12 additions & 0 deletions api/v1/nificluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,18 @@ type LdapConfiguration struct {
// Filter for searching for users against the 'User Search Base'.
// (i.e. sAMAccountName={0}). The user specified name is inserted into '{0}'.
SearchFilter string `json:"searchFilter,omitempty"`
// How the connection to the LDAP server is authenticated.
// Possible values are ANONYMOUS, SIMPLE, LDAPS, or START_TLS.
AuthenticationStrategy string `json:"authenticationStrategy,omitempty"`
// The DN of the manager that is used to bind to the LDAP server to search for users.
ManagerDn string `json:"managerDn,omitempty"`
// The password of the manager that is used to bind to the LDAP server to search for users.
ManagerPassword string `json:"managerPassword,omitempty"`
// Strategy to identify users. Possible values are USE_DN and USE_USERNAME.
// The default functionality if this property is missing is USE_DN in order to retain backward compatibility.
// USE_DN will use the full DN of the user entry if possible.
// USE_USERNAME will use the username the user logged in with.
IdentityStrategy string `json:"identityStrategy,omitempty"`
}

// NifiClusterTaskSpec specifies the configuration of the nifi cluster Tasks
Expand Down
24 changes: 16 additions & 8 deletions api/v1alpha1/nificluster_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,14 @@ func convertNifiClusterDisruptionBudget(src DisruptionBudget, dst *v1.NifiCluste

func convertNifiClusterLdapConfiguration(src LdapConfiguration, dst *v1.NifiCluster) {
dst.Spec.LdapConfiguration = v1.LdapConfiguration{
Enabled: src.Enabled,
Url: src.Url,
SearchBase: src.SearchBase,
SearchFilter: src.SearchFilter,
Enabled: src.Enabled,
Url: src.Url,
SearchBase: src.SearchBase,
SearchFilter: src.SearchFilter,
AuthenticationStrategy: src.AuthenticationStrategy,
ManagerDn: src.ManagerDn,
ManagerPassword: src.ManagerPassword,
IdentityStrategy: src.IdentityStrategy,
}
}

Expand Down Expand Up @@ -755,10 +759,14 @@ func convertNifiClusterFromDisruptionBudget(src v1.DisruptionBudget, dst *NifiCl

func convertNifiClusterFromLdapConfiguration(src v1.LdapConfiguration, dst *NifiCluster) {
dst.Spec.LdapConfiguration = LdapConfiguration{
Enabled: src.Enabled,
Url: src.Url,
SearchBase: src.SearchBase,
SearchFilter: src.SearchFilter,
Enabled: src.Enabled,
Url: src.Url,
SearchBase: src.SearchBase,
SearchFilter: src.SearchFilter,
AuthenticationStrategy: src.AuthenticationStrategy,
ManagerDn: src.ManagerDn,
ManagerPassword: src.ManagerPassword,
IdentityStrategy: src.IdentityStrategy,
}
}

Expand Down
18 changes: 13 additions & 5 deletions api/v1alpha1/nificluster_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ func assertNifiClustersEqual(anc *NifiCluster, nc *v1.NifiCluster, t *testing.T)
if anc.Spec.LdapConfiguration.Enabled != nc.Spec.LdapConfiguration.Enabled ||
anc.Spec.LdapConfiguration.SearchBase != nc.Spec.LdapConfiguration.SearchBase ||
anc.Spec.LdapConfiguration.SearchFilter != nc.Spec.LdapConfiguration.SearchFilter ||
anc.Spec.LdapConfiguration.Url != nc.Spec.LdapConfiguration.Url {
anc.Spec.LdapConfiguration.Url != nc.Spec.LdapConfiguration.Url ||
anc.Spec.LdapConfiguration.AuthenticationStrategy != nc.Spec.LdapConfiguration.AuthenticationStrategy ||
anc.Spec.LdapConfiguration.ManagerDn != nc.Spec.LdapConfiguration.ManagerDn ||
anc.Spec.LdapConfiguration.ManagerPassword != nc.Spec.LdapConfiguration.ManagerPassword ||
anc.Spec.LdapConfiguration.IdentityStrategy != nc.Spec.LdapConfiguration.IdentityStrategy {
t.Error("LDAP configurations are not equal")
}
if anc.Spec.NifiClusterTaskSpec.RetryDurationMinutes != nc.Spec.NifiClusterTaskSpec.RetryDurationMinutes {
Expand Down Expand Up @@ -432,10 +436,14 @@ func createNifiCluster() *NifiCluster {
Budget: "50",
},
LdapConfiguration: LdapConfiguration{
Enabled: true,
Url: "url",
SearchBase: "searchBase",
SearchFilter: "searchFilter",
Enabled: true,
Url: "url",
SearchBase: "searchBase",
SearchFilter: "searchFilter",
AuthenticationStrategy: "authenticationStrategy",
ManagerDn: "managerDn",
ManagerPassword: "managerPassword",
IdentityStrategy: "identityStrategy",
},
NifiClusterTaskSpec: NifiClusterTaskSpec{
RetryDurationMinutes: 5,
Expand Down
12 changes: 12 additions & 0 deletions api/v1alpha1/nificluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,18 @@ type LdapConfiguration struct {
// Filter for searching for users against the 'User Search Base'.
// (i.e. sAMAccountName={0}). The user specified name is inserted into '{0}'.
SearchFilter string `json:"searchFilter,omitempty"`
// How the connection to the LDAP server is authenticated.
// Possible values are ANONYMOUS, SIMPLE, LDAPS, or START_TLS.
AuthenticationStrategy string `json:"authenticationStrategy,omitempty"`
// The DN of the manager that is used to bind to the LDAP server to search for users.
ManagerDn string `json:"managerDn,omitempty"`
// The password of the manager that is used to bind to the LDAP server to search for users.
ManagerPassword string `json:"managerPassword,omitempty"`
// Strategy to identify users. Possible values are USE_DN and USE_USERNAME.
// The default functionality if this property is missing is USE_DN in order to retain backward compatibility.
// USE_DN will use the full DN of the user entry if possible.
// USE_USERNAME will use the username the user logged in with.
IdentityStrategy string `json:"identityStrategy,omitempty"`
}

// NifiClusterTaskSpec specifies the configuration of the nifi cluster Tasks
Expand Down
16 changes: 16 additions & 0 deletions config/crd/bases/nifi.konpyutaika.com_nificlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,16 @@ spec:
type: array
ldapConfiguration:
properties:
authenticationStrategy:
type: string
enabled:
type: boolean
identityStrategy:
type: string
managerDn:
type: string
managerPassword:
type: string
searchBase:
type: string
searchFilter:
Expand Down Expand Up @@ -5031,8 +5039,16 @@ spec:
type: array
ldapConfiguration:
properties:
authenticationStrategy:
type: string
enabled:
type: boolean
identityStrategy:
type: string
managerDn:
type: string
managerPassword:
type: string
searchBase:
type: string
searchFilter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,14 @@ spec:
description: Space-separated list of URLs of the LDAP servers (i.e.
ldap://<hostname>:<port>).
type: string
authenticationStrategy:
type: string
managerDn:
type: string
managerPassword:
type: string
identityStrategy:
type: string
type: object
listenersConfig:
description: listenerConfig specifies nifi's listener specifig configs
Expand Down
16 changes: 16 additions & 0 deletions helm/nifikop/crds/nifi.konpyutaika.com_nificlusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,16 @@ spec:
type: array
ldapConfiguration:
properties:
authenticationStrategy:
type: string
enabled:
type: boolean
identityStrategy:
type: string
managerDn:
type: string
managerPassword:
type: string
searchBase:
type: string
searchFilter:
Expand Down Expand Up @@ -5031,8 +5039,16 @@ spec:
type: array
ldapConfiguration:
properties:
authenticationStrategy:
type: string
enabled:
type: boolean
identityStrategy:
type: string
managerDn:
type: string
managerPassword:
type: string
searchBase:
type: string
searchFilter:
Expand Down
8 changes: 4 additions & 4 deletions pkg/resources/templates/config/login_identity_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ var LoginIdentityProvidersTemplate = `<?xml version="1.0" encoding="UTF-8" stand
<provider>
<identifier>ldap-provider</identifier>
<class>org.apache.nifi.ldap.LdapProvider</class>
<property name="Authentication Strategy">START_TLS</property>
<property name="Manager DN"></property>
<property name="Manager Password"></property>
<property name="Authentication Strategy">{{.LdapConfiguration.AuthenticationStrategy}}</property>
<property name="Manager DN">{{.LdapConfiguration.ManagerDn}}</property>
<property name="Manager Password">{{.LdapConfiguration.ManagerPassword}}</property>
<property name="TLS - Keystore"></property>
<property name="TLS - Keystore Password"></property>
<property name="TLS - Keystore Type"></property>
Expand All @@ -87,7 +87,7 @@ var LoginIdentityProvidersTemplate = `<?xml version="1.0" encoding="UTF-8" stand
<property name="Url">{{.LdapConfiguration.Url}}</property>
<property name="User Search Base">{{.LdapConfiguration.SearchBase}}</property>
<property name="User Search Filter">{{.LdapConfiguration.SearchFilter}}</property>
<property name="Identity Strategy">USE_DN</property>
<property name="Identity Strategy">{{.LdapConfiguration.IdentityStrategy}}</property>
<property name="Authentication Expiration">12 hours</property>
</provider>
{{end}}
Expand Down

0 comments on commit cdb44e7

Please sign in to comment.