authz

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessGrant

type AccessGrant struct {
	AppID     string
	Principal string
	Kind      AccessKind
	Role      ContentRole
	GrantedBy string
	GrantedAt string
}

AccessGrant represents a row from the app_access table.

type AccessKind

type AccessKind string

AccessKind distinguishes user grants from group grants.

const (
	AccessKindUser AccessKind = "user"
)

type AppRelation

type AppRelation int

AppRelation is the effective relationship between a caller and a specific app. Determines what operations the caller can perform.

const (
	RelationNone                AppRelation = iota // No access at all
	RelationAnonymous                              // Public app, unauthenticated user
	RelationContentViewer                          // Per-content viewer (ACL grant)
	RelationContentCollaborator                    // Per-content collaborator (ACL grant)
	RelationOwner                                  // App owner
	RelationAdmin                                  // System admin
)

func EvaluateAccess

func EvaluateAccess(
	caller *auth.CallerIdentity,
	appOwner string,
	grants []AccessGrant,
	accessType string,
) AppRelation

EvaluateAccess determines the caller's relationship to a specific app.

Evaluation order:

  1. Public app + nil caller -> RelationAnonymous
  2. System admin -> RelationAdmin (overrides all)
  3. App owner -> RelationOwner
  4. Explicit user ACL grants -> highest content role
  5. logged_in or public app + authenticated caller -> RelationContentViewer
  6. No match -> RelationNone

accessType is the app's access_type column ("acl", "logged_in", or "public"). caller may be nil for unauthenticated requests to public apps.

func (AppRelation) CanAccessProxy

func (r AppRelation) CanAccessProxy() bool

CanAccessProxy reports whether this relation allows using the app via proxy.

func (AppRelation) CanDelete

func (r AppRelation) CanDelete() bool

CanDelete reports whether this relation allows deleting the app.

func (AppRelation) CanDeploy

func (r AppRelation) CanDeploy() bool

CanDeploy reports whether this relation allows deploying bundles.

func (AppRelation) CanManageACL

func (r AppRelation) CanManageACL() bool

CanManageACL reports whether this relation allows managing ACL grants.

func (AppRelation) CanStartStop

func (r AppRelation) CanStartStop() bool

CanStartStop reports whether this relation allows starting/stopping the app.

func (AppRelation) CanUpdateConfig

func (r AppRelation) CanUpdateConfig() bool

CanUpdateConfig reports whether this relation allows updating app config.

func (AppRelation) CanViewDetails

func (r AppRelation) CanViewDetails() bool

CanViewDetails reports whether this relation allows viewing app details.

func (AppRelation) String added in v0.0.3

func (r AppRelation) String() string

String returns the lowercase name of the app relation.

type ContentRole

type ContentRole int

ContentRole is a per-content role granted via the app_access table. Ordered by privilege for max-wins resolution.

const (
	ContentRoleViewer       ContentRole = iota // Can use the app via proxy
	ContentRoleCollaborator                    // Can deploy, start/stop, update config
)

func ParseContentRole

func ParseContentRole(s string) (ContentRole, bool)

ParseContentRole converts a string to a ContentRole. Returns ContentRoleViewer and false for unrecognized values.

func (ContentRole) String

func (r ContentRole) String() string

String returns the lowercase name of the content role.

Jump to

Keyboard shortcuts

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