steward

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 0 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.

README

steward

Act as the caller: Google sign-in and per-user Google tokens for go-steer MCP and HTTP services, on top of purser.

A purser checks who is aboard; a steward looks after passengers' belongings on their behalf. Given a request carrying a person's Google access token, steward decides whether the token is good for this service, who it belongs to and whether that person is let in, then hands the service a purser.Caller and a token source for calling Google APIs and GKE clusters as that person. What they can see is then what their own IAM and Kubernetes RBAC allow.

Status: v0.4.0, Path A and Path B. Verification (googletoken), admission by email, domain and Google group (allow), request wiring (httpauth), MCP session binding (mcpauth), and steward's own OAuth 2.1 authorization server (authserver, with token sealing in seal). Pin v0.4.0 rather than a commit. Pre-1.0, the exported API may break at a minor version. See docs/DESIGN.md.

Use

Protect an MCP endpoint that a Gemini Enterprise app calls with each person's Google token, and read Google APIs as that person:

v, err := googletoken.New(googletoken.Config{
	ClientIDs:      []string{oauthClientID}, // the client Gemini Enterprise is configured with
	RequiredScopes: []string{"https://www.googleapis.com/auth/cloud-platform"},
	// No Logger needed: an outage is a 503 that purser logs at Warn, through
	// httpauth.Options.Logger or slog.Default(). Setting one doubles the lines.
})
admit, err := allow.Parse([]string{"@example.com", "contractor@gmail.com"})
a, err := googletoken.NewAuthenticator(v, admit)
p, err := httpauth.New(httpauth.Options{
	Authenticator: a,
	Resource:      "https://svc.example.com/mcp",
	Scopes:        []string{"openid", "email", "https://www.googleapis.com/auth/cloud-platform"},
})

mux.Handle(p.MetadataPath(), p.MetadataHandler())  // RFC 9728, unauthenticated
mux.Handle("/mcp", mcpauth.Middleware(p)(mcpHandler)) // or p.Middleware() for stateless HTTP

// In an MCP tool handler (stateful sessions): read from the request, not
// the context, which the SDK freezes at the session's first request.
ts, _ := mcpauth.TokenSource(req) // the person's own Google token, for this call
id, _ := mcpauth.Identity(req)    // id.Email, id.HD, id.Subject

// In a plain HTTP handler behind p.Middleware():
caller, _ := purser.CallerFromContext(r.Context())   // caller.Identity is the email
ts, _ = httpauth.TokenSourceFromContext(r.Context()) // their own Google token

Add Path B for generic MCP clients (Claude Code, gemini-cli, IDEs), which discover an authorization server and register with it: mount steward's in front of Google sign-in, and let the same Protector accept its tokens too:

keys, err := secretmanager.NewProvider(secretmanager.Source{
	Client:  smClient, // authorized with secretmanager.Scope
	Version: "projects/my-project/secrets/svc-keys/versions/latest",
}, 0, slog.Default())
groups := &allow.CloudIdentityGroups{Client: ciClient} // Groups Reader
list, err := allow.Parse([]string{"@example.com", "group:svc-users@example.com"})
admitter, err := allow.NewAdmitter(list, groups)
as, err := authserver.New(authserver.Config{
	Issuer:   "https://svc.example.com",
	Resource: "https://svc.example.com/mcp",
	Scopes:   []string{"svc:read", "svc:write"},
	Google:   googleClient, // authserver.LoadGoogleClient(path); register as.CallbackURL() with it
	Custody:  &authserver.VaultCustody{AuthProvider: authProvider, Client: vaultClient},
	Admit:    admitter,
	Keys:     keys,
	OpenRegistration: true, // DCR and Client ID Metadata Documents
})
as.Register(mux) // metadata, /authorize, /callback, /token, /register, ...
p, err := httpauth.New(httpauth.Options{
	Authenticator: a,  // Path A, as above (optional)
	AuthServer:    as, // Path B
	Resource:      "https://svc.example.com/mcp",
})

// A person arrives the same way on either path (mcpauth.TokenSource,
// mcpauth.Identity). A workload that used client credentials has no
// person: mcpauth.Principal(req) (or httpauth.PrincipalFromContext) says
// p.Workload, and p.Scopes holds the granted service scopes.

