httpsign

package
v0.0.0-...-ea7d51e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAuthorizationHeader error when get invalid format of Authorization header
	ErrInvalidAuthorizationHeader = newPublicError("Authorization header format is incorrect")
	// ErrInvalidKeyID error when KeyID in header does not provided
	ErrInvalidKeyID = newPublicError("Invalid keyId")
	// ErrDateNotFound error when no date in header
	ErrDateNotFound = newPublicError("There is no Date on Headers")
	// ErrIncorrectAlgorithm error when Algorithm in header does not match with secret key
	ErrIncorrectAlgorithm = newPublicError("Algorithm does not match")
	// ErrHeaderNotEnough error when requirements header do not appear on header field
	ErrHeaderNotEnough = newPublicError("Header field is not match requirement")
	// ErrNoSignature error when no Signature not found in header
	ErrNoSignature = newPublicError("No Signature header found in request")
	// ErrInvalidSign error when signing string do not match
	ErrInvalidSign = newPublicError("Invalid sign")
	// ErrMissingKeyID error when keyId not in header
	ErrMissingKeyID = newPublicError("keyId must be on header")
	// ErrMissingSignature error when signature not in header
	ErrMissingSignature = newPublicError("signature must be on header")

	// ErrUnterminatedParameter err when could not parse value
	ErrUnterminatedParameter = newPublicError("Unterminated parameter")
	// ErrMisingDoubleQuote err when after character = not have double quote
	ErrMisingDoubleQuote = newPublicError(`Missing " after = character`)
	// ErrMisingEqualCharacter err when there is no character = before " or , character
	ErrMisingEqualCharacter = newPublicError(`Missing = character =`)
)

Functions

This section is empty.

Types

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(options ...Option) *Authenticator

func (*Authenticator) Authenticated

func (a *Authenticator) Authenticated() gin.HandlerFunc

type EncryptionKey

type EncryptionKey interface {
	Secret(ctx context.Context, keyID KeyID) (*Secret, error)
}

type KeyID

type KeyID string

type Option

type Option func(*Authenticator)

func WithEncryptKey

func WithEncryptKey(e EncryptionKey) Option

func WithRequiredHeaders

func WithRequiredHeaders(headers []string) Option

func WithValidator

func WithValidator(validators ...validator.Validator) Option

type Secret

type Secret struct {
	Key       string
	Algorithm secret.Crypto
}

type Secrets

type Secrets struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSecrets

func NewSecrets() *Secrets

type SignatureHeader

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

func NewSignatureHeader

func NewSignatureHeader(r *http.Request) (*SignatureHeader, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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