tableland

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT, Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrivInsert allows insert operations to be executed. The abbreviation is "a".
	PrivInsert = Privilege{
		Abbreviation: "a",
		Bitfield:     0b001,
	}

	// PrivUpdate allows updated operations to be executed. The abbreviation is "w".
	PrivUpdate = Privilege{
		Abbreviation: "w",
		Bitfield:     0b010,
	}

	// PrivDelete allows delete operations to be executed. The abbreviation is "d".
	PrivDelete = Privilege{
		Abbreviation: "d",
		Bitfield:     0b100,
	}
)

Functions

This section is empty.

Types

type ACL

type ACL interface {
	// CheckPrivileges checks if an address can execute a specific operation on a table.
	CheckPrivileges(context.Context, *sql.Tx, ChainID, common.Address, tables.TableID, Operation) (bool, error)
}

ACL is the API for access control rules check.

type ChainID

type ChainID int64

ChainID is a supported EVM chain identifier.

type Operation

type Operation int

Operation represents the kind of operation that can by executed in Tableland.

const (
	// OpSelect is represents a SELECT query.
	OpSelect Operation = iota
	// OpInsert is represents a INSERT query.
	OpInsert
	// OpUpdate is represents a UPDATE query.
	OpUpdate
	// OpDelete is represents a DELETE query.
	OpDelete
	// OpGrant is represents a GRANT query.
	OpGrant
	// OpRevoke is represents a REVOKE query.
	OpRevoke
	// OpCreate is represents a CREATE query.
	OpCreate
	// OpAlter is represents a ALTER query.
	OpAlter
)

func (Operation) String

func (op Operation) String() string

String returns the string representation of the operation.

type Policy

type Policy interface {
	// IsInsertAllowed rejects insert statement execution.
	IsInsertAllowed() bool

	// IsUpdateAllowed rejects update statement execution.
	IsUpdateAllowed() bool

	// IsDeleteAllowed rejects delete statement execution.
	IsDeleteAllowed() bool

	// WhereClause is SQL where clauses that restricts update and delete execution.
	WhereClause() string

	// UpdatableColumns imposes restrictions on what columns can be updated.
	// Empty means all columns are allowed.
	UpdatableColumns() []string

	// WithCheck is a SQL where clause that restricts the execution of incoming writes.
	WithCheck() string
}

Policy represents the kinds of restrictions that can be imposed on a statement execution.

type Privilege

type Privilege struct {
	Abbreviation string
	Bitfield     int
}

Privilege maps to SQL privilege and is the thing needed to execute an operation.

func NewPrivilegeFromSQLString

func NewPrivilegeFromSQLString(s string) (Privilege, error)

NewPrivilegeFromSQLString converts a SQL privilege string into a Privilege.

func (Privilege) ToSQLString

func (p Privilege) ToSQLString() string

ToSQLString returns the SQL string representation of a Privilege.

type Privileges

type Privileges []Privilege

Privileges represents a list of privileges.

func (Privileges) CanExecute

func (p Privileges) CanExecute(operation Operation) (bool, Privilege)

CanExecute checks if the list of privileges can execute a given operation. In case the operation cannot be executed, it returns the privilege that would allow the execution.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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