auth

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultTTL default signature ttl
	DefaultTTL = time.Minute
	// IdentifierLen identifier's fix length
	IdentifierLen = 6
)
View Source
const (
	// GRPC the grpc method
	GRPC = "GRPC"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Identifier

type Identifier = string

Identifier distinguish what system is displayed, fix length is IdentifierLen

type Method

type Method interface {
	String() string
	Unknow() bool
	// contains filtered or unexported methods
}

Method define supproted http method

var (
	// MethodUnknow unknow
	MethodUnknow Method = &method{value: "UNKNOW"}
	// MethodGet http get
	MethodGet Method = &method{value: http.MethodGet}
	// MethodHead http head
	MethodHead Method = &method{value: http.MethodHead}
	// MethodPost http post
	MethodPost Method = &method{value: http.MethodPost}
	// MethodPut http put
	MethodPut Method = &method{value: http.MethodPut}
	// MethodPatch http patch
	MethodPatch Method = &method{value: http.MethodPatch}
	// MethodDelete http delete
	MethodDelete Method = &method{value: http.MethodDelete}
	// MethodConnect http connect
	MethodConnect Method = &method{value: http.MethodConnect}
	// MethodOptions http options
	MethodOptions Method = &method{value: http.MethodOptions}
	// MethodTrace http trace
	MethodTrace Method = &method{value: http.MethodTrace}
	// MethodGRPC grpc
	MethodGRPC Method = &method{value: GRPC}
)

func ToMethod

func ToMethod(method string) Method

ToMethod convert to method

type Option

type Option func(*option)

Option optional config

func WithMD5

func WithMD5() Option

WithMD5 use md5 hash algorithm

func WithSHA1

func WithSHA1() Option

WithSHA1 use sha1 hash algorithm

func WithSHA256

func WithSHA256() Option

WithSHA256 use sha256 hash algorithm

func WithSecrets

func WithSecrets(secrets map[Identifier]Secret) Option

WithSecrets setup mutli identifier-secret

func WithTTL

func WithTTL(ttl time.Duration) Option

WithTTL setup signature's ttl

type Secret

type Secret = string

Secret symmetric encryption cipher code

type Signature

type Signature interface {
	ResetSecrets(secrets map[Identifier]Secret) error
	Generate(identifier Identifier, method Method, uri string, body []byte) (authorization, date string, err error)
	Verify(authorization, date string, method Method, uri string, body []byte) (identifier Identifier, ok bool, err error)
}

Signature defines methods of signature

func NewSignature

func NewSignature(opts ...Option) (Signature, error)

NewSignature create a new signature instance

Jump to

Keyboard shortcuts

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