permission

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationResource  = "hs:resource"
	AnnotationOperation = "hs:operation"
)

Annotation keys stored on cobra.Command.Annotations.

View Source
const (
	OpRead   = "read"
	OpWrite  = "write"
	OpDelete = "delete"
)

Valid operations.

Variables

This section is empty.

Functions

func Annotate

func Annotate(cmd *cobra.Command, resource, operation string)

Annotate sets the resource and operation annotations on a command.

Types

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

Policy is a parsed set of permission rules. A nil or zero-value Policy is unrestricted (allows everything).

func Parse

func Parse(s string) (*Policy, error)

Parse parses a comma-separated permission string into a Policy. An empty string yields an unrestricted policy.

func (*Policy) Allows

func (p *Policy) Allows(resource, op string) bool

Allows checks whether the given resource:operation is permitted.

func (*Policy) IsUnrestricted

func (p *Policy) IsUnrestricted() bool

IsUnrestricted returns true when no rules are set (everything allowed).

func (*Policy) Rules

func (p *Policy) Rules() []Rule

Rules returns a copy of the parsed rules.

func (*Policy) String

func (p *Policy) String() string

String returns the original permission string, or "unrestricted".

type Rule

type Rule struct {
	Resource  string
	Operation string
}

Rule is a single resource:operation pair.

Jump to

Keyboard shortcuts

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