authz

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(db *sql.DB, ownerships []OwnershipMapping) error

Init initializes the global authz state. Reads OPA policy from OPA_POLICY_PATH environment variable. Skips initialization when DISABLE_AUTHZ=1.

Types

type CheckRequest

type CheckRequest struct {
	Action     string
	Resource   string
	UserID     int64
	Role       string
	ResourceID int64
}

CheckRequest holds the inputs for an authorization check.

type CheckResponse

type CheckResponse struct{}

CheckResponse is the result of an authorization check.

func Check

func Check(req CheckRequest) (CheckResponse, error)

Check evaluates the OPA policy. Returns error if denied or evaluation fails. Set DISABLE_AUTHZ=1 to bypass authorization checks.

type OwnershipMapping

type OwnershipMapping struct {
	Resource string // "gig", "proposal"
	Table    string // "gigs", "proposals"
	Column   string // "client_id", "freelancer_id"
}

OwnershipMapping represents a resource-to-table ownership mapping from @ownership annotations.

Jump to

Keyboard shortcuts

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