security

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthenticated = errors.New("security: unauthenticated")
	ErrUnauthorized    = errors.New("security: unauthorized")
)

Functions

This section is empty.

Types

type APIKeyAuthenticator

type APIKeyAuthenticator interface {
	AuthenticateAPIKey(ctx context.Context, key string) (identity.Principal, bool, error)
}

type APIKeyAuthenticatorFunc

type APIKeyAuthenticatorFunc func(ctx context.Context, key string) (identity.Principal, bool, error)

func (APIKeyAuthenticatorFunc) AuthenticateAPIKey

func (fn APIKeyAuthenticatorFunc) AuthenticateAPIKey(ctx context.Context, key string) (identity.Principal, bool, error)

type Action

type Action string
const (
	ActionRunSubmit   Action = "run.submit"
	ActionRunRead     Action = "run.read"
	ActionRunCancel   Action = "run.cancel"
	ActionHITLResume  Action = "hitl.resume"
	ActionToolInvoke  Action = "tool.invoke"
	ActionMemoryRead  Action = "memory.read"
	ActionMemoryWrite Action = "memory.write"
	ActionAdminConfig Action = "admin.configure"
)

type BearerAuthenticator

type BearerAuthenticator interface {
	AuthenticateBearer(ctx context.Context, token string) (identity.Principal, bool, error)
}

type BearerAuthenticatorFunc

type BearerAuthenticatorFunc func(ctx context.Context, token string) (identity.Principal, bool, error)

func (BearerAuthenticatorFunc) AuthenticateBearer

func (fn BearerAuthenticatorFunc) AuthenticateBearer(ctx context.Context, token string) (identity.Principal, bool, error)

type Policy

type Policy interface {
	Authorize(ctx context.Context, principal identity.Principal, action Action, resource Resource) error
}

type PolicyFunc

type PolicyFunc func(ctx context.Context, principal identity.Principal, action Action, resource Resource) error

func (PolicyFunc) Authorize

func (fn PolicyFunc) Authorize(ctx context.Context, principal identity.Principal, action Action, resource Resource) error

type Resource

type Resource struct {
	Type        string            `json:"type"`
	ID          string            `json:"id,omitempty"`
	TenantID    string            `json:"tenant_id,omitempty"`
	WorkspaceID string            `json:"workspace_id,omitempty"`
	ProjectID   string            `json:"project_id,omitempty"`
	Metadata    map[string]string `json:"metadata,omitempty"`
}

func BindTenant added in v0.1.4

func BindTenant(principal identity.Principal, resource Resource) Resource

BindTenant attaches the principal tenant to a resource when the resource has no tenant.

type RolePolicy

type RolePolicy struct {
	Rules map[Action][]identity.Role
}

func NewDefaultRolePolicy

func NewDefaultRolePolicy() RolePolicy

func (RolePolicy) Authorize

func (policy RolePolicy) Authorize(ctx context.Context, principal identity.Principal, action Action, resource Resource) error

Jump to

Keyboard shortcuts

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