Skip to content

Commit

Permalink
add comments on source/contents of auth method's parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
eikenb committed Feb 28, 2023
1 parent 6a820cf commit 9803533
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions agent/connect/ca/provider_vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,13 @@ func vaultLogin(client *vaultapi.Client, authMethod *structs.VaultAuthMethod) (*
return resp, nil
}

// Note the authMethod's parameters (Params) is populated from a freeform map
// in the configuration where they could hardcode values to be passed directly
// to the `auth/*/login` endpoint. So each auth method's authentication code
// needs to handle both these cases. The legacy case (which should be
// deprecated) where the user has hardcoded login values directly (eg. a `jwt`
// string) and the case where they use the configuration option used in the
// vault agent's auth methods.
func configureVaultAuthMethod(authMethod *structs.VaultAuthMethod) (VaultAuthenticator, error) {
if authMethod.MountPath == "" {
authMethod.MountPath = authMethod.Type
Expand Down
5 changes: 3 additions & 2 deletions agent/connect/ca/provider_vault_auth_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ func K8sLoginDataGen(authMethod *structs.VaultAuthMethod) (map[string]any, error
params := authMethod.Params
role := params["role"].(string)

// token passed directly
// refactor this to use the hasJWT function as used in the jwt auth
// Note the `jwt` can be passed directly in the authMethod as the it's Params
// is a freeform map in the config where they could hardcode it.
// See comment on configureVaultAuthMethod (in ./provider_vault.go) for more.
if jwt, ok := params["jwt"].(string); ok && strings.TrimSpace(jwt) != "" {
return map[string]any{
"role": role,
Expand Down

0 comments on commit 9803533

Please sign in to comment.