Documentation ¶
Overview ¶
Package crypter implements an encryption services. the main purpose is to encrypt files / binary payloads. initial implementation focuses on PDF files
Index ¶
- Variables
- func EndpointLoggingMiddleware(logger logging.Logger, endpointName string) endpoint.Middleware
- func MakeEncryptEndpoint(s EncryptionService) endpoint.Endpoint
- func NewGRPCServer(endpoints Endpoints, logger logging.Logger) proto.CrypterServer
- type AppConfig
- type Claim
- type EncryptionService
- type Endpoints
- type Environment
- type LogConfig
- type PayloadType
- type Request
- type Response
- type ServiceMiddleware
- type TokenSecurity
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvlaidPayloadType tells the caller that encryption is not possible fo the supplied payload-type ErrInvlaidPayloadType = errors.New("invalid payload type supplied") )
Functions ¶
func EndpointLoggingMiddleware ¶
func EndpointLoggingMiddleware(logger logging.Logger, endpointName string) endpoint.Middleware
EndpointLoggingMiddleware returns an endpoint middleware that logs the duration of each invocation, and the resulting error, if any.
func MakeEncryptEndpoint ¶
func MakeEncryptEndpoint(s EncryptionService) endpoint.Endpoint
MakeEncryptEndpoint constructs an Encrypt endpoint wrapping the service.
func NewGRPCServer ¶
func NewGRPCServer(endpoints Endpoints, logger logging.Logger) proto.CrypterServer
NewGRPCServer makes endpoints available as a gRPC CrypterServer.
Types ¶
type AppConfig ¶
type AppConfig struct { TokenSecurity TokenSecurity Logging LogConfig Environment Environment ServiceName string HostID string }
AppConfig holds the application configuration
type EncryptionService ¶
type EncryptionService interface { // Encrypt uses the supplied token to validate the user and encrypts the provided payload // The encryption is performend using the supplied passwords. Encrypt(ctx context.Context, req Request) ([]byte, error) }
EncryptionService describes a service that encrypts payloads
func NewGRPCClient ¶
func NewGRPCClient(conn *grpc.ClientConn) EncryptionService
NewGRPCClient returns a EncryptionService backed by a gRPC server at the other end of the conn. The caller is responsible for constructing the conn, and eventually closing the underlying transport. We bake-in certain middlewares, implementing the client library pattern.
func NewService ¶
func NewService(logger logging.Logger, tokenSetting TokenSecurity) EncryptionService
NewService returns a Service with all of the expected middlewares wired in.
type Endpoints ¶
Endpoints collects all of the endpoints that compose a service. It's meant to be used as a helper struct, to collect all of the endpoints into a single parameter. An endpoint is needed per service method.
func NewEndpoints ¶
func NewEndpoints(svc EncryptionService, logger logging.Logger) Endpoints
NewEndpoints returns Endpoints which wrap the provided server, and wires in all of the expected endpoint middlewares via the various parameters.
type Environment ¶
type Environment string
Environment specifies operation modes
const ( // Development is used in development Development Environment = "Development" // Production is used for deployments Production Environment = "Production" )
type LogConfig ¶
type LogConfig struct { FilePath string LogLevel string // GrayLogServer defines the address of a log-aggregator using Graylog GrayLogServer string }
LogConfig is used to define settings for the logging process
type PayloadType ¶
type PayloadType string
PayloadType enumerates the available payload types
const ( // PDF is a payload of application/pdf PDF PayloadType = "PDF" )
type Request ¶
type Request struct { AuthToken string Payload []byte Type PayloadType InitPass string NewPass string }
Request combines the parameters passed on to the encryption service
type Response ¶
type Response struct { Payload []byte `json:"payload"` Err error `json:"-"` // should be intercepted by Failed/errorEncoder }
Response collects the response values for the Encrypt method.
type ServiceMiddleware ¶
type ServiceMiddleware func(EncryptionService) EncryptionService
ServiceMiddleware describes a service (as opposed to endpoint) middleware. it is used to intercept the method execution and perform actions before/after the serivce method execution
func ServiceLoggingMiddleware ¶
func ServiceLoggingMiddleware(logger logging.Logger) ServiceMiddleware
ServiceLoggingMiddleware takes a logger as a dependency and returns a ServiceLoggingMiddleware.