auth

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultExpireTimeInterval = time.Second * 120

Variables

View Source
var ErrSignatureExpired = errors.New("signature expired")
View Source
var ErrSignatureInvalid = func(e error) SignatureInvalidError {
	return SignatureInvalidError{content: "signature invalid: %w", err: e}
}
View Source
var ErrUIDInvalid = errors.New("uid invalid")

Functions

This section is empty.

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

func NewAPIRequestFromToken(token string) (*APIRequest, error)

func (*APIRequest) GetMetadata

func (t *APIRequest) GetMetadata() string

func (*APIRequest) GetPublicKey

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

func (*APIRequest) GetSignature

func (t *APIRequest) GetSignature() string

func (*APIRequest) GetToken

func (t *APIRequest) GetToken() string

type DefaultAPIAuthenticator

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

func NewDefaultAPIAuthenticator

func NewDefaultAPIAuthenticator() *DefaultAPIAuthenticator

func NewDefaultAPIAuthenticatorAsDriver

func NewDefaultAPIAuthenticatorAsDriver(driver xcrypt.Encrypt) *DefaultAPIAuthenticator

func (*DefaultAPIAuthenticator) Auth

func (d *DefaultAPIAuthenticator) Auth(token string) (string, error)

func (*DefaultAPIAuthenticator) Request

func (d *DefaultAPIAuthenticator) Request(appId string, pubKey, privKey []byte) string

type Signatory

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

func NewSignatory

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

func NewSignatoryFromMetadata

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

func (*Signatory) DoSignature

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

func (*Signatory) GetMetadata

func (t *Signatory) GetMetadata() string

func (*Signatory) IsExpire

func (t *Signatory) IsExpire() bool

func (*Signatory) Match

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

type SignatureInvalidError

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

func (SignatureInvalidError) Error

func (e SignatureInvalidError) Error() string

func (SignatureInvalidError) Unwrap

func (e SignatureInvalidError) Unwrap() error

Jump to

Keyboard shortcuts

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