emauth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package emauth provides MCP Enterprise-Managed Authorization support for mcp-google: audit logging and scope-based tool gating driven by the identity verified from an ID-JAG-derived access token.

The identity (subject, RFC 8693 act delegation chain, scope) is placed in the request context by omniskill's ExternalBearerMiddleware; this package consumes it at the MCP method layer via a receiving middleware.

Index

Constants

View Source
const (
	ScopeDocs   = "docs:read"
	ScopeSheets = "sheets:read"
	ScopeSlides = "slides:read"
	ScopeDrive  = "drive:read"

	// ScopeDriveWrite authorizes the write tools, which exist only when the
	// server is started with --enable-write.
	ScopeDriveWrite = "drive:write"
)

Scopes understood by mcp-google. When the verified token carries a scope claim, every tool call requires the tool's mapped scope; tokens without a scope claim are not gated (identity is still audit-logged).

Variables

This section is empty.

Functions

func HasScope

func HasScope(scopes, required string) bool

HasScope reports whether the space-delimited scope string contains the required scope.

func Middleware

func Middleware(logger *slog.Logger) mcp.Middleware

Middleware returns an MCP receiving middleware that audit-logs the verified identity on every tool call and, when the token carries a scope claim, denies calls to unmapped tools and calls whose token scope does not cover the tool's mapped scope. Non-tool methods pass through untouched.

func RequiredScope

func RequiredScope(toolName string) (scope string, ok bool)

RequiredScope returns the policy scope that authorizes the tool with the given exact name, and whether the tool is mapped at all. Unmapped tools report ok == false and are denied when a scope claim is present.

func ToolScopes added in v0.5.0

func ToolScopes() map[string]string

ToolScopes returns a copy of the tool → scope authorization map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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