Help us shape the future of Go! Take the 2026 Go Developer Survey

permissions

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPermission = errors.New("permission grant is invalid")
	ErrPermissionDenied  = errors.New("plugin permission grant is required")
	ErrGrantNotFound     = errors.New("permission grant not found")
)

Functions

This section is empty.

Types

type CheckRequest

type CheckRequest struct {
	PluginInstanceID string    `json:"plugin_instance_id"`
	PermissionIDs    []string  `json:"permission_ids"`
	Now              time.Time `json:"now,omitempty"`
}

type Effect

type Effect string
const (
	EffectGrant Effect = "grant"
	EffectDeny  Effect = "deny"
)

type GrantRequest

type GrantRequest struct {
	PluginInstanceID string    `json:"plugin_instance_id"`
	PermissionID     string    `json:"permission_id"`
	GrantedBy        string    `json:"granted_by,omitempty"`
	Now              time.Time `json:"now,omitempty"`
	ExpiresAt        time.Time `json:"expires_at,omitempty"`
}

type ListRequest

type ListRequest struct {
	PluginInstanceID string `json:"plugin_instance_id,omitempty"`
	ActiveOnly       bool   `json:"active_only,omitempty"`
}

type MemoryState

type MemoryState struct {
	Records []Record `json:"records,omitempty"`
}

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func NewMemoryStoreFromState

func NewMemoryStoreFromState(state MemoryState) *MemoryStore

func (*MemoryStore) DeletePluginGrants

func (s *MemoryStore) DeletePluginGrants(_ context.Context, pluginInstanceID string) error

func (*MemoryStore) Grant

func (s *MemoryStore) Grant(_ context.Context, req GrantRequest) (Record, error)

func (*MemoryStore) IsGranted

func (s *MemoryStore) IsGranted(_ context.Context, req CheckRequest) (bool, []string, error)

func (*MemoryStore) List

func (s *MemoryStore) List(_ context.Context, req ListRequest) ([]Record, error)

func (*MemoryStore) Revoke

func (s *MemoryStore) Revoke(_ context.Context, req RevokeRequest) (Record, error)

func (*MemoryStore) State

func (s *MemoryStore) State() MemoryState

type Record

type Record struct {
	PluginInstanceID string     `json:"plugin_instance_id"`
	PermissionID     string     `json:"permission_id"`
	Effect           Effect     `json:"effect"`
	GrantedBy        string     `json:"granted_by,omitempty"`
	GrantedAt        time.Time  `json:"granted_at"`
	ExpiresAt        *time.Time `json:"expires_at,omitempty"`
	RevokedAt        *time.Time `json:"revoked_at,omitempty"`
	RevokedBy        string     `json:"revoked_by,omitempty"`
	RevokedReason    string     `json:"revoked_reason,omitempty"`
}

type RevokeRequest

type RevokeRequest struct {
	PluginInstanceID string    `json:"plugin_instance_id"`
	PermissionID     string    `json:"permission_id"`
	RevokedBy        string    `json:"revoked_by,omitempty"`
	Reason           string    `json:"reason,omitempty"`
	Now              time.Time `json:"now,omitempty"`
}

type SQLiteStore

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

func NewSQLiteStore

func NewSQLiteStore(ctx context.Context, path string) (*SQLiteStore, error)

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

func (*SQLiteStore) DeletePluginGrants

func (s *SQLiteStore) DeletePluginGrants(ctx context.Context, pluginInstanceID string) error

func (*SQLiteStore) Grant

func (s *SQLiteStore) Grant(ctx context.Context, req GrantRequest) (Record, error)

func (*SQLiteStore) IsGranted

func (s *SQLiteStore) IsGranted(ctx context.Context, req CheckRequest) (bool, []string, error)

func (*SQLiteStore) List

func (s *SQLiteStore) List(ctx context.Context, req ListRequest) ([]Record, error)

func (*SQLiteStore) Revoke

func (s *SQLiteStore) Revoke(ctx context.Context, req RevokeRequest) (Record, error)

type Store

type Store interface {
	Grant(ctx context.Context, req GrantRequest) (Record, error)
	Revoke(ctx context.Context, req RevokeRequest) (Record, error)
	List(ctx context.Context, req ListRequest) ([]Record, error)
	IsGranted(ctx context.Context, req CheckRequest) (bool, []string, error)
	DeletePluginGrants(ctx context.Context, pluginInstanceID string) error
}

Jump to

Keyboard shortcuts

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