Dev IDP & Mock Authentication
Relevant source files
The following files were used as context for generating this wiki page:
Dev IDP is a lightweight Go-based server located in dev-idp/ that replaces external identity services used in production. It provides a non-interactive authentication experience for local development, allowing developers to sign in without credentials or external account dependencies. The system runs as a pitchfork daemon and utilizes a local SQLite database to persist user, organization, and role data.
Sources: CONTRIBUTING.md:120-125, CLAUDE.md:75-78
System Architecture
The Dev IDP architecture centers on a single Go service that emulates the behavior of enterprise identity providers. It exposes two primary API surfaces on a single port to handle login, Model Context Protocol (MCP) authentication, and organization management.
Component Structure
The diagram shows the interaction between the core services and Dev IDP during the authentication and management lifecycle.
Sources: CONTRIBUTING.md:120-128, CONTRIBUTING.md:180-195
Backend Modes
Dev IDP operates in two modes configured via the GRAM_DEVIDP_BACKEND environment variable. These modes determine whether identity data is generated locally or proxied from an upstream provider.
| Mode | Description | Configuration |
|---|---|---|
local (Default) | Synthesizes identity from git config user.email on first use. Emulates WorkOS API locally. | Zero configuration required. |
workos | Proxies REST calls to the real WorkOS API. Maps git email to a real WorkOS user ID. | Requires WORKOS_API_KEY. |
Sources: CONTRIBUTING.md:130-155
Local Mode Implementation
In local mode, clicking "Login" signs you in automatically as the identity found in your local git configuration. WorkOS-specific calls for Roles & Permissions, Team management, and Invitations are handled by a built-in emulator. You can customize users and organizations by accessing the local management interface at http://localhost:35293.
Sources: CONTRIBUTING.md:133-140
WorkOS Proxy Mode
When configured for workos, Dev IDP validates the GRAM_IDP_CLIENT_SECRET generated during setup and replaces it with the WORKOS_API_KEY before proxying requests upstream. This prevents the primary WorkOS key from being used as a client credential. Login remains non-interactive by performing a lookup of the git committer email through the WorkOS API.
Sources: CONTRIBUTING.md:144-165
API Surfaces and Protocols
Dev IDP hosts two distinct protocol handlers sharing the same SQLite backend.
| Prefix | Purpose | Details |
|---|---|---|
/oauth2-1 | Login & MCP Auth | Implements OAuth 2.1 authorization server with PKCE and optional Dynamic Client Registration. |
/workos | Management | Emulates or proxies the WorkOS REST surface for organizations, roles, and teams. |
Sources: CONTRIBUTING.md:180-190
Authentication Sequence
The sequence demonstrates the non-interactive flow where the authorization code is minted locally and exchanged via the WorkOS-emulated endpoint.
Sources: CONTRIBUTING.md:191-197
Configuration and Management
Dev IDP settings are primarily managed through mise.local.toml.
- Setup: Run
./zeroto generate required secrets likeGRAM_IDP_CLIENT_SECRET. - Synchronization: Run
mise gwsto evolve the SQLite database schema while preserving existing data. - Execution: Start the service as part of the local stack using
mise run start. - Transitioning: If changing backends, restart
pitchforkto ensure the new logic is applied; each backend maintains its owncurrent_usersstate.
Sources: CONTRIBUTING.md:120-122, CONTRIBUTING.md:157-178
OAuth Error Handling
The system includes templates for reporting authentication failures, specifically handling scenarios relevant to the mock environment:
- Expired/Invalid Link: Occurs if a connection link is reused or formatted incorrectly.
- Session Changed: Triggered when the browser session does not match the active sign-in session.
- Organization Blocked: Enforced when RBAC or organization policies prevent a specific connection.
Sources: server/internal/oauthui/authorization_error.html:35-85
Integration with Speakeasy Server
The Speakeasy Go server interacts with Dev IDP using the same code paths as production. It utilizes the authctx package, assuming ActiveOrganisationID is present after successful validation. Mutating handlers enforce permissions via s.authz.Require before performing database work.
Sources: REVIEW.md:55-58, REVIEW.md:75-80
Summary of Dev IDP Significance
Dev IDP serves as the cornerstone of the "zero-config" local development experience for the Speakeasy AI Control Plane. By providing a stable, non-interactive alternative to complex enterprise identity providers, it enables rapid iteration on features involving RBAC, organization scoping, and MCP server authentication.
Sources: CONTRIBUTING.md:120-125, README.md:85-95