Documentation ¶
Index ¶
- func BuildSignatureString(r *http.Request, headers []string) (string, error)
- func GetRequestDigest(r *http.Request) (string, error)
- func GetRequestLine(r *http.Request) string
- type SignatureAuth
- func (s *SignatureAuth) CheckRequestSignature(r *http.Request, requiredServiceIDs []string) (string, error)
- func (s *SignatureAuth) CheckSignature(serviceID string, message []byte, signature string) error
- func (s *SignatureAuth) Sign(message []byte) (string, error)
- func (s *SignatureAuth) SignRequest(r *http.Request) error
- type SignatureAuthHeader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildSignatureString ¶
BuildSignatureString builds the string to be signed for the provided request
"headers" specify which headers to include in the signature string
func GetRequestDigest ¶
GetRequestDigest returns the SHA256 digest of the provided request body
func GetRequestLine ¶
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