token

package
v0.0.0-...-70e99ff Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const LEN_TOKEN_ID = 36

Variables

View Source
var (
	ERR_SIZE_MORE = errors.New("token size is more than 4 kb")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Marshal(*Token) (string, error)
	Unmarshal(string) (*Token, error)
}

func NewBackendCryptAES

func NewBackendCryptAES(key SecretKey) (Backend, error)

NewBackendCryptAES and returns a new *token.CryptAES. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func NewBackendJose

func NewBackendJose(cfg *JoseConfig, key SecretKey) (Backend, error)

type BackendCryptAES

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

func (*BackendCryptAES) Marshal

func (c *BackendCryptAES) Marshal(tok *Token) (str string, err error)

func (*BackendCryptAES) Unmarshal

func (c *BackendCryptAES) Unmarshal(value string) (tok *Token, err error)

type BackendJose

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

func (*BackendJose) Marshal

func (j *BackendJose) Marshal(tok *Token) (token string, err error)

func (BackendJose) Unmarshal

func (j BackendJose) Unmarshal(token string) (tok *Token, err error)

type Body

type Body struct {
	ID         string `json:"tok_id"`
	UpTime     int64  `json:"up_time"`
	CreateTime int64  `json:"cr_time"`

	*values.Value
}

func (Body) MarshalEasyJSON

func (v Body) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Body) MarshalJSON

func (v Body) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Body) UnmarshalEasyJSON

func (v *Body) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Body) UnmarshalJSON

func (v *Body) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Encoder

type Encoder interface {
	NewToken() *Token
	UnmarshalString(string) (*Token, error)
	MarshalString(*Token) (string, error)
}

func NewEncoder

func NewEncoder(backend Backend) Encoder

type JoseConfig

type JoseConfig struct {
	// Use jose func `Sign` else `Encrypt`
	Type string

	//Sign config
	SigningAlg string

	//Encrypt config
	EncryptAlg string
	EncryptEnc string

	//Options
	Compress bool
}

type SecretKey

type SecretKey []byte

type StandartEncoder

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

func (*StandartEncoder) MarshalString

func (e *StandartEncoder) MarshalString(tok *Token) (raw string, err error)

func (*StandartEncoder) NewToken

func (e *StandartEncoder) NewToken() (tok *Token)

func (*StandartEncoder) UnmarshalString

func (e *StandartEncoder) UnmarshalString(str string) (tok *Token, err error)

type Token

type Token struct {
	*Body
}

func (*Token) GetTokenCreateTime

func (b *Token) GetTokenCreateTime() int64

func (*Token) GetTokenID

func (b *Token) GetTokenID() string

func (*Token) GetTokenUpdateTime

func (b *Token) GetTokenUpdateTime() int64

Jump to

Keyboard shortcuts

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