Why it exists

Several go-steer services need the same thing: let a person reach the service through an agent such as Gemini Enterprise, and have the service read on that person's behalf, with that person's permissions, instead of with one shared service identity.

  • supercargo checks Gemini Enterprise users' Google tokens today, in its own internal/googleauth.
  • k8s-lookout needs the same check plus the token itself, so its Kubernetes and Cloud reads run as the person (k8s-lookout#699).

Doing it once means one implementation of the parts that are easy to get subtly wrong: checking that a token was issued to your client, telling Google failing from Google refusing, and not trusting an email suffix as proof of a Workspace domain.

Two paths

Path Who holds the user's Google grant For Status
A The client (Gemini Enterprise); the service checks the token it sends Gemini Enterprise Custom MCP Servers v0.1.0
B The service, as its own OAuth 2.1 authorization server MCP clients that register dynamically (Claude Code, gemini-cli, IDEs) v0.2.0

Development

See CONTRIBUTING.md and AGENTS.md. dev/tools/ci runs every presubmit locally; dev/README.md describes each one.

License

Apache 2.0 — see LICENSE.

Documentation

Overview

Package steward lets a go-steer service act as its caller.

A steward looks after passengers' belongings on their behalf; purser (github.com/go-steer/purser) checks who is aboard. This module is the first half's complement: given a request carrying a person's Google access token, it decides whether the token is good for this service, who it belongs to, and whether that person is let in, and then hands the service a purser.Caller plus a token source it can use to call Google APIs and GKE clusters as that person.

The design, the hard rules and the phase plan are in docs/DESIGN.md.

Directories

Path Synopsis
Package allow decides which verified Google accounts are let in.
Package allow decides which verified Google accounts are let in.
Package authserver is steward's OAuth 2.1 authorization server (Path B): a service mounts it at an issuer URL in front of Google sign-in, so MCP clients that expect to discover an authorization server and register with it (Claude Code, gemini-cli, IDEs) can sign people in, and the service then acts as each person with their own Google access token.
Package authserver is steward's OAuth 2.1 authorization server (Path B): a service mounts it at an issuer URL in front of Google sign-in, so MCP clients that expect to discover an authorization server and register with it (Claude Code, gemini-cli, IDEs) can sign people in, and the service then acts as each person with their own Google access token.
Package googletoken verifies the Google OAuth access tokens a client presents on a person's behalf, such as the ones a Gemini Enterprise app sends to a Custom MCP Server.
Package googletoken verifies the Google OAuth access tokens a client presents on a person's behalf, such as the ones a Gemini Enterprise app sends to a Custom MCP Server.
Package httpauth protects an HTTP resource and hands each request the caller's own Google token.
Package httpauth protects an HTTP resource and hands each request the caller's own Google token.
internal
pathbtest
Package pathbtest helps tests drive steward's authorization server end to end: a fake Google sign-in, a browser that approves the consent page, and helpers that obtain access tokens over HTTP.
Package pathbtest helps tests drive steward's authorization server end to end: a fake Google sign-in, a browser that approves the consent page, and helpers that obtain access tokens over HTTP.
Package mcpauth serves an MCP server built on github.com/modelcontextprotocol/go-sdk behind an httpauth.Protector: it binds each session to the person who opened it, and gives each call the token that came with it.
Package mcpauth serves an MCP server built on github.com/modelcontextprotocol/go-sdk behind an httpauth.Protector: it binds each session to the person who opened it, and gives each call the token that came with it.
Package seal turns small values into opaque, tamper-proof strings and back: AES-256-GCM envelopes under a keyring whose keys are named by ID, so a key is rotated without a database and any replica holding the keyring opens what another sealed.
Package seal turns small values into opaque, tamper-proof strings and back: AES-256-GCM envelopes under a keyring whose keys are named by ID, so a key is rotated without a database and any replica holding the keyring opens what another sealed.
secretmanager
Package secretmanager loads a seal.Keyring from a Google Secret Manager secret version, so the keys that seal steward's tokens live in Secret Manager and a rotation is a new secret version.
Package secretmanager loads a seal.Keyring from a Google Secret Manager secret version, so the keys that seal steward's tokens live in Secret Manager and a rotation is a new secret version.

Jump to

Keyboard shortcuts

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