httphandler

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCodeData

type AuthCodeData struct {
	ClientID            string `json:"client_id,omitempty"`
	CodeChallenge       string `json:"code_challenge"`
	CodeChallengeMethod string `json:"code_challenge_method"`
	Resource            string `json:"resource,omitempty"`
	UpstreamTokenKey    string `json:"upstream_token_key"` // アップストリーム・トークンのRedisキー
	MCPServerName       string `json:"mcp_server_name"`
}

AuthCodeData 認証コードとトークンの交換に関するデータを保持。

type AuthHandler

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

AuthHandler CLIおよびMCPクライアントの両方に対して、OAuth 2.1認証サーバーを実装。

func NewAuthHandler

func NewAuthHandler(
	storeClient store.Client,
	servers config.Servers,
	opts ...AuthHandlerOption,
) *AuthHandler

func (*AuthHandler) CallbackEndpoint

func (h *AuthHandler) CallbackEndpoint(
	w http.ResponseWriter,
	r *http.Request,
	srv *config.Server,
)

func (*AuthHandler) LoginEndpoint

func (h *AuthHandler) LoginEndpoint(w http.ResponseWriter, r *http.Request, srv *config.Server)

func (*AuthHandler) MetadataEndpoint

func (h *AuthHandler) MetadataEndpoint(w http.ResponseWriter, r *http.Request, srv *config.Server)

MetadataEndpoint serves /.well-known/oauth-authorization-server

func (*AuthHandler) OauthProtectedResource

func (h *AuthHandler) OauthProtectedResource(
	w http.ResponseWriter,
	r *http.Request,
	srv *config.Server,
)

func (*AuthHandler) RegisterClientEndpoint

func (h *AuthHandler) RegisterClientEndpoint(
	w http.ResponseWriter,
	r *http.Request,
	srv *config.Server,
)

RegisterClientEndpoint POST /auth/clients リクエストを処理します(動的クライアント登録、RFC 7591)。

func (*AuthHandler) RegisterClientEndpointByClaudeCode added in v1.2.0

func (h *AuthHandler) RegisterClientEndpointByClaudeCode(w http.ResponseWriter, r *http.Request)

RegisterClientEndpoint POST /auth/clients リクエストを処理します(動的クライアント登録、RFC 7591)。

func (*AuthHandler) RegisterRoutes

func (h *AuthHandler) RegisterRoutes(
	mux *http.ServeMux,
	pathServerName string,
	middleware func(h http.HandlerFunc) http.HandlerFunc,
)

func (*AuthHandler) TokenEndpoint

func (h *AuthHandler) TokenEndpoint(
	w http.ResponseWriter,
	r *http.Request,
	srv *config.Server,
)

type AuthHandlerOption added in v1.2.0

type AuthHandlerOption func(h *AuthHandler)

func WithEncryptKey added in v1.2.0

func WithEncryptKey(key []byte) AuthHandlerOption

func WithEncryptKeyByBase64 added in v1.2.0

func WithEncryptKeyByBase64(key string) AuthHandlerOption

type AuthSession

type AuthSession struct {
	ClientID            string `json:"client_id,omitempty"`
	RedirectURI         string `json:"redirect_uri,omitempty"`
	State               string `json:"state,omitempty"`
	CodeChallenge       string `json:"code_challenge,omitempty"`
	CodeChallengeMethod string `json:"code_challenge_method,omitempty"`
	Resource            string `json:"resource,omitempty"` // RFC 8707
	// アップストリームのOAuth2設定のスナップショット(コールバック時に必要)
	OAuth2ClientID     string   `json:"oauth2_client_id,omitempty"`
	OAuth2ClientSecret string   `json:"oauth2_client_secret,omitempty"`
	OAuth2TokenURL     string   `json:"oauth2_token_url,omitempty"`
	OAuth2Scopes       []string `json:"oauth2_scopes,omitempty"`
	// 上流認可サーバーへのリクエストで使用した PKCE code_verifier
	UpstreamCodeVerifier string `json:"upstream_code_verifier,omitempty"`
	MCPServerName        string `json:"mcp_server_name"`
}

AuthSession 進行中の認証セッションのために、Redisに保存されたデータを保持。

type ClientRegistration

type ClientRegistration struct {
	ClientID                string   `json:"client_id"`
	ClientIDIssuedAt        int64    `json:"client_id_issued_at"`
	RedirectURIs            []string `json:"redirect_uris"`
	GrantTypes              []string `json:"grant_types"`
	ResponseTypes           []string `json:"response_types"`
	ClientName              string   `json:"client_name,omitempty"`
	TokenEndpointAuthMethod string   `json:"token_endpoint_auth_method,omitempty"`
}

