auth

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultExpireTimeInterval = time.Second * 120

Variables

View Source
var ERR_SIGNATUREEXPIRED = errors.New("signature expired")
View Source
var ERR_SIGNATUREINVALID = func(e error) SIGNATUREINVALIDERR {
	return SIGNATUREINVALIDERR{content: "signature invalid: %w", err: e}
}
View Source
var ERR_UIDINVALID = errors.New("uid invalid")

Functions

func NewDefaultApiAuthenticator added in v0.1.1

func NewDefaultApiAuthenticator() *defaultApiAuthenticator

func NewDefaultApiAuthenticatorAsDriver added in v0.1.1

func NewDefaultApiAuthenticatorAsDriver(driver xcrypt.Encrypt) *defaultApiAuthenticator

Types

type ApiAuthenticator

type ApiAuthenticator interface {
	Request(appId string, pubKey, privKey []byte) string
	Auth(sig string) (string, error)
}

type ApiRequest

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

func NewApiRequest

func NewApiRequest(signature, metadata string, pubKey []byte) *ApiRequest

func NewApiRequestFromToken added in v0.1.1

func NewApiRequestFromToken(token string) (*ApiRequest, error)

func (*ApiRequest) GetMetadata added in v0.1.2

func (t *ApiRequest) GetMetadata() string

func (*ApiRequest) GetPublicKey added in v0.1.2

func (t *ApiRequest) GetPublicKey() []byte

func (*ApiRequest) GetSignature added in v0.1.2

func (t *ApiRequest) GetSignature() string

func (*ApiRequest) GetToken added in v0.1.2

func (t *ApiRequest) GetToken() string

type SIGNATUREINVALIDERR added in v0.1.1

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

func (SIGNATUREINVALIDERR) Error added in v0.1.1

func (e SIGNATUREINVALIDERR) Error() string

func (SIGNATUREINVALIDERR) Unwrap added in v0.1.1

func (e SIGNATUREINVALIDERR) Unwrap() error

type Signatory added in v0.1.1

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

func NewSignatory added in v0.1.1

func NewSignatory(crypt xcrypt.Encrypt, appId string, timestamp int64) *Signatory

func NewSignatoryFromMetadata added in v0.1.1

func NewSignatoryFromMetadata(crypt xcrypt.Encrypt, metadata string) (*Signatory, error)

func (*Signatory) DoSignature added in v0.1.2

func (t *Signatory) DoSignature(privKey []byte) string

func (*Signatory) GetMetadata added in v0.1.2

func (t *Signatory) GetMetadata() string

func (*Signatory) IsExpire added in v0.1.2

func (t *Signatory) IsExpire() bool

func (*Signatory) Match added in v0.1.2

func (t *Signatory) Match(signature string, pubKey []byte) (bool, error)

Jump to

Keyboard shortcuts

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