Documentation
¶
Overview ¶
Package api wraps HTTP calls to the DBGorilla backend.
v0.1.0 surface is minimal -- only the endpoints needed for login, identity lookup, and MCP API key management. All requests carry a Bearer token from the keychain when one is present; refresh-on-401 happens automatically via the refresh token if available.
Security notes:
- When the client is not in insecure mode, the redirect policy refuses to follow a redirect that would downgrade to a non-https URL. This prevents a malicious server from steering a Bearer-bearing request to plaintext (which Go's stdlib already strips Authorization on for cross-host redirects, but a same-host http downgrade would still expose other custom headers).
- The User-Agent advertises the CLI version so backend abuse-detection and forensic logs can identify the client.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetUserAgentVersion ¶
func SetUserAgentVersion(v string)
SetUserAgentVersion lets cmd inject the build-time version string into the User-Agent header at startup. Safe to call from any goroutine before the first request.
Types ¶
type Client ¶
Client wraps HTTP calls to the DBGorilla backend API.
func NewInsecureClient ¶
NewInsecureClient skips TLS certificate verification. Use only for internal/dev environments with self-signed certs.
func (*Client) Do ¶
Do performs an authenticated HTTP request. Returns the response body bytes, status code, and any error.
type ErrorResponse ¶
type ErrorResponse struct {
Detail string `json:"detail"`
}
ErrorResponse is the standard FastAPI error response.
type UserInfo ¶
type UserInfo struct {
Username string `json:"username"`
Email string `json:"email"`
Tenant string `json:"tenant"`
UserID string `json:"user_id"`
TenantID string `json:"tenant_id"`
IsAdmin bool `json:"is_admin"`
IsSystemTenant bool `json:"is_system_tenant"`
}
UserInfo matches GET /api/v0_1/auth/user on backend release-202603.007. `tenant` is the organization display name; `tenant_id` is the UUID.