vault

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 8 Imported by: 0

README

HashiCorp Vault

HashiCorp Vault using the Transit Secrets Engine for encryption as a service.

Quick Start

Sample Terraform code is available in testing/terraform/vault to try this provider.

Example
package main

import (
	vaultapi "github.com/hashicorp/vault/api"

	"github.com/bincyber/go-sqlcrypter"
	"github.com/bincyber/go-sqlcrypter/providers/vault"
)

func main() {
	// Token will be read from VAULT_TOKEN envvar
	client, err := vaultapi.NewClient(&vaultapi.Config{
		Address: "http://localhost:8200",
	})
	if err != nil {
		// handle error
	}

	vaultCrypter, err := vault.New(client, "transit", "go-sqlcrypter")
	if err != nil {
		// handle err
	}

	sqlcrypter.Init(vaultCrypter)
}
Encryption as a Service

Encryption and decryption of sensitive data is entirely delegated to Vault. The Encrypt and Decrypt endpoints of the Transit secrets engine are used. The data encryption key (DEK) is never accessed by the application. Vault also does not store the data sent to the Transit secrets engine.

Convergent Encryption

Convergent Encryption is not supported at this time.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(client *vaultapi.Client, mount, key string) (sqlcrypter.Crypterer, error)

New creates a new Vault crypter configured to encrypt data using the Transit secrets engine at the specified mount path and key. The latest version of the key is always used to encrypt new data. Convergent Encryption is not supported.

Types

type VaultCrypter

type VaultCrypter struct {
	// contains filtered or unexported fields
}

VaultCrypter is an implementation of the Crypterer interface using HashiCorp Vault's Transit secrets engine.

func (*VaultCrypter) Decrypt

func (v *VaultCrypter) Decrypt(w io.Writer, r io.Reader) error

Decrypt decrypts ciphertext to plaintext using the Transit secret engine's Decrypt endpoint.

See: https://www.vaultproject.io/api-docs/secret/transit#decrypt-data

func (*VaultCrypter) Encrypt

func (v *VaultCrypter) Encrypt(w io.Writer, r io.Reader) error

Encrypt encrypts plaintext to ciphertext using the Transit secret engine's Encrypt endpoint.

See: https://www.vaultproject.io/api-docs/secret/transit#encrypt-data

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL