scopes

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package scopes parses and validates atproto OAuth permission scopes (proposal 0011-auth-scopes). It models the granular resources (repo, rpc, blob, account, identity, include) alongside the legacy static scopes (atproto, transition:*), and exposes enough structure for PAR-time validation and resource-server enforcement.

Index

Constants

View Source
const (
	ResourceRepo       = "repo"
	ResourceRPC        = "rpc"
	ResourceBlob       = "blob"
	ResourceAccount    = "account"
	ResourceIdentity   = "identity"
	ResourceInclude    = "include"
	ResourceAtproto    = "atproto"
	ResourceTransition = "transition"
)

Resource identifiers for parsed scopes.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndigoResolver

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

IndigoResolver resolves permission sets using indigo's lexicon resolution (DNS TXT `_lexicon.<authority>` -> DID -> `com.atproto.lexicon.schema` record), with a small in-memory TTL cache for both positive and negative results.

func NewIndigoResolver

func NewIndigoResolver() *IndigoResolver

NewIndigoResolver builds a resolver backed by the default identity directory.

func NewIndigoResolverWithDirectory

func NewIndigoResolverWithDirectory(dir directory) *IndigoResolver

NewIndigoResolverWithDirectory builds a resolver using the supplied directory.

func (*IndigoResolver) ResolvePermissionSet

func (r *IndigoResolver) ResolvePermissionSet(ctx context.Context, nsidStr string) (*lexicon.SchemaPermissionSet, error)

type PermissionSetResolver

type PermissionSetResolver interface {
	ResolvePermissionSet(ctx context.Context, nsid string) (*lexicon.SchemaPermissionSet, error)
}

PermissionSetResolver resolves an `include:<nsid>` scope to its permission-set lexicon. ResolvePermissionSet returns the parsed permission-set when the NSID resolves to a valid permission-set record, or an error otherwise.

type Scope

type Scope struct {
	Raw      string
	Resource string

	// repo
	Collections []string
	Actions     []string

	// rpc
	Lxm []string
	Aud string

	// blob
	Accept []string

	// account / identity
	Attr   string
	Action string

	// include
	Nsid string

	// transition:<value>
	Transition string
}

Scope is a single parsed scope token. Only the fields relevant to its Resource are populated.

func Parse

func Parse(raw string) (*Scope, error)

Parse parses a single scope token, returning an error if it is syntactically invalid or uses a disallowed wildcard combination.

func ParseList

func ParseList(scope string) ([]*Scope, error)

ParseList splits a space-delimited scope string and parses each token. It returns an error on the first token that fails to parse.

func (*Scope) AllowsAccount added in v0.11.2

func (s *Scope) AllowsAccount(attr, action string) bool

AllowsAccount checks attribute access; manage implies read.

func (*Scope) AllowsBlob added in v0.11.2

func (s *Scope) AllowsBlob(mediaType string) bool

AllowsBlob reports whether this scope accepts a concrete MIME type.

func (*Scope) AllowsIdentity added in v0.11.2

func (s *Scope) AllowsIdentity(attr string) bool

AllowsIdentity checks attribute access, including identity:*.

func (*Scope) AllowsRepoWrite

func (s *Scope) AllowsRepoWrite(collection, action string) bool

AllowsRepoWrite reports whether this scope grants the given repo write action on the given collection. Non-repo scopes always return false.

Jump to

Keyboard shortcuts

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