authorizations

package
v1.2.69 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func New added in v1.2.0

func New(options ...Option) services.Service

func Remove added in v1.2.0

func Remove(ctx context.Context, account Id, ids ...Id) (err error)

func Validate

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

func With

func With(ctx context.Context, authorization Authorization) context.Context

Types

type Attribute

type Attribute struct {
	Key   []byte          `json:"key" avro:"key"`
	Value json.RawMessage `json:"value" avro:"value"`
}

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" avro:"id"`
	Account    Id         `json:"account" avro:"account"`
	Attributes Attributes `json:"attributes" avro:"attributes"`
	ExpireAT   time.Time  `json:"expireAT" avro:"expireAt"`
}

func Decode

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

func List added in v1.2.0

func List(ctx context.Context, account Id) (v []Authorization, err error)

func Load

func Load(ctx context.Context) (Authorization, bool, error)

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) MarshalJSON added in v1.2.0

func (id Id) MarshalJSON() ([]byte, error)

func (Id) String

func (id Id) String() string

func (*Id) UnmarshalJSON added in v1.2.0

func (id *Id) UnmarshalJSON(p []byte) error

type Option added in v1.2.0

type Option func(options *Options)

func WithTokenEncoder added in v1.2.0

func WithTokenEncoder(encoder TokenEncoder) Option

func WithTokenStore added in v1.2.0

func WithTokenStore(store TokenStore) Option

type Options added in v1.2.0

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

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

type TokenStore added in v1.2.0

type TokenStore interface {
	services.Component
	Get(ctx context.Context, account Id, id Id) (v Authorization, has bool, err error)
	List(ctx context.Context, account Id) (v []Authorization, err error)
	Save(ctx context.Context, v Authorization) (err error)
	Remove(ctx context.Context, account Id, ids []Id) (err error)
}

Jump to

Keyboard shortcuts

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