Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

authorizable source pure

Package authorizable is an extension of p/nt/ownable; It allows the user to instantiate an Authorizable struct, which...

Overview

Package authorizable is an extension of p/nt/ownable; It allows the user to instantiate an Authorizable struct, which extends p/nt/ownable with a list of users that are authorized for something. By using authorizable, you have a superuser (ownable), as well as another authorization level, which can be used for adding moderators or similar to your realm.

Variables 1

var ErrNotInAuthList, ErrNotSuperuser, ErrAlreadyInList

1var (
2	ErrNotInAuthList = errors.New("authorizable: caller is not in authorized list")
3	ErrNotSuperuser  = errors.New("authorizable: caller is not superuser")
4	ErrAlreadyInList = errors.New("authorizable: address is already in authorized list")
5)
source

Functions 1

func New

1func New(o *ownable.Ownable) *Authorizable
source

New creates an Authorizable from an existing *ownable.Ownable. The owner is automatically added to the auth list.

Example construction:

Example
1authorizable.New(ownable.NewWithAddress(addr))

Types 1

type Authorizable

struct
1type Authorizable struct {
2	*ownable.Ownable                // owner in ownable is superuser
3	authorized       *bptree.BPTree // chain.Addr > struct{}{}
4}
source

Methods on Authorizable

func AddToAuthList

method on Authorizable
1func (a *Authorizable) AddToAuthList(_ int, rlm realm, addr address) error
source

AddToAuthList adds addr to the auth list. rlm must be the caller's own captured cur; rlm.Previous().Address() must equal the superuser (the underlying Ownable's owner).

func AssertOnAuthList

method on Authorizable
1func (a Authorizable) AssertOnAuthList(_ int, rlm realm)
source

func DeleteFromAuthList

method on Authorizable
1func (a *Authorizable) DeleteFromAuthList(_ int, rlm realm, addr address) error
source

DeleteFromAuthList removes addr from the auth list. rlm must be the caller's own captured cur; rlm.Previous().Address() must equal the superuser (the underlying Ownable's owner).

func OnAuthList

method on Authorizable
1func (a *Authorizable) OnAuthList(_ int, rlm realm) error
source

OnAuthList reports whether rlm.Address() is on the auth list. rlm must be the caller's own captured cur (asserted via rlm.IsCurrent()). Pre-migration shape used unsafe.CurrentRealm().Address() — vulnerable to the .Title()-class read where a non-crossing wrapper made the walk return the wrong realm. Explicit rlm closes that.

func PreviousOnAuthList

method on Authorizable
1func (a *Authorizable) PreviousOnAuthList(_ int, rlm realm) error
source

PreviousOnAuthList reports whether rlm.Previous().Address() — the realm that crossed into the caller — is on the auth list. Same rlm contract as OnAuthList.

Imports 4

Source Files 4