authz

package
v0.0.0-...-8e081cf Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const REFRESH_INTERVAL_SECONDS = 5

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseWalletAllowLister

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

DatabaseWalletAllowLister implements database backed allow list.

func NewDatabaseWalletAllowLister

func NewDatabaseWalletAllowLister(db *bun.DB, log *zap.Logger) *DatabaseWalletAllowLister

func (*DatabaseWalletAllowLister) Allow

func (d *DatabaseWalletAllowLister) Allow(ctx context.Context, walletAddress string) error

Add an address to the allow list.

func (*DatabaseWalletAllowLister) Apply

func (d *DatabaseWalletAllowLister) Apply(ctx context.Context, walletAddress string, permission Permission) error

func (*DatabaseWalletAllowLister) Deny

func (d *DatabaseWalletAllowLister) Deny(ctx context.Context, walletAddress string) error

Add an address to the deny list.

func (*DatabaseWalletAllowLister) GetPermissions

func (d *DatabaseWalletAllowLister) GetPermissions(walletAddress string) Permission

Get the permissions for a wallet address

func (*DatabaseWalletAllowLister) IsAllowListed

func (d *DatabaseWalletAllowLister) IsAllowListed(walletAddress string) bool

Check if the wallet address is explicitly allow listed

func (*DatabaseWalletAllowLister) IsDenyListed

func (d *DatabaseWalletAllowLister) IsDenyListed(walletAddress string) bool

Check if the wallet address is explicitly deny listed

func (*DatabaseWalletAllowLister) Start

Load the permissions and start listening

func (*DatabaseWalletAllowLister) Stop

func (d *DatabaseWalletAllowLister) Stop()

type Permission

type Permission int64
const (
	Allowed     Permission = 0
	Denied      Permission = 1
	Unspecified Permission = 2
)

func (Permission) String

func (p Permission) String() string

Add a string function to use for logging

type WalletAddress

type WalletAddress struct {
	bun.BaseModel `bun:"table:authz_addresses"`

	ID            int64      `bun:",pk,autoincrement"`
	WalletAddress string     `bun:"wallet_address,notnull"`
	CreatedAt     time.Time  `bun:"created_at"`
	DeletedAt     *time.Time `bun:"deleted_at"`
	Permission    string     `bun:"permission"`
	Comment       string     `bun:"comment"`
}

type WalletAllowLister

type WalletAllowLister interface {
	Start(ctx context.Context) error
	Stop()
	IsAllowListed(walletAddress string) bool
	IsDenyListed(walletAddress string) bool
	GetPermissions(walletAddress string) Permission
	Deny(ctx context.Context, WalletAddress string) error
	Allow(ctx context.Context, WalletAddress string) error
}

WalletAllowLister maintains an allow list for wallets.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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