obo

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecisionCode

func DecisionCode(err error) string

Types

type ActionRegistry

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

func ParseActionRegistry

func ParseActionRegistry(raw string) (*ActionRegistry, error)

ParseActionRegistry reads OCTO_OBO_ACTION_SCOPES_JSON. Every OBO Action and its allowed Scopes must be explicitly registered at startup. An empty value creates an empty registry, so non-OBO deployments can start while OBO fails closed until policy is configured.

func (*ActionRegistry) Allows

func (r *ActionRegistry) Allows(action string) bool

func (*ActionRegistry) AllowsScope

func (r *ActionRegistry) AllowsScope(action, scope string) bool

type DBSnapshotReader

type DBSnapshotReader struct{ Session *dbr.Session }

DBSnapshotReader performs every mutable identity/authorization read inside one repeatable-read transaction. It does not consult legacy OBO caches.

func (DBSnapshotReader) Read

func (r DBSnapshotReader) Read(ctx context.Context, botToken, spaceID string, mode Mode) (Snapshot, error)

type DecisionError

type DecisionError struct {
	Code   string
	Status int
	Cause  error
}

func (*DecisionError) Error

func (e *DecisionError) Error() string

func (*DecisionError) Unwrap

func (e *DecisionError) Unwrap() error

type Delegation

type Delegation struct {
	GrantID       int64  `json:"grant_id"`
	MatchedScope  string `json:"matched_scope"`
	PolicyVersion int64  `json:"policy_version"`
	Action        string `json:"action"`
	DecisionID    string `json:"decision_id"`
}

type Identity

type Identity struct {
	UID     string `json:"uid"`
	Kind    string `json:"kind"`
	SpaceID string `json:"space_id"`
}

type Mode

type Mode string
const (
	ModeAsBot Mode = "AS_BOT"
	ModeOBO   Mode = "OBO"
)

type Principal

type Principal struct {
	Mode       Mode        `json:"mode"`
	Actor      Identity    `json:"actor"`
	Subject    Identity    `json:"subject"`
	Delegation *Delegation `json:"delegation,omitempty"`
}

type Request

type Request struct {
	BotToken string `json:"bot_token"`
	Mode     Mode   `json:"mode"`
	SpaceID  string `json:"space_id"`
	Action   string `json:"action,omitempty"`
	Resource *struct {
		Type string `json:"type"`
		ID   string `json:"id"`
	} `json:"resource,omitempty"`
}

type Resolver

type Resolver struct {
	Reader   SnapshotReader
	Registry *ActionRegistry
}

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, req Request) (*Principal, error)

type Snapshot

type Snapshot struct {
	BotUID        string
	OwnerUID      string
	GrantID       int64
	PolicyVersion int64
	BoundScopes   []string
}

Snapshot contains only authorization facts read from one consistent DB snapshot. A read-only Bot request does not populate delegation fields.

type SnapshotReader

type SnapshotReader interface {
	Read(ctx context.Context, botToken, spaceID string, mode Mode) (Snapshot, error)
}

Jump to

Keyboard shortcuts

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