vault

package module
v0.0.0-...-770cca3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2020 License: MIT Imports: 18 Imported by: 1

README

Golang-Vault

A simple password protected key-value trust store for go-lang applications.

Pre-requisites :

  • github.com/boltdb/bolt
  • github.com/gorilla/mux

Install dependencies

go get -u github.com/boltdb/bolt
go get -u github.com/gorilla/mux

Generate Executable

go build -o vault cmd/main.go

Usage

vault
  -p <Required. Password that has to be set for the vault>
  -i <Optional. Input JSON file with data that will be added to the vault>
  -o <Optional. Output filename. Defaults to db.valut>

Documentation

Index

Constants

View Source
const DEFAULTBUCKETNAME = "ODP"

DEFAULTBUCKETNAME - default bucket name for BoltDB

View Source
const DEFAULTPASSWORDKEYNAME = "_PASSWORD"

DEFAULTPASSWORDKEYNAME - default key name for password

View Source
const DEFAULTRANDOMKEYNAME = "_HASH"

DEFAULTRANDOMKEYNAME - default key name for encryption random string

View Source
const RANDOMSTRINGLENGTH = 16

RANDOMSTRINGLENGTH - length of random string for encryption

View Source
const TEMPTRUSTORESPATH = ".\\temp"

Variables

This section is empty.

Functions

func CreateMd5Hash

func CreateMd5Hash(value string) string

CreateMd5Hash - get md5 hash of some value

func Decrypt

func Decrypt(data []byte, passphrase string) ([]byte, error)

Decrypt - decrypt ciphertext using password

func DownloadTruststore

func DownloadTruststore(w http.ResponseWriter, req *http.Request)

DownloadTruststore - download trustore request

func DownloadTruststoreCLI

func DownloadTruststoreCLI(fileName string, content []byte, password string)

DownloadTruststoreCLI - downloadTrustStore using CLI

func Encrypt

func Encrypt(data []byte, passphrase string) ([]byte, error)

Encrypt - encrypt plaintext using password

func RandomString

func RandomString(n int) string

RandomString - random string generator for specified length

Types

type DB

type DB struct {
	STORE *bolt.DB
	// contains filtered or unexported fields
}

DB - Base truststore struct

func InitDB

func InitDB(filePath string, bucketName string) *DB

InitDB - Initialize trustore

func (*DB) CloseDB

func (store *DB) CloseDB() error

CloseDB - Close the current DB file

func (*DB) Delete

func (store *DB) Delete(key string) error

Delete - Transactional Delete to Bucket

func (*DB) Get

func (store *DB) Get(key string) ([]byte, error)

Get - Transactional Get for a key in specific bucket

func (*DB) Upsert

func (store *DB) Upsert(key string, data []byte) error

Upsert - Transactional Addition/Updation to Bucket

type DownloadRequest

type DownloadRequest struct {
	StorePassword string            `json:"storePassword"`
	Data          map[string]string `json:"data"`
}

DownloadRequest - input structure for download request of trustore

type DownloadResponse

type DownloadResponse struct {
	Vault    string `json:"vault"`
	FileName string `json:"fileName"`
}

DownloadResponse - output response for download request of trustore

type Vault

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

Vault - Base Vault structure

func CreateVault

func CreateVault(filePath string, newPassword string) *Vault

CreateVault - create new vault with specified location and password

func InitVault

func InitVault(filePath string, storePassword string) (*Vault, error)

InitVault - Initialize access to vault

func (*Vault) ChangePassword

func (v *Vault) ChangePassword(newPassword string) error

ChangePassword - change trustore password

func (*Vault) Close

func (v *Vault) Close() error

Close - Close trustore

func (*Vault) Delete

func (v *Vault) Delete(key string) error

Delete - delete a value by key in trustore

func (*Vault) Get

func (v *Vault) Get(key string) ([]byte, error)

Get - get data from trustore

func (*Vault) Upsert

func (v *Vault) Upsert(key string, value string) error

Upsert - add/update value in trustore

type VaultService

type VaultService interface {
	Get(key string) ([]byte, error)
	Upsert(key string, value string) error
	Delete(key string) error
	ChangePassword(newPassword string) error
	Close() error
}

VaultService - task of vault

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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