authz

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessDescriptor

type AccessDescriptor interface {
	Principal() string
	Tenant() string
	Resource() string
	Permission() string
	Name() string

	WithPrincipal(string) AccessDescriptor
	WithTenant(string) AccessDescriptor
	WithResource(string) AccessDescriptor
	WithPermission(string) AccessDescriptor
	WithName(string) AccessDescriptor
}

AccessDescriptor describes the context of an access request.

type AccessFactory

type AccessFactory func() AccessDescriptor

AccessFactory defines a function to create an AccessDescriptor.

type ArgFn

type ArgFn func(int) string

type Authorizer

type Authorizer interface {
	// Check determines if a given access request is permitted for a single resource.
	Check(ctx context.Context, tx *sql.Tx, fn ArgFn, accessDescriptor AccessDescriptor) bool
	// Partial generates a SQL expression (a WHERE clause) that can be used to
	// filter a list of resources based on the user's permissions.
	Partial(ctx context.Context, accessDescriptor AccessDescriptor, extraColumnMappings map[string]SQLColumnRef) (Expr, error)
}

Authorizer defines the interface for making authorization decisions.

type Expr

type Expr interface {
	SQL(ArgFn, []any) (string, []any)
	Tables() []SQLTableRef
}

Expr represents a SQL expression generated by partial evaluation.

type SQLColumnRef

type SQLColumnRef struct {
	Table  string
	Column string
}

SQLColumnRef represents a reference to a specific column in a SQL table.

func (SQLColumnRef) SQL

func (sc SQLColumnRef) SQL(fn ArgFn, args []any) (string, []any)

func (SQLColumnRef) Tables

func (sc SQLColumnRef) Tables() []SQLTableRef

type SQLTableRef

type SQLTableRef struct {
	Table string
}

SQLTableRef represents a reference to a SQL table.

func (SQLTableRef) SQL

func (st SQLTableRef) SQL(_ ArgFn, args []any) (string, []any)

Jump to

Keyboard shortcuts

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