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 ¶
NewClient enrolls the agent's key at the agent provider and returns a client acting as that agent.
func (*Client) AgentID ¶
AgentID returns the agent's identifier, such as aauth:assistant@ap.aauth.test.
func (*Client) HTTPClient ¶
HTTPClient returns the client that signs and authorizes requests.
func (*Client) PersonServer ¶
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 ¶
Interaction asks the person to act at URL, entering or confirming Code.
func (Interaction) Link ¶
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.