sigauth

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSignatureString

func BuildSignatureString(r *http.Request, headers []string) (string, error)

BuildSignatureString builds the string to be signed for the provided request

"headers" specify which headers to include in the signature string

func GetRequestDigest

func GetRequestDigest(r *http.Request) (string, error)

GetRequestDigest returns the SHA256 digest of the provided request body

func GetRequestLine

func GetRequestLine(r *http.Request) string

GetRequestLine returns the request line for the provided request

Types

type SignatureAuth

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

SignatureAuth contains configurations and helper functions required to validate signatures

func NewSignatureAuth

func NewSignatureAuth(serviceKey *rsa.PrivateKey, authService *authservice.AuthService) (*SignatureAuth, error)

NewSignatureAuth creates and configures a new SignatureAuth instance

func (*SignatureAuth) CheckRequestSignature

func (s *SignatureAuth) CheckRequestSignature(r *http.Request, requiredServiceIDs []string) (string, error)

CheckRequestSignature validates the signature on the provided request

The request must be signed by one of the services in requiredServiceIDs. If nil, any valid signature
from a subscribed service will be accepted
Returns the service ID of the signing service

func (*SignatureAuth) CheckSignature

func (s *SignatureAuth) CheckSignature(serviceID string, message []byte, signature string) error

CheckSignature validates the provided message signature from the given service

func (*SignatureAuth) Sign

func (s *SignatureAuth) Sign(message []byte) (string, error)

Sign generates and returns a signature for the provided message

func (*SignatureAuth) SignRequest

func (s *SignatureAuth) SignRequest(r *http.Request) error

SignRequest signs and modifies the provided request with the necessary signature parameters

type SignatureAuthHeader

type SignatureAuthHeader struct {
	KeyId      string   `json:"keyId" validate:"required"`
	Algorithm  string   `json:"algorithm" validate:"required"`
	Headers    []string `json:"headers,omitempty"`
	Extensions string   `json:"extensions,omitempty"`
	Signature  string   `json:"signature" validate:"required"`
}

SignatureAuthHeader defines the structure of the Authorization header for signature authentication

func ParseSignatureAuthHeader

func ParseSignatureAuthHeader(header string) (*SignatureAuthHeader, error)

ParseSignatureAuthHeader parses a signature Authorization header string

func (*SignatureAuthHeader) Build

func (s *SignatureAuthHeader) Build() (string, error)

Build builds the signature Authorization header string

func (*SignatureAuthHeader) SetField

func (s *SignatureAuthHeader) SetField(field string, value string) error

SetField sets the provided field to the provided value

Jump to

Keyboard shortcuts

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