Integration setup and credentials
Integration setup turns user-supplied connection details into a verified integration that the runtime can use. The system supports local setup for laptops and shared setup for tenant gateway silos, while keeping secret values out of normal project configuration and limiting remote credential access to the tenant identity.
The broader integration model is described in Integration platform. See Integration catalog for the supported service set and Integration verification for health checks.
Setup model
The setup model gives every integration one description of its fields and one common save path. This keeps the onboarding wizard, the integration CLI, and action tools aligned even when they collect values in different ways.
Setup surfaces
The setup flow is available through opensre onboard, opensre setup, opensre integrations setup <service>, and interactive-shell action tools. Each integration surface collects values and passes them to integrations/setup_flow.py; the shared flow then applies the same required-field checks, verification, persistence, and optional follow-up action. The CLI also provides list, show, remove, and verify operations through surfaces/…/integrations.py and integrations/cli.py.
The onboarding picker groups services by their main use. A user can configure one service during onboarding or skip the step and configure it later. Repeated setup uses saved values as defaults, so an operator can change one field without silently clearing the others. References: surfaces/…/onboard_integrations.py• L7-15, surfaces/…/_integration_configurators.py• L64-82, surfaces/…/spec_configurator.py• L40-53, integrations/cli.py• L880-899
Factory setup is a separate first-run path for installers. It requires GitHub device sign-in, then runs the shared LLM setup before the shell starts; opensre onboard remains an LLM-only flow. The LLM step guides provider and model selection, checks the required local or remote access, and saves the local configuration and environment values after the user completes the checks. References: surfaces/…/factory_setup.py• L1-5, surfaces/…/factory_setup.py• L37-113, surfaces/…/flow.py• L271-281, surfaces/…/flow.py• L474-511
Setup specification
An IntegrationSetupSpec defines the fields for one service. A field names its stored credential, its prompt, its environment name when one is needed, and whether it is required or secret. The environment name determines the storage tier; a field does not select a tier itself.
Some services have distinct connection modes. SetupMode limits prompts to the selected mode and clears fields from other modes. This supports choices such as webhook versus socket access without asking the user to reason about unrelated fields. Cross-field rules remain part of the verifier so setup and later health checks use the same definition of a valid connection. References: integrations/setup_flow.py• L65-95, integrations/setup_flow.py• L99-147, integrations/setup_flow.py• L169-225, integrations/setup_flow.py• L227-241
Configuration models
Normalized configuration models turn collected values into strict runtime connection data. They own common defaults and input cleanup, while also rejecting invalid URLs, incomplete authentication choices, and conflicting connection modes before the runtime uses the values. References: integrations/config_models.py• L43-109, integrations/config_models.py• L166-193, integrations/config_models.py• L223-235, integrations/config_models.py• L323-343, integrations/config_models.py• L426-437
Setup stages
apply_setup is the single save contract. It rejects missing required values, runs the service verifier, optionally resolves user-friendly references into runtime values, writes the local configuration, mirrors the result to the webapp vault when available, and then runs any best-effort final action.
The flow does not save a rejected credential. It writes secure values and public configuration before the integration record so a failed environment write cannot leave a store-only connection that other deployment checks cannot see. A final action can report a problem after the verified connection is already saved; it does not undo the save. References: integrations/setup_flow.py• L258-291, integrations/setup_flow.py• L294-318, integrations/setup_flow.py• L321-365
The following diagram shows how all collection surfaces converge on one setup contract.
flowchart LR
A[Onboarding wizard] --> D[Collected values]
B[Factory setup] --> D
C[Integration CLI] --> D
E[Action tools] --> D
D --> F[Required-field checks]
F --> G[Service verifier]
G --> H[Optional value resolution]
H --> I[Secure storage and .env]
I --> J[Integration store]
J --> K[Optional webapp mirror]
K --> L[Optional final action]
Credential storage
Credentials use separate stores for runtime integration records, sensitive values, and non-sensitive settings. This split lets the runtime resolve a complete integration while preventing secrets from being written to the project .env file.
Integration records
The canonical local record is IntegrationStore v2. It groups records by service and supports one or more named instances. Each instance has a name, tags, and a credentials map; older single-record data is migrated into a default instance.
Normal setup writes one service record with a default instance. The store also exposes instance selection by name or tags for services that need more than one endpoint. Store updates replace a service or instance while preserving the v2 shape, and remote hydration replaces the complete set as one operation. References: integrations/store.py• L1-33, integrations/store.py• L249-262, integrations/store.py• L286-338, integrations/store.py• L377-425, integrations/store.py• L428-487
The effective store path follows the current customer scope unless a caller supplies an explicit path. Local updates use a lock and an atomic file replacement, so concurrent setup and hydration do not expose a partial credential set. The service-level read API also provides a flat credential view for older callers while instance-aware callers use the v2 shape. References: integrations/store.py• L53-60, integrations/store.py• L123-168, integrations/store.py• L232-249, integrations/store.py• L268-300
Secret tiers
Sensitive values are identified by their environment name. Tokens, keys, passwords, and connection strings use the secure local secret path; URLs, ids, channels, and other non-sensitive settings use the project .env. The tier boundary is enforced by the writers, so a sensitive key cannot be written as clear text through the public .env writer.
At request time, environment values take precedence over the owner-only local credential file. The local file exists for headless machines that do not have a working OS keychain. The current read path does not open the OS keychain; legacy keychain entries can be imported once or scrubbed during deletion. OPENSRE_DISABLE_KEYRING disables local persistence and leaves the process environment as the only source. References: config/env_file.py• L1-23, config/env_file.py• L161-198, config/…/store.py• L1-15, config/…/store.py• L56-83, config/…/store.py• L96-163, config/…/secrets.py• L7-16
Secret file protection
The fallback credential file is separate from .env and is stored under the host home directory. Its parent directory is owner-only and the file is published with owner-only permissions through an atomic replacement. This protects against a temporary world-readable file during a write and avoids placing secrets on an organization workspace mount.
Saving a blank value clears the stored copy. Deletion also attempts to remove legacy keychain data, and reports failure if either the local copy or the recoverable legacy copy cannot be cleared. References: config/…/local_file.py• L1-13, config/…/local_file.py• L48-67, config/…/local_file.py• L100-118, config/…/local_file.py• L151-183, config/…/store.py• L126-163
Diagnostic redaction
Credential redaction protects local history and diagnostic traces when connection data reaches logs or captured command text. Shared rules replace common cloud keys, vendor tokens, bearer values, passwords, JSON web tokens, and private keys with named markers before those records are exposed. This is a second protection layer; it does not replace secure storage or prevent a new credential format from needing its own rule. References: config/secret_redaction.py• L1-20, config/secret_redaction.py• L22-56
Credential access
Credential access has two roles: local setup and runtime hydration. Local setup persists a connection for later resolution, while gateway startup loads one tenant's complete credential set before the process serves requests.
Account credentials
OpenSRE account access is separate from external integration records. The local account record stores non-secret identity and endpoint metadata, while the account bearer token uses the owner-only secret store under OPENSRE_ACCOUNT_TOKEN; a complete token and app URL can also enable the hosted account LLM route. This token authorizes account-level control-plane access and must not be treated as the tenant's IntegrationStore payload. References: config/account.py• L40-60, config/account.py• L149-198, config/account.py• L201-227, config/…/account.py• L5-25
Request-time resolution
The runtime first uses already-resolved state when a caller supplies it. Otherwise it chooses an authenticated remote source when an auth token is present, then falls back to the webapp vault or local sources. Local resolution combines the integration store with environment-backed integrations, and the resolved result is classified into service configurations for tools.
For a silo using the webapp vault, the merge order is vault, then local store, then environment. This allows an environment value to override a vault value for an operational change while still using the vault as the main tenant source. If the vault is unavailable, the runtime treats that as a fallback condition rather than as an empty tenant configuration. References: infrastructure/…/integration_resolution.py• L207-256, infrastructure/…/integration_resolution.py• L259-291, infrastructure/…/integration_resolution.py• L299-357
Background credential resolution
Background GitHub work resolves its token when the job needs it, instead of relying only on credentials captured when the job was created. An explicitly injected token has highest priority; otherwise the worker uses the effective GitHub integration and then checks the supported environment credential names. If none is available, the worker stops with a setup error before it schedules or runs the repair work. References: integrations/…/credentials.py• L1-25
The same worker requires a positive GitHub account id before it authorizes a durable run. This stable identity links the run to the intended GitHub account and prevents a missing or malformed identity from being treated as a valid credential context. References: integrations/…/credentials.py• L28-33
Gateway hydration routes
Gateway startup loads a bootstrap secret first. The bootstrap secret identifies the provisioned silo and may contain the token for the credentials API; it does not contain the integration set. The gateway then uses one of two routes:
- The integrations secret route reads a tenant-specific IntegrationStore v2 payload from Secrets Manager. This route is used by deployed silos and takes priority when configured.
- The credentials API route fetches the tenant set over HTTPS. It is the staged fallback when no integrations secret ARN is configured and needs a token from the bootstrap secret.
If none of the silo hydration settings exist, the feature is off and the shipped local store remains in use. If only part of the required silo identity exists, startup fails instead of serving an unknown or wrong tenant. References: gateway/…/credential_hydration.py• L1-23, gateway/…/credential_hydration.py• L61-100, gateway/…/credential_hydration.py• L119-155, config/…/tenancy.py• L1-25
The following diagram shows the startup choice between the deployed secret route and the API fallback.
flowchart TD
A[Gateway startup] --> B[Read bootstrap secret]
B --> C{Integrations secret configured?}
C -->|Yes| D[Read tenant IntegrationStore v2]
C -->|No| E{Credentials API configured?}
E -->|Yes| F[Fetch tenant credentials over HTTPS]
E -->|No| G[Keep shipped local store]
D --> H[Validate complete payload]
F --> H
H --> I[Atomically replace local store]
Credentials API contract
The credentials API accepts a bearer credential and an organization id. Its canonical response is a strict version-two store with service records and named instances. The client also adapts the older webapp vault response into that same local shape, so callers do not need two runtime models.
The client requires HTTPS and rejects malformed or extra fields. It validates the full response before replacing the local store. Tagged connections are visible only to their named user or organization; a gateway fetch keeps organization-owned connections and drops a member's personal grant from the shared store. Untagged legacy connections remain server-authorized, while unknown owner kinds fail closed. Errors do not include returned credential values, so a failed fetch is a safe startup error rather than a partial or leaked credential set. References: integrations/…/__init__.py• L1-27, integrations/…/client.py• L20-109, integrations/…/client.py• L112-195, integrations/…/client.py• L198-243
Secrets Manager hydration
The integrations secret is a JSON string owned by the control plane. The gateway parses and validates it as IntegrationStore v2, then atomically materializes its integration list in the local store. Empty, invalid, or wrong-version payloads are rejected without echoing the secret or changing the store.
The configured store path can point to ephemeral silo storage. This keeps tenant vault credentials out of the persistent workspace mount while preserving the same local store contract for the rest of the runtime. References: integrations/secrets_vault.py• L1-11, integrations/secrets_vault.py• L26-51, config/…/tenancy.py• L38-44, tests/…/test_secrets_vault.py• L40-93
Webapp vault access
The webapp vault is the tenant-facing remote store used by a silo and by local setup when a webapp target is configured. The silo prefers its organization-scoped account bearer token; during rollout it can use the shared AGENT_USAGE_SECRET only when the webapp route allows that fallback. The organization is always derived from the silo, so callers cannot select a different tenant.
Vault reads filter the response before it enters the shared store. Organization-owned connections remain available to the silo, while a member's personal grant is dropped; legacy records without owner data remain supported. A successful empty response means the tenant has no exportable integrations. An unavailable response means the runtime should continue with local sources. Local setup and removal mirror changes to the vault on a best-effort basis, and GitHub is not mirrored through this local write path. Credential values sent to the vault are converted to text, including list values that readers later split back into lists. References: integrations/webapp_vault.py• L1-16, integrations/webapp_vault.py• L28-75, integrations/webapp_vault.py• L78-157, integrations/webapp_vault.py• L160-227, integrations/webapp_vault.py• L230-322
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every setup surface on
apply_setup; a store-only path silently breaks deployment checks that read .env or secure storage. - Keep
SetupField.env_varnames aligned with sensitivity classification. A renamed token, key, password, or connection-string variable can move a secret into the wrong tier. - Keep setup verifiers and health-check verifiers on the same cross-field rules. A picker alone cannot protect stored or hand-edited data.
- Keep IntegrationStore v2 validation and the Secrets Manager payload shape aligned. A valid remote payload must still be atomically readable by local instance selectors.
- Keep the bootstrap secret separate from the integrations secret. The bootstrap value authorizes the API fallback; it is not the tenant integration payload.
- Keep webapp vault reads bound to the silo's organization id and the active bearer contract. A caller-provided tenant id or an unintended fallback token would cross the tenant boundary.
- Keep owner tags consistent across the credentials API and webapp vault paths. A personal connection must not enter a store shared by every member of the silo.
- Keep vault
Noneand an empty list distinct. The former means fall back to local sources; the latter means the remote tenant has no exportable records. - Keep list-valued credentials serialized as text for the webapp API and normalized back to the vendor's expected list form.
- Keep background workers on the effective integration and environment fallback path. A worker that uses only a token captured at schedule time can miss current credential changes or run with stale access.
- Keep stable vendor account ids separate from access tokens. Durable work must reject a missing or invalid account identity before it authorizes a run.
- Keep account metadata and the account bearer token separate from tenant integration records. Account login data can select a control-plane route, but it does not hydrate external service credentials.
- Extend the shared redaction rules when a new credential format or diagnostic path can expose secret text. Secure storage does not protect values that are already copied into history or traces.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A required setup field is blank | Setup returns a failure and saves nothing | IntegrationSetupSpec field rules and apply_setup collection |
| A credential fails the service verifier | The connection is not persisted | The same verifier is used for setup and later health checks |
| A sensitive environment name is passed to the public .env writer | The write is refused instead of placing the secret in clear text | Sensitivity checks in config/env_file.py |
| Local secret storage is disabled or cannot write | Setup fails; environment-only operation remains possible | OPENSRE_DISABLE_KEYRING and explicit save errors |
| A background GitHub worker has no usable token | The run fails before repair work starts | Explicit token, effective integration, and environment fallback order |
| GitHub returns no positive account id | Durable authorization is rejected | account_id validates the returned identity type and value |
| A gateway has partial hydration settings | Startup rejects the deployment | Bootstrap ARN, organization, and HTTPS configuration checks |
| The integrations secret or API response has the wrong shape | No replacement occurs and the error does not include secret values | Strict IntegrationStore v2 validation and atomic replacement |
| A remote connection is tagged for another user or organization | The connection is excluded from the shared store | Owner visibility checks fail closed for unknown owner kinds |
| The webapp vault cannot be reached | Runtime uses local sources; local setup still completes | None fallback semantics and best-effort mirror writes |
| A vault request uses the wrong bearer or organization | The remote integration set is unavailable or unauthorized | Account-token preference, controlled fallback, and silo-derived organization id |
| Account metadata is missing or invalid | The account-level route is not created even when an account token exists | Valid account record parsing and HTTP(S) app URL normalization |
| A credential format is not covered by redaction rules | The value can remain in local history or diagnostic output | Shared named redaction rules for credential patterns |
Key files
| File | Why to read it |
|---|---|
| integrations/setup_flow.py | Shared contract that validates, resolves, and persists setup values |
| integrations/config_models.py | Strict normalized connection models used by runtime resolution and verification |
| surfaces/…/factory_setup.py | First-run GitHub sign-in and LLM setup sequence |
| surfaces/…/integrations.py | Public integration management commands |
| integrations/cli.py | Interactive setup, masking, listing, removal, and verification behavior |
| surfaces/…/spec_configurator.py | Common onboarding collection behavior |
| surfaces/…/flow.py | LLM provider setup and local configuration persistence |
| integrations/store.py | Local IntegrationStore v2 record, instance model, and atomic updates |
| config/env_file.py | Boundary between secure secret storage and project .env values |
| config/…/store.py | Request-time secret precedence and deletion behavior |
| config/…/local_file.py | Owner-only fallback file used on headless machines |
| config/account.py | Separate account metadata and bearer-token access used for control-plane routes |
| config/…/account.py | Account token, endpoint, owner-tag, and integration-origin names used by account access |
| config/secret_redaction.py | Shared credential patterns used to protect history and diagnostic traces |
| gateway/…/credential_hydration.py | Gateway startup choice between Secrets Manager and API hydration |
| integrations/…/__init__.py | Public exports for validated credential-store contracts and hydration helpers |
| integrations/…/client.py | HTTPS API contract, owner filtering, and strict payload validation |
| integrations/secrets_vault.py | Secrets Manager payload parsing and local-store hydration |
| integrations/webapp_vault.py | Tenant vault reads, writes, deletes, owner filtering, and fallback behavior |
| infrastructure/…/integration_resolution.py | Runtime source precedence and resolved integration assembly |
| integrations/…/credentials.py | Fresh GitHub token lookup and stable account identity checks for background work |
| config/…/tenancy.py | Gateway hydration and tenant storage settings |