Browse Source

Add support for mount path in ldap auth

Brent Spector 4 years ago
parent
commit
561bd3ae56

+ 5 - 0
apis/externalsecrets/v1alpha1/secretstore_vault_types.go

@@ -173,6 +173,11 @@ type VaultKubernetesAuth struct {
 // VaultLdapAuth authenticates with Vault using the LDAP authentication method,
 // VaultLdapAuth authenticates with Vault using the LDAP authentication method,
 // with the username and password stored in a Kubernetes Secret resource.
 // with the username and password stored in a Kubernetes Secret resource.
 type VaultLdapAuth struct {
 type VaultLdapAuth struct {
+	// Path where the LDAP authentication backend is mounted
+	// in Vault, e.g: "ldap"
+	// +kubebuilder:default=ldap
+	Path string `json:"path"`
+	
 	// Username is a LDAP user name used to authenticate using the LDAP Vault
 	// Username is a LDAP user name used to authenticate using the LDAP Vault
 	// authentication method
 	// authentication method
 	Username string `json:"username"`
 	Username string `json:"username"`

+ 6 - 0
deploy/crds/external-secrets.io_clustersecretstores.yaml

@@ -800,6 +800,11 @@ spec:
                               username/password pair using the LDAP authentication
                               username/password pair using the LDAP authentication
                               method
                               method
                             properties:
                             properties:
+                              path:
+                                default: ldap
+                                description: 'Path where the LDAP authentication backend
+                                  is mounted in Vault, e.g: "ldap"'
+                                type: string
                               secretRef:
                               secretRef:
                                 description: SecretRef to a key in a Secret resource
                                 description: SecretRef to a key in a Secret resource
                                   containing password for the LDAP user used to authenticate
                                   containing password for the LDAP user used to authenticate
@@ -828,6 +833,7 @@ spec:
                                   method
                                   method
                                 type: string
                                 type: string
                             required:
                             required:
+                            - path
                             - username
                             - username
                             type: object
                             type: object
                           tokenSecretRef:
                           tokenSecretRef:

+ 6 - 0
deploy/crds/external-secrets.io_secretstores.yaml

@@ -800,6 +800,11 @@ spec:
                               username/password pair using the LDAP authentication
                               username/password pair using the LDAP authentication
                               method
                               method
                             properties:
                             properties:
+                              path:
+                                default: ldap
+                                description: 'Path where the LDAP authentication backend
+                                  is mounted in Vault, e.g: "ldap"'
+                                type: string
                               secretRef:
                               secretRef:
                                 description: SecretRef to a key in a Secret resource
                                 description: SecretRef to a key in a Secret resource
                                   containing password for the LDAP user used to authenticate
                                   containing password for the LDAP user used to authenticate
@@ -828,6 +833,7 @@ spec:
                                   method
                                   method
                                 type: string
                                 type: string
                             required:
                             required:
+                            - path
                             - username
                             - username
                             type: object
                             type: object
                           tokenSecretRef:
                           tokenSecretRef:

+ 5 - 3
docs/provider-hashicorp-vault.md

@@ -77,10 +77,12 @@ Vault supports only simple key/value pairs - nested objects are not supported. H
 
 
 ### Authentication
 ### Authentication
 
 
-We support three different modes for authentication:
+We support five different modes for authentication:
 [token-based](https://www.vaultproject.io/docs/auth/token),
 [token-based](https://www.vaultproject.io/docs/auth/token),
-[appRole](https://www.vaultproject.io/docs/auth/approle) and
-[kubernetes-native](https://www.vaultproject.io/docs/auth/kubernetes), each one comes with it's own
+[appRole](https://www.vaultproject.io/docs/auth/approle),
+[kubernetes-native](https://www.vaultproject.io/docs/auth/kubernetes),
+[ldap](https://www.vaultproject.io/docs/auth/ldap) and
+[jwt/odic](https://www.vaultproject.io/docs/auth/jwt), each one comes with it's own
 trade-offs. Depending on the authentication method you need to adapt your environment.
 trade-offs. Depending on the authentication method you need to adapt your environment.
 
 
 #### Token-based authentication
 #### Token-based authentication

+ 2 - 0
docs/snippets/vault-ldap-store.yaml

@@ -13,6 +13,8 @@ spec:
         # VaultLdap authenticates with Vault using the LDAP auth mechanism
         # VaultLdap authenticates with Vault using the LDAP auth mechanism
         # https://www.vaultproject.io/docs/auth/ldap
         # https://www.vaultproject.io/docs/auth/ldap
         ldap:
         ldap:
+        # Path where the LDAP authentication backend is mounted
+          path: "ldap"
           # LDAP username
           # LDAP username
           username: "username"
           username: "username"
           secretRef:
           secretRef:

+ 1 - 1
pkg/provider/vault/vault.go

@@ -633,7 +633,7 @@ func (v *client) requestTokenWithLdapAuth(ctx context.Context, client Client, ld
 	parameters := map[string]string{
 	parameters := map[string]string{
 		"password": password,
 		"password": password,
 	}
 	}
-	url := strings.Join([]string{"/v1", "auth", "ldap", "login", username}, "/")
+	url := strings.Join([]string{"/v1", "auth", ldapAuth.Path, "login", username}, "/")
 	request := client.NewRequest("POST", url)
 	request := client.NewRequest("POST", url)
 
 
 	err = request.SetJSONBody(parameters)
 	err = request.SetJSONBody(parameters)