Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 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 )
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 ¶
Privilege maps to SQL privilege and is the thing needed to execute an operation.
func NewPrivilegeFromSQLString ¶
NewPrivilegeFromSQLString converts a SQL privilege string into a Privilege.
func (Privilege) ToSQLString ¶
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.