aauthagent

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package aauthagent makes omniagent an AAuth agent (draft-hardt-oauth-aauth-protocol): it enrolls a key at an agent provider and returns an HTTP client that signs every request as that agent and answers the requirements a resource raises, obtaining person and auth tokens from the person's person server and waiting while the person approves.

Give the client to an OpenAPI skill to call an AAuth resource:

client, err := aauthagent.NewClient(ctx, aauthagent.Config{
	AgentProvider: "https://ap.aauth.test",
	EnrollPath:    "/enroll",
	OnInteraction: func(i aauthagent.Interaction) { fmt.Println("Approve at", i.Link()) },
})
skill := openapi.NewSkill(openapi.Config{
	Name:       "petstore",
	SpecURL:    "https://petstore.aauth.test/openapi.json",
	HTTPClient: client.HTTPClient(),
})

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is an enrolled AAuth agent.

func NewClient

func NewClient(ctx context.Context, cfg Config) (*Client, error)

NewClient enrolls the agent's key at the agent provider and returns a client acting as that agent.

func (*Client) AgentID

func (c *Client) AgentID() string

AgentID returns the agent's identifier, such as aauth:assistant@ap.aauth.test.

func (*Client) HTTPClient

func (c *Client) HTTPClient() *http.Client

HTTPClient returns the client that signs and authorizes requests.

func (*Client) PersonServer

func (c *Client) PersonServer() string

PersonServer returns the person server the agent token names.

type Config

type Config struct {
	// AgentProvider is the agent provider's issuer URL. Required.
	AgentProvider string
	// EnrollPath is the provider's token endpoint path (default
	// agentprovider.DefaultPaths().Token). The aauth-go sandbox uses
	// /enroll.
	EnrollPath string
	// Enrollment is sent with the enrollment request: the provider's own
	// enrollment fields. Nil sends {}.
	Enrollment any
	// Key is the agent's signing key. Nil generates an Ed25519 key, so the
	// agent is new each time; pass a stored key to keep its identity.
	Key crypto.Signer
	// RootCAsPEM holds certificates to trust as well as the system roots,
	// such as the aauth-go sandbox CA.
	RootCAsPEM []byte
	// Base is the transport requests are sent on (default: one trusting
	// the system roots and RootCAsPEM).
	Base http.RoundTripper
	// OnInteraction is called when the person must act, such as approving
	// access at their person server. The request waits meanwhile.
	OnInteraction func(Interaction)
}

Config configures NewClient.

type Interaction

type Interaction struct {
	URL  string
	Code string
}

Interaction asks the person to act at URL, entering or confirming Code.

func (i Interaction) Link() string

Link returns URL with the code as its code query parameter, which an interaction page accepts in place of typing it.

Jump to

Keyboard shortcuts

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