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 ¶
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 ¶
Parse parses a single scope token, returning an error if it is syntactically invalid or uses a disallowed wildcard combination.
func ParseList ¶
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) AllowsRepoWrite ¶
AllowsRepoWrite reports whether this scope grants the given repo write action on the given collection. Non-repo scopes always return false.