Help us shape the future of Go! Take the 2026 Go Developer Survey

authcheck

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package authcheck discovers how an MCP server over HTTP is protected (Protected Resource Metadata, authorization server metadata) and checks it against the authorization rules of spec 2026-07-28 and the auth extensions (ext-auth: OAuth client credentials, enterprise-managed authorization).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery struct {
	Challenge     string   `json:"challenge,omitempty"` // WWW-Authenticate of the 401
	MetadataURL   string   `json:"resourceMetadataUrl"`
	Resource      string   `json:"resource"`
	AuthServers   []string `json:"authorizationServers"`
	ASMetadataURL string   `json:"authServerMetadataUrl,omitempty"`
	// contains filtered or unexported fields
}

Discovery is what a client learns before authorizing.

func Discover

func Discover(ctx context.Context, endpoint string, c *http.Client) (*Discovery, error)

Discover finds the Protected Resource Metadata (from the 401 challenge, else the well-known URIs) and the first authorization server's metadata. It returns nil, nil if the endpoint does not require authorization.

func (*Discovery) AuthServer

func (d *Discovery) AuthServer() string

AuthServer returns the first advertised authorization server.

type Flow

type Flow struct {
	Name      string `json:"name"`
	Supported bool   `json:"supported"`
	Detail    string `json:"detail,omitempty"`
	Flag      string `json:"flag,omitempty"` // how mcp-tester uses it
}

Flow is an authorization flow the server offers.

type Report

type Report struct {
	Endpoint     string         `json:"endpoint"`
	Protected    bool           `json:"protected"`
	Discovery    *Discovery     `json:"discovery,omitempty"`
	Flows        []Flow         `json:"flows,omitempty"`
	Results      []Result       `json:"results"`
	AuthServer   map[string]any `json:"authServerMetadata,omitempty"`
	ResourceMeta map[string]any `json:"resourceMetadata,omitempty"`
}

Report is the outcome of a check run.

func Check

func Check(ctx context.Context, endpoint string, c *http.Client) *Report

Check runs discovery and all checks against endpoint.

func (*Report) Failed

func (r *Report) Failed() bool

Failed reports whether any check failed.

type Result

type Result struct {
	Name   string `json:"name"`
	Status Status `json:"status"`
	Detail string `json:"detail,omitempty"`
}

Result is the outcome of one check.

type Status

type Status string

Status of one check.

const (
	Pass Status = "PASS"
	Fail Status = "FAIL" // a MUST is violated
	Warn Status = "WARN" // a SHOULD is violated or a deprecated mechanism is in use
	Info Status = "INFO"
	Skip Status = "SKIP"
)

Jump to

Keyboard shortcuts

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