authorizations

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnauthorized = errors.Unauthorized("unauthorized")

Functions

func Service

func Service() services.Service

func ServiceWithEncoder

func ServiceWithEncoder(encoder TokenEncoder) services.Service

func Validate

func Validate(ctx context.Context) (err error)

func With

func With(ctx context.Context, authorization Authorization)

Types

type Attribute

type Attribute struct {
	Key   []byte
	Value json.RawMessage
}

type Attributes

type Attributes []Attribute

func (*Attributes) Get

func (attributes *Attributes) Get(key []byte, value interface{}) (has bool, err error)

func (*Attributes) Remove

func (attributes *Attributes) Remove(key []byte)

func (*Attributes) Set

func (attributes *Attributes) Set(key []byte, value interface{}) (err error)

type Authorization

type Authorization struct {
	Id         Id         `json:"id"`
	Account    Id         `json:"account"`
	Attributes Attributes `json:"attributes"`
	ExpireAT   time.Time  `json:"expireAT"`
}

func Decode

func Decode(ctx context.Context, token Token) (authorization Authorization, err error)

func Load

func Load(ctx context.Context) Authorization

func (Authorization) Exist

func (authorization Authorization) Exist() bool

func (Authorization) Validate

func (authorization Authorization) Validate() bool

type Id

type Id []byte

func IntId

func IntId(id int64) Id

func StringId

func StringId(id []byte) Id

func (Id) Exist

func (id Id) Exist() (ok bool)

func (Id) Int

func (id Id) Int() int64

func (Id) String

func (id Id) String() string

type Token

type Token []byte

func Encode

func Encode(ctx context.Context, authorization Authorization) (token Token, err error)

func (Token) String

func (token Token) String() string

type TokenEncoder

type TokenEncoder interface {
	services.Component
	Encode(ctx context.Context, param Authorization) (token Token, err error)
	Decode(ctx context.Context, token Token) (result Authorization, err error)
}

func DefaultTokenEncoder

func DefaultTokenEncoder() TokenEncoder

Jump to

Keyboard shortcuts

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