- Added internal/vault/client.go for creating a Vault client with configuration settings. - Introduced internal/vault/errors.go to classify Vault API errors for better UI handling. - Created internal/vault/kv.go to manage KV secrets, including listing, reading, writing, and deleting operations. - Implemented internal/vault/mounts.go to list and describe secret engine mounts. - Developed internal/vault/service.go to provide a unified entry point for Vault operations. - Added internal/vault/kv_test.go for comprehensive testing of KV operations. - Introduced internal/ui/toast.go for transient notifications in the UI. - Added renovate.json for dependency management and updates.
33 lines
928 B
Go
33 lines
928 B
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hashicorp/vault/api"
|
|
)
|
|
|
|
func init() { register(approleMethod{}) }
|
|
|
|
type approleMethod struct{}
|
|
|
|
func (approleMethod) Name() string { return "approle" }
|
|
func (approleMethod) DisplayName() string { return "AppRole" }
|
|
func (approleMethod) DefaultMount() string { return "approle" }
|
|
|
|
func (approleMethod) Fields() []Field {
|
|
return []Field{
|
|
{Name: "role_id", Label: "Role ID", Kind: FieldText, Required: true,
|
|
EnvFallback: []string{"VAULT_ROLE_ID"}},
|
|
{Name: "secret_id", Label: "Secret ID", Kind: FieldSecret, Required: true,
|
|
EnvFallback: []string{"VAULT_SECRET_ID"}},
|
|
}
|
|
}
|
|
|
|
func (approleMethod) Login(ctx context.Context, c *api.Client, req Request) (*api.Secret, error) {
|
|
mount := mountOf(req, "approle")
|
|
return loginWrite(ctx, c, mount, "login", map[string]interface{}{
|
|
"role_id": req.Creds.Get("role_id"),
|
|
"secret_id": req.Creds.Get("secret_id"),
|
|
})
|
|
}
|