middleware

package
v0.0.0-...-b88d7a6 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRSAKey

func GetRSAKey(rsaPrivateKeyLocation, privatePassphrase, rsaPublicKeyLocation string) (*rsa.PrivateKey, error)

GetRSAKey parses the rsa public and private keys

func MetricsRecorder

func MetricsRecorder(next http.Handler) http.Handler

MetricsRecorder is the middleware that records metrics for the request

func RequestFingerprinter

func RequestFingerprinter(next http.Handler) http.Handler

RequestFingerprinter tracks each individual request coming into the system for debugging purposes

Types

type Authenticator

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

Authenticator manages the authentication for requests. It is empty here but could be extended to pull in state (for example if you wanted to check entity auth against a persistent store then you would keep the connection in here).

func NewAuthenticator

func NewAuthenticator(rsaKey *rsa.PublicKey) *Authenticator

NewAuthenticator creates a new authenticator struct that could be used to authenticate requests.

func (Authenticator) Authenticate

func (a Authenticator) Authenticate(next http.Handler) http.Handler

Authenticate authenticates requests for the authenticator

type Claims

type Claims struct {
	jwt.StandardClaims
	EntityID string `json:"entityId"`
}

Claims care the claims in the jwt for authentication

type RequestFingerprint

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

RequestFingerprint manages the fingerprint information for a request. This struct is passed in a context via the http.Request `WithContext` function. This means that anything downstream of the fingerpring will have access to the information within the fingerprint simply by calling the `GetRequestFingerprint(r) function.`

func GetRequestFingerprint

func GetRequestFingerprint(r *http.Request) (f *RequestFingerprint, err error)

GetRequestFingerprint gets the fingerprint of the request

func NewRequestFingerprint

func NewRequestFingerprint(r *http.Request) *RequestFingerprint

NewRequestFingerprint creates a new fingerprint for a request

func (*RequestFingerprint) GetEntity

func (f *RequestFingerprint) GetEntity() (entity string)

GetEntity gets the entity of the request

func (*RequestFingerprint) GetID

func (f *RequestFingerprint) GetID() (id string)

GetID gets the id fingerprint of the request

func (*RequestFingerprint) GetSource

func (f *RequestFingerprint) GetSource() (source string)

GetSource gets the source ip for a request

func (*RequestFingerprint) SetEntity

func (f *RequestFingerprint) SetEntity(entity string)

SetEntity sets the entity for a request fingerprint

Jump to

Keyboard shortcuts

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