mcp

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mcp provides Model Context Protocol-flavored helpers on top of authlet's AS. Currently:

  • PRM (RFC 9728 Protected Resource Metadata) JSON handler
  • WWW-Authenticate challenge string with resource_metadata pointer

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChallengeHeader

func ChallengeHeader(resourceMetadataURL string) string

ChallengeHeader builds a WWW-Authenticate value pointing at the PRM URL. Use it in your 401 responses (or rely on pkg/rs.Middleware, which sets this automatically when ResourceMetadata is configured).

func PRMHandler

func PRMHandler(p PRM) http.HandlerFunc

PRMHandler returns an http.HandlerFunc that serves the given PRM document as JSON with a public Cache-Control header. Mount it at the .well-known/oauth-protected-resource path appropriate for the resource. Only GET is accepted; other methods receive 405.

Types

type PRM

type PRM struct {
	// Resource is the canonical URL of the protected resource.
	Resource string `json:"resource"`
	// AuthorizationServers lists the issuer URLs that may mint tokens for
	// this resource.
	AuthorizationServers []string `json:"authorization_servers"`
	// BearerMethodsSupported enumerates how clients may present bearer
	// tokens (e.g. "header", "body", "query"). Optional.
	BearerMethodsSupported []string `json:"bearer_methods_supported,omitempty"`
	// ScopesSupported lists scope values the resource recognises. Optional.
	ScopesSupported []string `json:"scopes_supported,omitempty"`
}

PRM is the Protected Resource Metadata JSON document defined by RFC 9728. It advertises which authorization servers can issue tokens for the resource and which bearer methods and scopes the resource accepts.

Jump to

Keyboard shortcuts

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