auth

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: BSD-3-Clause Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSignature  = errors.New("invalid signature")
	ErrActorMissing      = errors.New("actor account is missing")
	ErrNotAllowed        = errors.New("not allowed")
	ErrActionMissing     = errors.New("action missing")
	ErrActorCantPay      = errors.New("actor can't pay")
	ErrActorEqualsSigner = errors.New("actor equals signer, use direct")
)

Functions

func Authorized

func Authorized(
	ctx context.Context,
	db chain.Database,
	action chain.Action,
	actor crypto.PublicKey,
	signer crypto.PublicKey,
	actorPays bool,
) error

func GetActor

func GetActor(auth chain.Auth) crypto.PublicKey

func GetSigner

func GetSigner(auth chain.Auth) crypto.PublicKey

func UnmarshalDelegate

func UnmarshalDelegate(p *codec.Packer) (chain.Auth, error)

func UnmarshalDirect

func UnmarshalDirect(p *codec.Packer) (chain.Auth, error)

Types

type Delegate

type Delegate struct {
	Actor     crypto.PublicKey `json:"actor"`
	Signer    crypto.PublicKey `json:"signer"`
	Signature crypto.Signature `json:"signature"`

	ActorPays bool `json:"actorPays"`
}

func (*Delegate) AsyncVerify

func (d *Delegate) AsyncVerify(msg []byte) error

func (*Delegate) CanDeduct

func (d *Delegate) CanDeduct(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Delegate) Deduct

func (d *Delegate) Deduct(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Delegate) Marshal

func (d *Delegate) Marshal(p *codec.Packer)

func (*Delegate) MaxUnits

func (*Delegate) MaxUnits(
	chain.Rules,
) uint64

func (*Delegate) Payer

func (d *Delegate) Payer() []byte

func (*Delegate) Refund

func (d *Delegate) Refund(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Delegate) StateKeys

func (d *Delegate) StateKeys() [][]byte

func (*Delegate) ValidRange

func (*Delegate) ValidRange(chain.Rules) (int64, int64)

func (*Delegate) Verify

func (d *Delegate) Verify(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	action chain.Action,
) (uint64, error)

Verify could be used to perform complex ACL rules that require state access to check.

type DelegateFactory

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

func NewDelegateFactory

func NewDelegateFactory(
	actor crypto.PublicKey,
	priv crypto.PrivateKey,
	actorPays bool,
) *DelegateFactory

func (*DelegateFactory) Sign

func (d *DelegateFactory) Sign(msg []byte, _ chain.Action) (chain.Auth, error)

type Direct

type Direct struct {
	Signer    crypto.PublicKey `json:"signer"`
	Signature crypto.Signature `json:"signature"`
}

func (*Direct) AsyncVerify

func (d *Direct) AsyncVerify(msg []byte) error

func (*Direct) CanDeduct

func (d *Direct) CanDeduct(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Direct) Deduct

func (d *Direct) Deduct(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Direct) Marshal

func (d *Direct) Marshal(p *codec.Packer)

func (*Direct) MaxUnits

func (*Direct) MaxUnits(
	chain.Rules,
) uint64

func (*Direct) Payer

func (d *Direct) Payer() []byte

func (*Direct) Refund

func (d *Direct) Refund(
	ctx context.Context,
	db chain.Database,
	amount uint64,
) error

func (*Direct) StateKeys

func (d *Direct) StateKeys() [][]byte

func (*Direct) ValidRange

func (*Direct) ValidRange(chain.Rules) (int64, int64)

func (*Direct) Verify

func (d *Direct) Verify(
	ctx context.Context,
	r chain.Rules,
	db chain.Database,
	action chain.Action,
) (uint64, error)

Verify could be used to perform complex ACL rules that require state access to check.

type DirectFactory

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

func NewDirectFactory

func NewDirectFactory(priv crypto.PrivateKey) *DirectFactory

func (*DirectFactory) Sign

func (d *DirectFactory) Sign(msg []byte, _ chain.Action) (chain.Auth, error)

Jump to

Keyboard shortcuts

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