ClientRegistration 動的に登録された OAuth 2.0 クライアント(RFC 7591)を保持。

type EdgePairHandler added in v1.7.0

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

EdgePairHandler serves POST /edge/pair, exchanging a pairing code (issued via the create_pairing_code tool) for a long-lived edge token.

func NewEdgePairHandler added in v1.7.0

func NewEdgePairHandler(
	pairing *edgeservices.PairingService,
	edgeCfg config.EdgeConfig,
) *EdgePairHandler

NewEdgePairHandler creates an EdgePairHandler backed by pairing. Each trusted-proxy group gets its own remoteaddr.Addr scoped to the single header that group's proxy actually sets: RFC1918 (always, since it can't be spoofed over the internet) and edge.trustedForwarders (an operator-supplied CIDR, e.g. an ALB/Ingress subnet) both read X-Forwarded-For, while Cloudflare's published ranges — opt-in via edgeCfg.TrustCloudflare — read CF-Connecting-IP. Keeping the headers scoped per group stops a request that only arrives through one trusted proxy from forging the header another group would trust — see docs/design/webmcp-reverse-gateway-phase2.ja.md「Phase 1 からの持ち越し判断事項」.

func (*EdgePairHandler) Pair added in v1.7.0

Pair handles POST /edge/pair {"code": "12345678", "token": "<existing edge token, optional>"} -> {"token": "..."}.

type EdgeWSHandler added in v1.7.0

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

EdgeWSHandler serves GET /edge/ws: the browser extension's outbound WebSocket connection for the WebMCP reverse-connection gateway (see docs/design/webmcp-reverse-gateway.ja.md).

func NewEdgeWSHandler added in v1.7.0

func NewEdgeWSHandler(
	edgeCfg config.EdgeConfig,
	pairing *edgeservices.PairingService,
	gateway *mcpsrv.ReverseGateway,
) *EdgeWSHandler

NewEdgeWSHandler creates an EdgeWSHandler.

func (*EdgeWSHandler) ServeHTTP added in v1.7.0

func (h *EdgeWSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for GET /edge/ws.

type HealthHandler added in v1.4.0

type HealthHandler struct{}

HealthHandler は liveness/readiness probe 向けのヘルスチェックエンドポイントを提供する。

func NewHealthHandler added in v1.4.0

func NewHealthHandler() *HealthHandler

NewHealthHandler は HealthHandler を生成する。

func (*HealthHandler) Healthz added in v1.4.0

func (h *HealthHandler) Healthz(w http.ResponseWriter, r *http.Request)

Healthz はプロセスが応答可能であることを示すエンドポイント。常に200 okを返す。

type MCPHandler added in v1.2.0

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

func NewMCPHandler added in v1.2.0

func NewMCPHandler(
	cfg config.Servers, catalog ToolCataloger, authzCfg config.AuthzConfig, decider authz.Decider,
) *MCPHandler

NewMCPHandler builds an MCPHandler. decider is nil when authzCfg.Enabled is false; it must be non-nil whenever authzCfg.Enabled is true, since allowToolCatalog denies (fails closed) rather than dereferencing a nil Decider.

func (*MCPHandler) MCPList added in v1.2.0

func (h *MCPHandler) MCPList(w http.ResponseWriter, r *http.Request)

type MediaHandler added in v1.3.0

type MediaHandler struct {
	ContentManager *storage.ContentManagementService
}

func (*MediaHandler) DownloadContent added in v1.3.0

func (m *MediaHandler) DownloadContent(w http.ResponseWriter, r *http.Request)

type RefreshTokenSession added in v1.2.1

type RefreshTokenSession struct {
	OAuth2ClientID     string   `json:"oauth2_client_id"`
	OAuth2ClientSecret string   `json:"oauth2_client_secret"`
	OAuth2TokenURL     string   `json:"oauth2_token_url"`
	OAuth2Scopes       []string `json:"oauth2_scopes"`
	MCPServerName      string   `json:"mcp_server_name"`
	Resource           string   `json:"resource,omitempty"`
	ClientID           string   `json:"client_id,omitempty"`
}

RefreshTokenSession リフレッシュトークン使用時に上流 OAuth2 設定を復元するためのデータ。

type StoreClientRegistration added in v1.2.0

type StoreClientRegistration struct {
	ClientRegistration
	MCPServerName string `json:"mcp_server_name"`
}

type ToolCataloger added in v1.11.0

type ToolCataloger interface {
	ToolCatalog(ctx context.Context, name string) ([]mcpsrv.ToolInfo, error)
}

ToolCataloger resolves a server's full tool catalog for the admin listing (?tools=true), independent of the per-caller tools/list authz filtering NewAuthzMiddleware applies on the mcp.Server path.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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