vault

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2016 License: MIT Imports: 9 Imported by: 0

README

Usage

Run the vaultd service:

cd vault/cmd/vaultd
go run main.go

Hash a password:

curl -XPOST -d'{"password":"MySecretPassword123"}' localhost:8080/hash
{"hash":"$2a$10$L/Riz9xbgTBDn7F6uLInq.9Tr67PvBCmxzrLgemitnRM53ht7LGpC"}

Validate passwords with hashes:

curl -XPOST -d'{"password":"MySecretPassword123","hash":"$2a$10$L/Riz9xbgTBDn7F6uLInq.9Tr67PvBCmxzrLgemitnRM53ht7LGpC"}' localhost:8080/validate
{"valid":true}

or if you get the password wrong:

curl -XPOST -d'{"password":"NOPE","hash":"$2a$10$L/Riz9xbgTBDn7F6uLInq.9Tr67PvBCmxzrLgemitnRM53ht7LGpC"}' localhost:8080/validate
{"valid":false}

Compiling protobuf

Install proto3 from source:

brew install autoconf automake libtool
git clone https://github.com/google/protobuf
./autogen.sh ; ./configure ; make ; make install

Update protoc Go bindings:

go get -u github.com/golang/protobuf/{proto,protoc-gen-go}

See also https://github.com/grpc/grpc-go/tree/master/examples

Compile the protobuf (from inside pb folder):

protoc vault.proto --go_out=plugins=grpc:.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeGRPCHashRequest

func DecodeGRPCHashRequest(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCHashResponse

func DecodeGRPCHashResponse(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCValidateRequest

func DecodeGRPCValidateRequest(ctx context.Context, r interface{}) (interface{}, error)

func DecodeGRPCValidateResponse

func DecodeGRPCValidateResponse(ctx context.Context, r interface{}) (interface{}, error)

func EncodeGRPCHashRequest

func EncodeGRPCHashRequest(ctx context.Context, r interface{}) (interface{}, error)

func EncodeGRPCHashResponse

func EncodeGRPCHashResponse(ctx context.Context, r interface{}) (interface{}, error)

func EncodeGRPCValidateRequest

func EncodeGRPCValidateRequest(ctx context.Context, r interface{}) (interface{}, error)

func EncodeGRPCValidateResponse

func EncodeGRPCValidateResponse(ctx context.Context, r interface{}) (interface{}, error)

func MakeHashEndpoint

func MakeHashEndpoint(srv Service) endpoint.Endpoint

func MakeValidateEndpoint

func MakeValidateEndpoint(srv Service) endpoint.Endpoint

func NewGRPCServer

func NewGRPCServer(ctx context.Context, endpoints Endpoints) pb.VaultServer

NewGRPCServer gets a new pb.VaultServer.

func NewHTTPServer

func NewHTTPServer(ctx context.Context, endpoints Endpoints) http.Handler

NewHTTPServer makes a new Vault HTTP service.

Types

type Endpoints

type Endpoints struct {
	HashEndpoint     endpoint.Endpoint
	ValidateEndpoint endpoint.Endpoint
}

Endpoints represents all endpoints for the vault Service.

func (Endpoints) Hash

func (e Endpoints) Hash(ctx context.Context, password string) (string, error)

Hash uses the HashEndpoint to hash a password.

func (Endpoints) Validate

func (e Endpoints) Validate(ctx context.Context, password,
	hash string) (bool, error)

Validate uses the ValidateEndpoint to validate a password and hash pair.

type Service

type Service interface {
	Hash(ctx context.Context, password string) (string, error)
	Validate(ctx context.Context, password, hash string) (bool, error)
}

Service provides password hashing capabilities.

func NewService

func NewService() Service

NewService makes a new Service.

Directories

Path Synopsis
client
cmd
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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