scope

package
v1.9.0 Latest Latest
Warning

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

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

Documentation

Overview

Package scope defines permission scopes that can be assigned to API keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ListFilter

type ListFilter struct {
	TenantID string `json:"tenant_id,omitempty"`
	Parent   string `json:"parent,omitempty"`
	Limit    int    `json:"limit,omitempty"`
	Offset   int    `json:"offset,omitempty"`
}

ListFilter contains filters for listing scopes.

type Scope

type Scope struct {
	ID          id.ScopeID     `json:"id" db:"id"`
	TenantID    string         `json:"tenant_id" db:"tenant_id"`
	AppID       string         `json:"app_id" db:"app_id"`
	Name        string         `json:"name" db:"name"`
	Description string         `json:"description,omitempty" db:"description"`
	Parent      string         `json:"parent,omitempty" db:"parent"`
	Metadata    map[string]any `json:"metadata,omitempty" db:"metadata"`
	CreatedAt   time.Time      `json:"created_at" db:"created_at"`
}

Scope defines a permission scope that can be assigned to keys. Scopes are hierarchical: "read:users" is a child of "read".

type Store

type Store interface {
	Create(ctx context.Context, s *Scope) error
	Get(ctx context.Context, scopeID id.ScopeID) (*Scope, error)
	GetByName(ctx context.Context, tenantID, name string) (*Scope, error)
	Update(ctx context.Context, s *Scope) error
	Delete(ctx context.Context, scopeID id.ScopeID) error
	List(ctx context.Context, filter *ListFilter) ([]*Scope, error)
	ListByKey(ctx context.Context, keyID id.KeyID) ([]*Scope, error)
	AssignToKey(ctx context.Context, keyID id.KeyID, scopeNames []string) error
	RemoveFromKey(ctx context.Context, keyID id.KeyID, scopeNames []string) error
}

Store is the persistence interface for permission scopes.

Jump to

Keyboard shortcuts

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