mcpauth

package
v1.5.113 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpauth implements opt-in, source-scoped MCP OAuth transactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBrowserUnavailable  = errors.New("private authorization browser is unavailable; a visible Golder workspace or supported GUI is required")
	ErrAuthorizationDenied = errors.New("authorization was denied by the provider")
)

Functions

func Stored

func Stored(source, fingerprint, resourceURL string, observers ...func(...string)) (auth.OAuthHandler, error)

Stored returns a non-interactive handler for a previously authorized source. A 401/403 never launches a browser from an agent tool call.

Types

type Flow

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

Flow owns one loopback callback listener and one authorization transaction. It must be closed when the explicit operator action ends.

func New

func New(source, fingerprint, resourceURL string, open Open, observers ...func(...string)) (*Flow, error)

New creates the listener before dynamic client registration so its exact redirect URI can be registered. It never starts a browser without Open.

func NewWithClient

func NewWithClient(source, fingerprint, resourceURL string, registration Registration, open Open, observers ...func(...string)) (*Flow, error)

NewWithClient also accepts an explicitly configured public client. It does not support embedded confidential client secrets.

func (*Flow) Authorize

func (f *Flow) Authorize(ctx context.Context, request *http.Request, response *http.Response) error

func (*Flow) Close

func (f *Flow) Close()

func (*Flow) TokenSource

func (f *Flow) TokenSource(ctx context.Context) (oauth2.TokenSource, error)

type Open

type Open func(ctx context.Context, review Review, startURL string) (close func(), err error)

Open is an operator-only browser launcher. It must ask the person to review the host/scopes, then open startURL in an isolated browser. startURL points to a random loopback trampoline, not the authorization endpoint or a secret.

type Registration

type Registration struct {
	ClientID string
	Issuer   string
}

Registration optionally supplies a public pre-registered OAuth client ID. An HTTPS client ID with a non-root path can also be a metadata document.

type Review

type Review struct {
	Host   string
	Scopes []string
}

Review contains only the authorization domain and requested scope. The complete authorization URL and state stay in the private transaction.

Jump to

Keyboard shortcuts

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