Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for JWT Auth Method in Golang SDK #28912

Open
vmaffet opened this issue Nov 14, 2024 · 0 comments
Open

Add support for JWT Auth Method in Golang SDK #28912

vmaffet opened this issue Nov 14, 2024 · 0 comments

Comments

@vmaffet
Copy link

vmaffet commented Nov 14, 2024

Problem

Currently, supported auth methods in the Go SDK are limited to:

  • approle
  • aws
  • azure
  • gcp
  • kubernetes
  • ldap
  • userpass

The JWT method is missing from this list.

Prefered Solution

Add support for JWT under github.com/hashicorp/vault/api/auth so that it can be consumed easily.

i.e.

package main

import (
	"context"
	"fmt"

	vault "github.com/hashicorp/vault/api"
	auth "github.com/hashicorp/vault/api/auth/jwt"
)

func example(jwtToken string) (string, error) {
	client, _ := vault.NewClient(nil)

	jwtAuth, err := auth.NewJWTAuth(
		jwtToken,       // JWT token
		"dev-role-jwt", // Vault role
	)
	if err != nil {
		return "", fmt.Errorf("unable to initialize JWT auth method: %w", err)
	}

	authInfo, err := client.Auth().Login(context.Background(), jwtAuth)
	[...]
}

Alternatives

  1. Use https://github.com/hashicorp/vault-client-go which supports it (Beta library - NOT for production)
  2. Code the auth method yourself in a private package.

Additional context

This would make login through GitHub Actions OIDC more straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants