auth

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSessionKey is thrown when no key was provided for HMAC signing
	ErrNoSessionKey = errors.New("no session key")
	// ErrMalformedSession is thrown when the session value doesn't conform to expectations
	ErrMalformedSession = errors.New("malformed session")
	// ErrInvalidSession the signature included with the session can't be verified with the provided session key \
	// or is malformed in some way
	ErrInvalidSession = errors.New("invalid session")
)

note @adam-hanna: can these be constants?

View Source
var (
	// ErrBase64Encode is thrown when a byte slice could not be base64 encoded
	ErrBase64Encode = errors.New("Base64 encoding failed")
	// ErrBase64Decode is thrown when a byte slice could not be base64 decoded
	ErrBase64Decode = errors.New("Base64 decoding failed")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	// Key is a slice of bytes for performing HMAC signing and verification operations
	Key []byte
}

Options defines the behavior of the auth service

type Service

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

Service performs signing and verification actions using HMAC

func New

func New(options Options) (*Service, error)

New returns a new auth service

func (*Service) SignAndBase64Encode

func (s *Service) SignAndBase64Encode(sessionID string) (string, error)

SignAndBase64Encode signs the sessionID with the key and returns a base64 encoded string

func (*Service) VerifyAndDecode

func (s *Service) VerifyAndDecode(signed string) (string, error)

VerifyAndDecode takes in a signed session string and returns a sessionID, only if the signed string passes auth verification.

type ServiceInterface

type ServiceInterface interface {
	SignAndBase64Encode(sessionID string) (string, error)
	VerifyAndDecode(signed string) (string, error)
}

ServiceInterface defines the methods that are performend by the auth service

Jump to

Keyboard shortcuts

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