Documentation
¶
Overview ¶
Package server assembles the single HTTP listener: health endpoints, the REST API and the MCP streamable-HTTP endpoint, both behind the same OAuth guard when configured. Without OAuth there is no authentication here: only a server nothing but a trusted proxy can reach (the agentgateway JWT policy in front of the route, muster in front of the MCP endpoint) runs that way, and it then acts as its ServiceAccount.
Index ¶
Constants ¶
const ( ProviderDex = "dex" ProviderGoogle = "google" )
OAuth providers.
const DefaultGitHubAPIURL = "https://api.github.com"
DefaultGitHubAPIURL is GitHub's REST API.
const DefaultGitHubCacheTTL = 15 * time.Minute
DefaultGitHubCacheTTL is how long a verified bearer is trusted without a second GET /user: a user token's expiry is not readable from the token, and a revoked one must stop working soon.
const ForwardedIdentityHeader = "X-Muster-Id-Token"
ForwardedIdentityHeader is where muster puts the person's IdP ID token on every call to a registration with auth.forwardIdentity.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Addr string
MCPEnabled bool
MCPPath string
// OAuth, when set, makes the server an OAuth 2.1 resource server: the MCP
// endpoint and the REST API require a bearer token the platform IdP
// issued (forwarded by muster / sent by the portal) or this server's own,
// and every call carries the caller's identity. Off: anonymous, acting as
// the ServiceAccount.
OAuth *OAuthConfig
}
Config configures the listener.
type GitHubPin ¶ added in v1.5.0
type GitHubPin struct {
// AuthorizationServer is the App's issuer identity muster pins,
// https://github.com/apps/giantswarm-agent-manager: named in the
// refusals.
AuthorizationServer string
// APIURL is the API base URL GET /user goes to (empty: api.github.com).
APIURL string
// CacheTTL bounds how long a verified bearer is trusted without asking
// GitHub again (zero: DefaultGitHubCacheTTL).
CacheTTL time.Duration
}
GitHubPin makes the MCP endpoint the App-pinned registration muster connects with (MCPServer auth.authorizationServer pinned to the App giantswarm-agent-manager, auth.forwardIdentity: true): the bearer is the person's user token of the App, verified with GET /user and kept for commit mode's pull request, and the person's IdP ID token arrives in ForwardedIdentityHeader. That token then goes through the same validation and the same Kubernetes-as-the-caller path a forwarded bearer takes without the pin, so apply mode is unchanged.
type OAuthConfig ¶ added in v0.2.0
type OAuthConfig struct {
// BaseURL is the public URL of this server: the OAuth issuer identifier
// of its own authorization-server metadata (https, or http on loopback).
BaseURL string
// Provider is the IdP: dex (default) or google.
Provider string
// Dex provider (Provider == dex).
DexIssuerURL string
DexClientID string
DexClientSecret string
// DexCAFile is a PEM CA bundle for an IdP with a private certificate;
// verifies discovery, token and JWKS calls. Empty: system trust.
DexCAFile string
// DexAllowPrivateIP lets the issuer resolve to a private/loopback address
// (an in-cluster Dex).
DexAllowPrivateIP bool
// Google provider (Provider == google).
GoogleClientID string
GoogleClientSecret string
// TrustedAudiences are the OAuth client ids whose IdP id_tokens are
// accepted as bearers (SSO token forwarding): the platform client, and
// the audiences the MCPServer requires — what the kube-apiserver trusts,
// which every token muster forwards carries by construction (the chart
// unions both). A portal session's id_token names the portal's own
// client, not the platform client. Empty: only tokens this server issued
// itself.
TrustedAudiences []string
// SSOAllowPrivateIPs lets the JWKS endpoint used for forwarded tokens
// resolve to a private address (an in-cluster Dex).
SSOAllowPrivateIPs bool
// AllowPublicClientRegistration lets MCP clients register over DCR
// without a token (labs only).
AllowPublicClientRegistration bool
// DownstreamOAuth puts the caller's IdP token on the request so every
// Kubernetes API call is made as the caller instead of the ServiceAccount
// (the apiserver must trust the IdP and the token's audience). The
// ServiceAccount then holds no permissions, so a request whose caller has
// no IdP token to present is refused (401) rather than run as nobody.
DownstreamOAuth bool
// GitHub, when set, pins the MCP registration to the App: the bearer on
// the MCP endpoint is the person's App user token and the IdP ID token
// arrives in ForwardedIdentityHeader (GitHubPin). The REST API keeps
// taking the IdP token as its bearer.
GitHub *GitHubPin
}
OAuthConfig makes agent-manager an OAuth 2.1 resource server (mcp-oauth) in front of the MCP endpoint and the REST API. The platform's identity provider is the authority: on the Agent Platform, muster forwards the session's IdP id_token byte-identical (MCPServer auth.forwardToken) and the portal sends the signed-in user's id_token through the gateway; both are validated here against the IdP's JWKS when their audience is one of TrustedAudiences (the platform's OAuth client). The caller's identity then travels with the request (identity package) and, with DownstreamOAuth, so does the token — every Kubernetes call is made as the caller.
func (OAuthConfig) Validate ¶ added in v0.2.0
func (c OAuthConfig) Validate() error
Validate checks required fields.