Documentation
¶
Overview ¶
Authorization lifecycle stub (S06), matching credentials/authorization. M39 supplies flow registration and Begin/Cancel. AuthService adds one-time callback tokens: Begin creates a pending session; Complete stores credentials and marks it completed so Resolve can read them; Cancel cancels pending sessions and invokes flow.Cancel. A real browser/SDK integration can supply a callback endpoint while retaining this interface.
Package credentials implements credentials and authorization flows, matching credentials/credentials, credentials-local, and authorization upstream. Resolve reads a branded POSIX variable reference before each LLM request, so environment changes become visible on the next turn. Storage Domain persists records with CAS versions and rejects concurrent write conflicts. Describe exposes only presence and writability, never plaintext. Registered authorization flows support list/begin/cancel; S06 adds the complete stub lifecycle.
Index ¶
- type AuthService
- func (s *AuthService) Begin(ctx context.Context, flowID FlowID) (token string, err error)
- func (s *AuthService) Cancel(ctx context.Context, token string) error
- func (s *AuthService) Complete(ctx context.Context, token string, value string) error
- func (s *AuthService) List() []AuthSession
- func (s *AuthService) Status(token string) (AuthSession, bool)
- type AuthSession
- type AuthStatus
- type AuthorizationService
- type CredentialInfo
- type Flow
- type FlowID
- type Store
- func (s *Store) Describe(ctx context.Context) []CredentialInfo
- func (s *Store) Resolve(ctx context.Context, ref brand.CredentialRef) (string, bool)
- func (s *Store) Set(ctx context.Context, ref brand.CredentialRef, value string) error
- func (s *Store) Unset(ctx context.Context, ref brand.CredentialRef) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService orchestrates begin, callback, and credential resolution.
func NewAuthService ¶
func NewAuthService(auth *AuthorizationService, store *Store) *AuthService
NewAuthService binds the flow registry and credential store.
func (*AuthService) Begin ¶
Begin starts a flow and returns a one-time callback token. Typical flow: list flows, begin, complete externally, then Complete(token, value).
func (*AuthService) Cancel ¶
func (s *AuthService) Cancel(ctx context.Context, token string) error
Cancel cancels a pending session and calls flow.Cancel.
func (*AuthService) Complete ¶
Complete simulates an OAuth callback: store value and mark the session completed. Resolve can then retrieve it using the flow's credential reference.
func (*AuthService) List ¶
func (s *AuthService) List() []AuthSession
List returns all sessions deterministically in lexical ID order.
func (*AuthService) Status ¶
func (s *AuthService) Status(token string) (AuthSession, bool)
Status returns the state of a session.
type AuthSession ¶
type AuthSession struct {
ID string `json:"id"`
FlowID FlowID `json:"flowId"`
Status AuthStatus `json:"status"`
StartedAt time.Time `json:"startedAt"`
CredRef brand.CredentialRef `json:"credRef,omitempty"` // Credential reference written by the callback.
HasValue bool `json:"hasValue"`
}
AuthSession records an authorization flow session.
type AuthStatus ¶
type AuthStatus string
AuthStatus identifies an authorization session state.
const ( AuthPending AuthStatus = "pending" // Waiting for a callback. AuthCompleted AuthStatus = "completed" // Credentials have been stored. AuthCancelled AuthStatus = "cancelled" // Canceled. )
Authorization session states.
type AuthorizationService ¶
type AuthorizationService struct {
// contains filtered or unexported fields
}
AuthorizationService registers authorization flows.
func NewAuthorizationService ¶
func NewAuthorizationService() *AuthorizationService
NewAuthorizationService creates an authorization service.
func (*AuthorizationService) Cancel ¶
func (a *AuthorizationService) Cancel(ctx context.Context, id FlowID) error
Cancel cancels the specified authorization flow.
func (*AuthorizationService) List ¶
func (a *AuthorizationService) List() []*Flow
List returns registered authorization flows.
func (*AuthorizationService) Register ¶
func (a *AuthorizationService) Register(f *Flow) error
Register registers an authorization flow.
type CredentialInfo ¶
type CredentialInfo struct {
Ref brand.CredentialRef `json:"ref"`
Writable bool `json:"writable"`
HasValue bool `json:"hasValue"`
}
CredentialInfo describes a credential without plaintext.
type Flow ¶
type Flow struct {
// ID uniquely identifies the flow.
ID FlowID
// Name is human-readable.
Name string
// Begin returns a prompt or URL for completing authorization; stubs may use a placeholder.
Begin func(ctx context.Context) (string, error)
// Cancel cancels the authorization flow.
Cancel func(ctx context.Context) error
}
Flow describes an authorization flow, such as OAuth authorization code.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store combines cached credentials with Storage Domain CAS persistence.
func NewMemoryStore ¶
func NewMemoryStore() *Store
NewMemoryStore creates an in-memory store for tests or temporary use.
func (*Store) Describe ¶
func (s *Store) Describe(ctx context.Context) []CredentialInfo
Describe exposes references, writability, and presence, never plaintext.