Documentation
¶
Overview ¶
Package credentials implements clawpatrol credentials support.
Index ¶
- type AWSCredential
- func (*AWSCredential) EnvVars() []config.EnvVar
- func (*AWSCredential) MintEKSBearer(ctx context.Context, sec runtime.Secret, region, cluster string) (string, error)
- func (*AWSCredential) SecretSlots() []config.SecretSlot
- func (c *AWSCredential) SignHTTPRequest(ctx context.Context, req *http.Request, sec runtime.Secret, endpoint any) error
- type AnthropicManualKey
- type AnthropicOAuthSubscription
- type BasicAuth
- type BearerToken
- type ClickhouseCredential
- func (c *ClickhouseCredential) ClickhouseAuth(sec runtime.Secret) (string, string)
- func (c *ClickhouseCredential) CredentialDatabase() string
- func (c *ClickhouseCredential) CredentialDisambiguators() map[string]string
- func (c *ClickhouseCredential) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
- func (*ClickhouseCredential) SecretSlots() []config.SecretSlot
- type CookieToken
- type DiscordBotToken
- func (*DiscordBotToken) EnvVars() []config.EnvVar
- func (*DiscordBotToken) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
- func (*DiscordBotToken) RewriteWebSocketPayload(_ context.Context, payload []byte, sec runtime.Secret) ([]byte, bool, error)
- func (*DiscordBotToken) SecretSlots() []config.SecretSlot
- type GeminiAPIKey
- type GitHubOAuth
- type GoogleGKECredential
- type HeaderToken
- type MTLSCredential
- type NotionMCPOAuth
- type NotionOAuth
- type OpenAICodexOAuth
- type Passthrough
- type PostgresCredential
- type SSHCredential
- type SlackTokens
- func (s *SlackTokens) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
- func (s *SlackTokens) NotifyHITL(ctx context.Context, req runtime.ApproveRequest, target runtime.HITLTarget) error
- func (*SlackTokens) SecretSlots() []config.SecretSlot
- func (s *SlackTokens) UpdateHITLMessage(ctx context.Context, secrets runtime.SecretStore, ...) error
- func (*SlackTokens) WebhookRoutes() []runtime.WebhookRoute
- type TailscaleCredential
- type TelegramBotToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSCredential ¶
type AWSCredential struct{}
AWSCredential is part of the clawpatrol plugin API.
Schema is intentionally empty: access key id and secret access key (and optional session token) live in the secret store as named slots, filled via the dashboard or CLAWPATROL_SECRET_<NAME>_<SLOT> env vars. Cluster + region come from the kubernetes endpoint at request time.
func (*AWSCredential) EnvVars ¶ added in v0.2.6
func (*AWSCredential) EnvVars() []config.EnvVar
EnvVars is part of the clawpatrol plugin API.
Mirrors the Anthropic OAuth credential's pushdown (see anthropic_oauth.go): aws-cli and the AWS SDKs read credentials out of the process environment, so `clawpatrol env` exports placeholders that satisfy local SigV4 signing. The gateway re-signs the proxied request with the operator's real stored creds at MITM time (reSignProxiedRequest), so these placeholder bytes never authenticate anything upstream.
func (*AWSCredential) MintEKSBearer ¶
func (*AWSCredential) MintEKSBearer(ctx context.Context, sec runtime.Secret, region, cluster string) (string, error)
MintEKSBearer implements runtime.EKSBearerMinter — same code path SignHTTPRequest uses, exported so the kubernetes_port_forward tunnel can build a self-contained kubeconfig without a parallel STS presign.
func (*AWSCredential) SecretSlots ¶
func (*AWSCredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type AnthropicManualKey ¶
type AnthropicManualKey struct{}
AnthropicManualKey is part of the clawpatrol plugin API.
func (*AnthropicManualKey) EnvVars ¶
func (*AnthropicManualKey) EnvVars() []config.EnvVar
EnvVars intentionally returns nothing.
Pushing ANTHROPIC_API_KEY conflicts with the AnthropicOAuthSubscription plugin's ANTHROPIC_AUTH_TOKEN — Claude Code and the Anthropic SDKs honor whichever is set first, and when both are set with placeholders, the SDK's own validation rejects the request before it reaches the gateway. Until the env-pushdown layer scopes vars to the profile's active credentials (rather than the union of every registered plugin), the manual-key plugin stays silent. Operators who want the x-api-key header still get it via InjectHTTP — no pushdown needed.
func (*AnthropicManualKey) InjectHTTP ¶
func (a *AnthropicManualKey) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
InjectHTTP is part of the clawpatrol plugin API.
func (*AnthropicManualKey) SecretSlots ¶
func (*AnthropicManualKey) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type AnthropicOAuthSubscription ¶
type AnthropicOAuthSubscription struct{}
AnthropicOAuthSubscription is part of the clawpatrol plugin API.
func (*AnthropicOAuthSubscription) EnvVars ¶
func (*AnthropicOAuthSubscription) EnvVars() []config.EnvVar
EnvVars is part of the clawpatrol plugin API.
ANTHROPIC_AUTH_TOKEN is the standard env-var shape for the raw Anthropic SDKs (Python, Node.js, …) and Claude Code. The value is a placeholder; the gateway rewrites the Authorization header at MITM time via InjectHTTP, so the bytes here never reach Anthropic — the operator's gateway-stored OAuth bearer (with the scopes requested by OAuthFlow below, including user:sessions:claude_code) authenticates upstream calls, including the session-register step `/remote-control` depends on.
Caveat for the `claude` CLI: it refuses OAuth-only features like `/remote-control` whenever ANTHROPIC_AUTH_TOKEN is present (it reads the env var as bearer/API-key auth via a LOCAL gate, before any network call). `clawpatrol run` works around that for the `claude` binary specifically via installClaudeCodeOAuthShim — it strips this env var and supplies a synthesized OAuth credential instead. See cmd/clawpatrol/integrations.go and doc/claude-code-oauth.md.
func (*AnthropicOAuthSubscription) InjectHTTP ¶
func (a *AnthropicOAuthSubscription) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
InjectHTTP is part of the clawpatrol plugin API.
func (*AnthropicOAuthSubscription) OAuthFlow ¶
func (a *AnthropicOAuthSubscription) OAuthFlow() *config.OAuthIntegration
OAuthFlow on AnthropicOAuthSubscription returns Anthropic's OAuth subscription flow (claude.ai → console.anthropic.com). Bootstrap refresh token is templated as `{{secret:CLAUDE_REFRESH}}` so the gateway can mint per-owner sessions from operator-provided env before the dashboard connect flow has run.
type BasicAuth ¶ added in v0.2.12
type BasicAuth struct {
// Username is the upstream HTTP Basic Auth username.
Username string `hcl:"username"`
}
BasicAuth injects `Authorization: Basic <base64(username:password)>`.
The credential secret is the raw password; `username` lives in config. Common credential binding fields apply: use `endpoint` or `endpoints` to bind the credential to upstreams.
When a profile has multiple Basic Auth credentials for the same HTTPS endpoint, use the `placeholder` disambiguator on the profile entry or credential block. The HTTPS placeholder detector matches that value inside decoded `Authorization: Basic <base64(username:placeholder)>` request headers.
func (*BasicAuth) InjectHTTP ¶ added in v0.2.12
InjectHTTP is part of the clawpatrol plugin API.
func (*BasicAuth) SecretSlots ¶ added in v0.2.12
func (*BasicAuth) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type BearerToken ¶
type BearerToken struct {
// IdempotencyKey stamps a deterministic Idempotency-Key header on
// non-GET/HEAD HTTP requests when the agent did not provide one.
IdempotencyKey bool `hcl:"idempotency_key,optional"`
}
BearerToken is part of the clawpatrol plugin API.
func (*BearerToken) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*BearerToken) SecretSlots ¶
func (*BearerToken) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type ClickhouseCredential ¶
type ClickhouseCredential struct {
// User is the upstream ClickHouse user the gateway injects.
User string `hcl:"user,optional"`
// Database limits this credential to ClickHouse requests for that
// database. Empty acts as the catchall.
Database string `hcl:"database,optional"`
}
ClickhouseCredential is part of the clawpatrol plugin API.
Database, when set, is the discriminator the dispatcher uses to pick this credential when several clickhouse_credential blocks bind the same endpoint(s). At request time the gateway reads the agent-declared database off the wire and picks the credential whose `database` matches; an unset `database` field is the catchall (one allowed per (profile, endpoint)).
func (*ClickhouseCredential) ClickhouseAuth ¶
func (c *ClickhouseCredential) ClickhouseAuth(sec runtime.Secret) (string, string)
ClickhouseAuth implements runtime.ClickhouseAuthCredential — the clickhouse_native endpoint runtime calls this once per session to learn what (user, password) to substitute into the Hello packet.
func (*ClickhouseCredential) CredentialDatabase ¶
func (c *ClickhouseCredential) CredentialDatabase() string
CredentialDatabase reports the operator-declared database discriminator for this credential. Retained for HCL emit / dump consumers; dispatch reads it through CredentialDisambiguators.
func (*ClickhouseCredential) CredentialDisambiguators ¶
func (c *ClickhouseCredential) CredentialDisambiguators() map[string]string
CredentialDisambiguators implements config.CredentialDisambiguatorBody. ClickHouse supports both `database` and `user` discriminators — the operator can pick either or both depending on how their cluster is sliced.
func (*ClickhouseCredential) InjectHTTP ¶
func (c *ClickhouseCredential) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
InjectHTTP is part of the clawpatrol plugin API.
func (*ClickhouseCredential) SecretSlots ¶
func (*ClickhouseCredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type CookieToken ¶
type CookieToken struct {
// CookieName is the HTTP cookie name that receives the secret value.
CookieName string `hcl:"cookie_name,optional"`
}
CookieToken is part of the clawpatrol plugin API.
func (*CookieToken) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*CookieToken) SecretSlots ¶
func (*CookieToken) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type DiscordBotToken ¶
type DiscordBotToken struct{}
DiscordBotToken injects Discord bot tokens for REST and Gateway SDK traffic.
func (*DiscordBotToken) EnvVars ¶
func (*DiscordBotToken) EnvVars() []config.EnvVar
EnvVars is part of the clawpatrol plugin API.
func (*DiscordBotToken) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*DiscordBotToken) RewriteWebSocketPayload ¶
func (*DiscordBotToken) RewriteWebSocketPayload(_ context.Context, payload []byte, sec runtime.Secret) ([]byte, bool, error)
RewriteWebSocketPayload is part of the clawpatrol plugin API.
func (*DiscordBotToken) SecretSlots ¶
func (*DiscordBotToken) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type GeminiAPIKey ¶
type GeminiAPIKey struct{}
GeminiAPIKey is part of the clawpatrol plugin API.
func (*GeminiAPIKey) EnvVars ¶
func (*GeminiAPIKey) EnvVars() []config.EnvVar
EnvVars is part of the clawpatrol plugin API.
func (*GeminiAPIKey) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*GeminiAPIKey) SecretSlots ¶
func (*GeminiAPIKey) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type GitHubOAuth ¶
type GitHubOAuth struct{}
GitHubOAuth is part of the clawpatrol plugin API.
func (*GitHubOAuth) EnvVars ¶
func (*GitHubOAuth) EnvVars() []config.EnvVar
EnvVars is part of the clawpatrol plugin API.
func (*GitHubOAuth) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*GitHubOAuth) OAuthFlow ¶
func (g *GitHubOAuth) OAuthFlow() *config.OAuthIntegration
OAuthFlow on GitHubOAuth returns the gh CLI's published OAuth device flow. No client secret — device flow is designed for public clients.
type GoogleGKECredential ¶
type GoogleGKECredential struct{}
GoogleGKECredential is part of the clawpatrol plugin API.
func (*GoogleGKECredential) SecretSlots ¶
func (*GoogleGKECredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type HeaderToken ¶
type HeaderToken struct {
// Header is the HTTP header name to overwrite with the secret value.
Header string `hcl:"header"`
// Prefix is prepended to the secret before injection, for schemes
// such as "Bearer " or "Token ".
Prefix string `hcl:"prefix,optional"`
}
HeaderToken is part of the clawpatrol plugin API.
func (*HeaderToken) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*HeaderToken) SecretSlots ¶
func (*HeaderToken) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type MTLSCredential ¶
type MTLSCredential struct{}
MTLSCredential is part of the clawpatrol plugin API.
func (*MTLSCredential) ConfigureUpstreamTLS ¶
ConfigureUpstreamTLS is part of the clawpatrol plugin API.
func (*MTLSCredential) SecretSlots ¶
func (*MTLSCredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type NotionMCPOAuth ¶
type NotionMCPOAuth struct{}
NotionMCPOAuth is part of the clawpatrol plugin API.
func (*NotionMCPOAuth) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*NotionMCPOAuth) OAuthFlow ¶
func (n *NotionMCPOAuth) OAuthFlow() *config.OAuthIntegration
OAuthFlow returns Notion's MCP OAuth flow. ClientID is intentionally empty — the dashboard registers one at connect time (Flow="notion_mcp" branch in oauth.go) and persists it per-credential.
func (*NotionMCPOAuth) SecretSlots ¶
func (*NotionMCPOAuth) SecretSlots() []config.SecretSlot
SecretSlots intentionally returns nothing: the token is captured through the OAuth flow, never pasted by the operator.
type NotionOAuth ¶
type NotionOAuth struct{}
NotionOAuth is part of the clawpatrol plugin API.
func (*NotionOAuth) InjectHTTP ¶
InjectHTTP is part of the clawpatrol plugin API.
func (*NotionOAuth) SecretSlots ¶
func (*NotionOAuth) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type OpenAICodexOAuth ¶
type OpenAICodexOAuth struct{}
OpenAICodexOAuth is part of the clawpatrol plugin API.
func (*OpenAICodexOAuth) EnvVars ¶
func (*OpenAICodexOAuth) EnvVars() []config.EnvVar
EnvVars intentionally returns nothing.
Codex env-var push-down lives on the openai_codex_https endpoint plugin (config/plugins/endpoints/openai_codex_https.go). Pushing it from the credential would attach the synthetic JWT to every endpoint that binds this credential — including api.openai.com, where it has no business going. Operators wire codex via:
credential "openai_codex_oauth" "codex" {}
endpoint "openai_codex_https" "codex" {
hosts = ["chatgpt.com"]
credential = codex
}
func (*OpenAICodexOAuth) InjectHTTP ¶
func (a *OpenAICodexOAuth) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
InjectHTTP is part of the clawpatrol plugin API.
func (*OpenAICodexOAuth) OAuthFlow ¶
func (a *OpenAICodexOAuth) OAuthFlow() *config.OAuthIntegration
OAuthFlow is part of the clawpatrol plugin API.
type Passthrough ¶ added in v0.2.5
type Passthrough struct{}
Passthrough is a credential that injects nothing. It exists only as a handle the operator declares, binds to endpoints, and lists in a profile's `credentials` — so the existing credential→endpoint→profile claim path works for endpoints that simply don't need auth injection (public APIs, services reached over an already-authenticated tunnel, open-internal endpoints). Write one passthrough credential per group of credential-less endpoints a profile should claim, or share one across several. The gateway forwards matching requests verbatim — no header, signature, or token rewrite — while the profile's rules still apply.
func (*Passthrough) IsPassthrough ¶ added in v0.2.5
func (*Passthrough) IsPassthrough() bool
IsPassthrough satisfies config.NonInjectingCredential so the dashboard can render a "no injection" indicator without importing this package.
type PostgresCredential ¶
type PostgresCredential struct {
// User is the upstream Postgres role the gateway authenticates as.
User string `hcl:"user,optional"`
// Database limits this credential to sessions whose StartupMessage
// declares the same database. Empty acts as the catchall.
Database string `hcl:"database,optional"`
}
PostgresCredential is part of the clawpatrol plugin API.
Database, when set, is the discriminator the dispatcher uses to pick this credential when several postgres_credential blocks bind the same endpoint(s). At request time the gateway reads the agent-declared database off the StartupMessage and picks the credential whose `database` matches; an unset `database` field is the catchall (one allowed per (profile, endpoint)).
func (*PostgresCredential) CredentialDatabase ¶
func (p *PostgresCredential) CredentialDatabase() string
CredentialDatabase reports the operator-declared database discriminator for this credential. Retained for HCL emit / dump consumers; dispatch reads it through CredentialDisambiguators.
func (*PostgresCredential) CredentialDisambiguators ¶
func (p *PostgresCredential) CredentialDisambiguators() map[string]string
CredentialDisambiguators implements config.CredentialDisambiguatorBody. `user` is the primary discriminator (postgres routes via StartupMessage.user); `database` is also supported when multiple credentials bind one endpoint with different default databases.
func (*PostgresCredential) PostgresAuth ¶
func (p *PostgresCredential) PostgresAuth(sec runtime.Secret) (string, string)
PostgresAuth implements runtime.PostgresAuthCredential — the postgres endpoint runtime calls this once per session to learn what (user, password) to use for upstream SCRAM / cleartext.
func (*PostgresCredential) SecretSlots ¶
func (*PostgresCredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type SSHCredential ¶
type SSHCredential struct{}
SSHCredential is part of the clawpatrol plugin API.
func (*SSHCredential) SSHAuth ¶
SSHAuth implements sshproto.AuthCredential. Returns the raw material; the SSH endpoint runtime parses keys via golang.org/x/crypto/ssh and surfaces parse errors with line context.
func (*SSHCredential) SecretSlots ¶
func (*SSHCredential) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
type SlackTokens ¶
type SlackTokens struct{}
SlackTokens is part of the clawpatrol plugin API.
func (*SlackTokens) InjectHTTP ¶
InjectHTTP defaults to the bot token (xoxb-…) for chat.postMessage etc. Slack admin endpoints (auth.test, admin.*, apps.*) prefer the app token; if the operator declared one, use it for those paths. Falls back to bot when only one slot is filled.
func (*SlackTokens) NotifyHITL ¶
func (s *SlackTokens) NotifyHITL(ctx context.Context, req runtime.ApproveRequest, target runtime.HITLTarget) error
NotifyHITL posts a Block Kit approval prompt to the operator's Slack channel. Bot token comes from the credential's `bot` slot (or Bytes for single-slot setups), fetched via the request's SecretStore so dashboard rotations apply per-call.
When target.Interactive is true, the message includes Approve / Deny buttons resolved by the gateway's /api/slack/interactive HTTP handler. Otherwise, only an "Open dashboard" link.
func (*SlackTokens) SecretSlots ¶
func (*SlackTokens) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.
func (*SlackTokens) UpdateHITLMessage ¶
func (s *SlackTokens) UpdateHITLMessage(ctx context.Context, secrets runtime.SecretStore, update runtime.HITLMessageUpdate) error
UpdateHITLMessage edits the originating Slack interactive message after a HITL decision lands. update.MessageRef is the JSON-encoded slackMessageRef the credential plugin emitted when posting; this call resolves the credential, then issues chat.update with the rendered decision text.
func (*SlackTokens) WebhookRoutes ¶
func (*SlackTokens) WebhookRoutes() []runtime.WebhookRoute
WebhookRoutes returns Slack's interactive callback handler. main mounts it at /api/cred/<credName>/interactive — operator pastes that URL into the Slack app's "Interactivity & Shortcuts" config. Public path (no dashboard secret gate); Slack auths via signature header verified per-request.
type TailscaleCredential ¶
type TailscaleCredential struct{}
TailscaleCredential has no operator-facing fields — there is nothing to paste. Per-tailnet selection (control_url, tags) lives on the tunnel block instead.
func (*TailscaleCredential) StateStore ¶
func (*TailscaleCredential) StateStore(name string, store runtime.SecretStore) (ipn.StateStore, error)
StateStore returns an ipn.StateStore that persists tsnet's identity through the gateway secret store. The credential owns persistence; the tunnel hands the result to tsnet.Server.Store and leaves AuthKey empty so tsnet drives the interactive login flow on first boot.
func (*TailscaleCredential) TailscaleAuth ¶
func (*TailscaleCredential) TailscaleAuth() *tailscaleproto.TailscaleAuthIntegration
TailscaleAuth signals to the dashboard that this credential surfaces a tailscale-node Connect flow. BeginURL is filled in by the dashboard handler at render time — the credential body doesn't know its own bare name.
type TelegramBotToken ¶
type TelegramBotToken struct{}
TelegramBotToken is part of the clawpatrol plugin API.
func (*TelegramBotToken) InjectHTTP ¶
func (t *TelegramBotToken) InjectHTTP(_ context.Context, req *http.Request, sec runtime.Secret) error
InjectHTTP is part of the clawpatrol plugin API.
func (*TelegramBotToken) SecretSlots ¶
func (*TelegramBotToken) SecretSlots() []config.SecretSlot
SecretSlots is part of the clawpatrol plugin API.