memory-bank/components/public-api-server.md
The Public API Server is a component in Gitpod that provides a versioned, stable, and managed API for programmatic access to Gitpod functionality. It serves as the gateway for external integrations, automation, and third-party tools to interact with Gitpod's core services. The API is designed to be backward compatible, well-documented, and follows modern API design principles.
The primary purposes of the Public API Server component are:
The Public API Server is built as a Go service with several key components:
The component is designed to be the primary entry point for all programmatic interactions with Gitpod, abstracting away internal implementation details and providing a stable interface.
main.go: Entry point for the applicationcmd/root.go: Command-line interface setupcmd/run.go: Main server run commandpkg/server/server.go: Core server implementationpkg/apiv1/: API service implementationspkg/auth/: Authentication and authorizationpkg/oidc/: OpenID Connect implementationpkg/identityprovider/: Identity provider functionalitypkg/proxy/: Request proxying to internal servicespkg/webhooks/: Webhook handlersThe Public API Server provides several services:
The component supports multiple authentication methods:
Authentication is implemented using JSON Web Signatures (JWS) with both RSA-256 and HMAC-SHA256 algorithms.
The Public API Server is configured through a JSON configuration file:
{
"server": {
"port": 3000,
"address": "0.0.0.0"
},
"gitpodServiceURL": "https://gitpod.io/api",
"publicURL": "https://api.gitpod.io",
"sessionServiceAddress": "session-service:3000",
"databaseConfigPath": "/etc/gitpod/db",
"redis": {
"address": "redis:6379"
},
"auth": {
"pki": {
"privateKeyPath": "/etc/gitpod/auth/private-key.pem",
"publicKeyPath": "/etc/gitpod/auth/public-key.pem"
},
"session": {
"cookieName": "gp:session",
"maxAgeMs": 259200000
}
},
"personalAccessTokenSigningKeyPath": "/etc/gitpod/auth/pat-key",
"stripeWebhookSigningSecretPath": "/etc/gitpod/stripe/webhook-secret",
"billingServiceAddress": "billing-service:3000"
}
components/common-go: Common Go utilitiescomponents/public-api: API definitionscomponents/usage-api: Usage API definitionscomponents/gitpod-protocol: Gitpod protocol definitionscomponents/gitpod-db: Database accessThe Public API Server integrates with:
gitpod.v1 services (like OrganizationService) is implemented.The component implements several security measures:
The component exposes various metrics:
The Public API Server is typically used to: