vaultendpoint

package
v0.0.0-...-01ba355 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SigningKey = []byte("zmh298onj30")

SigningKey is a JWT signing key.

Functions

func InstrumentingMiddleware

func InstrumentingMiddleware(duration metrics.Histogram) endpoint.Middleware

InstrumentingMiddleware returns an endpoint middleware that records the duration of each invocation to the passed histogram. The middleware adds a single field: "success", which is "true" if no error is returned, and "false" otherwise.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) endpoint.Middleware

LoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.

func MakeHashEndpoint

func MakeHashEndpoint(s vaultservice.Service) endpoint.Endpoint

MakeHashEndpoint constructs a Hash endpoint wrapping the service.

func MakeValidateEndpoint

func MakeValidateEndpoint(s vaultservice.Service) endpoint.Endpoint

MakeValidateEndpoint constructs a Validate endpoint wrapping the service.

Types

type HashRequest

type HashRequest struct {
	Password string `json:"password"`
}

type HashResponse

type HashResponse struct {
	Hash string `json:"hash"`
	Err  error  `json:"-"`
}

func (HashResponse) Failed

func (r HashResponse) Failed() error

type Set

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

Set collects all of the endpoints that compose a vault service.

func New

func New(svc vaultservice.Service, duration metrics.Histogram, otTracer stdopentracing.Tracer, zipkinTracer *stdzipkin.Tracer, logger log.Logger) Set

New returns a Set that wraps the provided server, and wires in all of the expected endpoint middlewares via the various parameters

func (Set) Hash

func (s Set) Hash(ctx context.Context, password string) (string, error)

Hash implements vaultservice.Service interface, so Set may be used as a service. This is primarily useful in the context of a client library.

func (Set) Validate

func (s Set) Validate(ctx context.Context, password, hash string) (bool, error)

Validate implements vaultservice.Service interface, so Set may be used as a service. This is primarily useful in the context of a client library.

type ValidateRequest

type ValidateRequest struct {
	Password string `json:"password"`
	Hash     string `json:"hash"`
}

type ValidateResponse

type ValidateResponse struct {
	Valid bool  `json:"valid"`
	Err   error `json:"-"`
}

func (ValidateResponse) Failed

func (r ValidateResponse) Failed() error

Jump to

Keyboard shortcuts

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