Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

feat(server,sdks): accept exchange credential vault payloads (OSEP-0025 T5)

高然c3d92033b436
diff --git a/sdks/sandbox/go/credential_vault_test.go b/sdks/sandbox/go/credential_vault_test.go
index 1301903b2..41d81e566 100644
--- a/sdks/sandbox/go/credential_vault_test.go
+++ b/sdks/sandbox/go/credential_vault_test.go
@@ -373,6 +373,60 @@ func TestCredentialVaultStateDoesNotRetainPlaintextSecretFields(t *testing.T) {
}
}
+func TestExchangeCredentialVaultRoundTrip(t *testing.T) {
+ // Exchange source and typeless auth (OSEP-0025) marshal losslessly, and
+ // the typeless form never emits a forced `"type"` key.
+ body, err := json.Marshal(CredentialVaultCreateRequest{
+ Credentials: []Credential{{
+ Name: "spi-signer",
+ Source: CredentialSource{Type: CredentialSourceExchange, Endpoint: "unix:///run/spi/spi.sock"},
+ }},
+ Bindings: []CredentialBinding{{
+ Name: "internal-api",
+ Match: CredentialMatch{Hosts: []string{"*.internal.example.com"}},
+ Auth: CredentialAuth{Credential: "spi-signer"},
+ }},
+ })
+ require.NoError(t, err)
+
+ var got map[string]any
+ require.NoError(t, json.Unmarshal(body, &got))
+ require.Equal(t, map[string]any{
+ "credentials": []any{map[string]any{
+ "name": "spi-signer",
+ "source": map[string]any{
+ "type": "exchange",
+ "endpoint": "unix:///run/spi/spi.sock",
+ },
+ }},
+ "bindings": []any{map[string]any{
+ "name": "internal-api",
+ "match": map[string]any{"hosts": []any{"*.internal.example.com"}},
+ "auth": map[string]any{"credential": "spi-signer"},
+ }},
+ }, got)
+ encoded := string(body)
+ require.True(t, !strings.Contains(encoded, `"type":""`), "unexpected empty type key in %s", encoded)
+ require.True(t, !strings.Contains(encoded, `"value"`), "unexpected value key in %s", encoded)
+
+ // Static payloads stay byte-compatible: the inline default-type shortcut
+ // keeps working through the flat CredentialSource model.
+ inline, err := json.Marshal(InlineCredentialSource{Value: "dummy-inline-value"})
+ require.NoError(t, err)
+ var inlineGot map[string]any
+ require.NoError(t, json.Unmarshal(inline, &inlineGot))
+ require.Equal(t, map[string]any{"type": "inline", "value": "dummy-inline-value"}, inlineGot)
+
+ // Sanitized typeless metadata round-trips credential-only (no `type`
+ // emitted); static metadata never leaks a credential reference.
+ typeless, err := json.Marshal(CredentialAuthMetadata{Credential: "spi-signer"})
+ require.NoError(t, err)
+ require.Equal(t, `{"credential":"spi-signer"}`, string(typeless))
+ static, err := json.Marshal(CredentialAuthMetadata{Type: "bearer", Credential: "tok"})
+ require.NoError(t, err)
+ require.Equal(t, `{"type":"bearer"}`, string(static))
+}
+
func TestCreateSandboxRequestIncludesCredentialProxy(t *testing.T) {
data, err := json.Marshal(CreateSandboxRequest{
Image: &ImageSpec{URI: "python:3.12"},
diff --git a/sdks/sandbox/go/types.go b/sdks/sandbox/go/types.go
index 06b8bb554..bc614d728 100644
--- a/sdks/sandbox/go/types.go
+++ b/sdks/sandbox/go/types.go
@@ -653,20 +653,30 @@ type CredentialSourceType string
const (
// CredentialSourceInline carries write-only inline credential material.
CredentialSourceInline CredentialSourceType = "inline"
+ // CredentialSourceExchange resolves header sets per request from a
+ // header-resolver endpoint (OSEP-0025); no local material travels.
+ CredentialSourceExchange CredentialSourceType = "exchange"
)
-// InlineCredentialSource contains write-only credential material. Values sent
-// in this model are never returned by Credential Vault state endpoints.
-type InlineCredentialSource struct {
- Type CredentialSourceType `json:"type"`
- Value string `json:"value"`
-}
-
-// MarshalJSON defaults the only supported source type so callers can use the
-// natural zero-value form InlineCredentialSource{Value: secret}.
-func (s InlineCredentialSource) MarshalJSON() ([]byte, error) {
- type inlineCredentialSource InlineCredentialSource
- source := inlineCredentialSource(s)
+// CredentialSource is a sandbox-local Credential Vault credential source.
+// Exactly one kind is set, selected by Type: inline material via Value, or a
+// header-resolver endpoint via Endpoint. The egress rejects sources that set
+// both or neither.
+type CredentialSource struct {
+ Type CredentialSourceType `json:"type,omitempty"`
+ Value string `json:"value,omitempty"`
+ Endpoint string `json:"endpoint,omitempty"`
+}
+
+// InlineCredentialSource is an alias kept for inline-only callers; it is the
+// same flat CredentialSource model.
+type InlineCredentialSource = CredentialSource
+
+// MarshalJSON defaults the source type so callers can use the natural
+// zero-value form CredentialSource{Value: secret} for inline material.
+func (s CredentialSource) MarshalJSON() ([]byte, error) {
+ type credentialSource CredentialSource
+ source := credentialSource(s)
if source.Type == "" {
source.Type = CredentialSourceInline
}
@@ -676,8 +686,8 @@ func (s InlineCredentialSource) MarshalJSON() ([]byte, error) {
// Credential is a sandbox-local Credential Vault credential create/update
// model.
type Credential struct {
- Name string `json:"name"`
- Source InlineCredentialSource `json:"source"`
+ Name string `json:"name"`
+ Source CredentialSource `json:"source"`
}
// CredentialScheme is a request scheme matched by a Credential Vault binding.
@@ -735,9 +745,12 @@ const (
)
// CredentialAuth configures how a binding injects credential material into
-// matching outbound requests.
+// matching outbound requests. The five static kinds set Type; the typeless
+// exchange form (OSEP-0025) omits Type entirely and sets only Credential, a
+// reference to an exchange-sourced credential. The egress rejects shapes
+// mixing the two (for example a typeless auth with Headers or Substitutions).
type CredentialAuth struct {
- Type CredentialAuthType `json:"type"`
+ Type CredentialAuthType `json:"type,omitempty"`
Credential string `json:"credential,omitempty"`
Name string `json:"name,omitempty"`
Headers []CustomHeaderEntry `json:"headers,omitempty"`
@@ -784,7 +797,8 @@ type CredentialVaultPatchRequest struct {
}
// CredentialMetadata is sanitized credential metadata returned by Credential
-// Vault. It intentionally does not include source values.
+// Vault. It intentionally does not include source values; SourceType is
+// `inline` or `exchange`.
type CredentialMetadata struct {
Name string `json:"name"`
SourceType string `json:"sourceType"`
@@ -792,10 +806,25 @@ type CredentialMetadata struct {
}
// CredentialAuthMetadata is sanitized auth metadata returned by Credential
-// Vault. It intentionally does not include credential references or values.
+// Vault. It intentionally does not include credential material. Static kinds
+// carry Type (plus Name for apiKey); the typeless exchange form carries only
+// Credential, a credential reference.
type CredentialAuthMetadata struct {
- Type string `json:"type"`
- Name string `json:"name,omitempty"`
+ Type string `json:"type,omitempty"`
+ Name string `json:"name,omitempty"`
+ Credential string `json:"credential,omitempty"`
+}
+
+// MarshalJSON enforces the sanitized wire shape: static kinds carry type
+// (plus name for apiKey) while only the typeless exchange form carries the
+// credential reference.
+func (m CredentialAuthMetadata) MarshalJSON() ([]byte, error) {
+ type credentialAuthMetadata CredentialAuthMetadata
+ out := credentialAuthMetadata(m)
+ if out.Type != "" {
+ out.Credential = ""
+ }
+ return json.Marshal(out)
}
// CredentialBindingMetadata is sanitized binding metadata returned by
diff --git a/sdks/sandbox/javascript/src/adapters/egressAdapter.ts b/sdks/sandbox/javascript/src/adapters/egressAdapter.ts
index 2875c2fed..d3ff982e4 100644
--- a/sdks/sandbox/javascript/src/adapters/egressAdapter.ts
+++ b/sdks/sandbox/javascript/src/adapters/egressAdapter.ts
@@ -136,13 +136,22 @@ function sanitizeCredentialAuthMetadata(
): CredentialBindingMetadata["auth"] {
if (value == null) return undefined;
const raw = expectObject(value, context);
- const auth: NonNullable<CredentialBindingMetadata["auth"]> = {
- type: expectString(raw.type, `${context}.type`),
- };
- if (raw.name != null) {
- auth.name = expectString(raw.name, `${context}.name`);
+ if (raw.type != null) {
+ const auth: NonNullable<CredentialBindingMetadata["auth"]> = {
+ type: expectString(raw.type, `${context}.type`),
+ };
+ if (raw.name != null) {
+ auth.name = expectString(raw.name, `${context}.name`);
+ }
+ return auth;
+ }
+ // Typeless exchange form: only the credential reference rides the wire.
+ if (raw.credential != null) {
+ return {
+ credential: expectString(raw.credential, `${context}.credential`),
+ };
}
- return auth;
+ throw new Error(`${context}: expected "type" or "credential"`);
}
export function sanitizeCredentialMetadata(value: unknown, context: string): CredentialMetadata {
diff --git a/sdks/sandbox/javascript/src/api/egress.ts b/sdks/sandbox/javascript/src/api/egress.ts
index 36d5bb834..8ce711ea2 100644
--- a/sdks/sandbox/javascript/src/api/egress.ts
+++ b/sdks/sandbox/javascript/src/api/egress.ts
@@ -563,6 +563,7 @@ export interface components {
};
CredentialMetadata: {
name: string;
+ /** @description Credential source kind (`inline` or `exchange`). */
sourceType: string;
revision: number;
};
@@ -574,12 +575,36 @@ export interface components {
};
Credential: {
name: string;
- source: components["schemas"]["InlineCredentialSource"];
+ source: components["schemas"]["CredentialSource"];
};
- InlineCredentialSource: {
+ /**
+ * @description Where the credential material comes from. Exactly one kind, selected
+ * by `type`:
+ *
+ * - `inline`: the secret value travels in this request via `value`.
+ * Inline values are write-only and never appear in reads.
+ * - `exchange`: no local material. Egress resolves header sets per
+ * request from a header-resolver service addressed by `endpoint`.
+ * Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ * Unix domain socket) and `https://host[:port]` (TLS); anything else
+ * is rejected with 400.
+ *
+ * Fields of the other kind must be absent; for example `value` together
+ * with `type: exchange` is rejected with 400.
+ */
+ CredentialSource: {
/** @enum {string} */
- type: "inline";
- value: string;
+ type: "inline" | "exchange";
+ /**
+ * @description Inline secret value. Required when `type` is `inline`; must be
+ * absent otherwise.
+ */
+ value?: string;
+ /**
+ * @description Header-resolver endpoint. Required when `type` is `exchange`; must
+ * be absent otherwise.
+ */
+ endpoint?: string;
};
CredentialBinding: {
name: string;
@@ -616,51 +641,44 @@ export interface components {
*/
paths: string[];
};
- CredentialAuth: components["schemas"]["BearerCredentialAuth"] | components["schemas"]["BasicCredentialAuth"] | components["schemas"]["ApiKeyCredentialAuth"] | components["schemas"]["CustomHeadersCredentialAuth"] | components["schemas"]["PassthroughCredentialAuth"];
- BearerCredentialAuth: {
- /**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
- */
- type: "bearer";
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- BasicCredentialAuth: {
- /**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
- */
- type: "basic";
- /** @description Credential containing pre-encoded base64(username:password). */
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- ApiKeyCredentialAuth: {
+ /**
+ * @description How a binding injects credential material. Exactly one auth kind:
+ *
+ * - `bearer`: `type: bearer` plus `credential`.
+ * - `basic`: `type: basic` plus `credential`.
+ * - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ * - `customHeaders`: `type: customHeaders` plus `headers`.
+ * - `passthrough`: `type: passthrough`, no credential reference.
+ * - typeless exchange: `type` omitted with only `credential` set. The
+ * referenced credential must be exchange-sourced; egress resolves the
+ * header set per request from the credential's endpoint.
+ *
+ * Static kinds must reference inline-sourced credentials, and the
+ * typeless form must reference an exchange-sourced credential and must
+ * not set `name`, `headers`, or `substitutions`. The five static kinds
+ * accept optional `substitutions`. Violations are rejected with 400.
+ */
+ CredentialAuth: {
/**
- * @description discriminator enum property added by openapi-typescript
+ * @description Static auth kind. Omit entirely for the typeless exchange form.
* @enum {string}
*/
- type: "apiKey";
- name: string;
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- CustomHeadersCredentialAuth: {
+ type?: "bearer" | "basic" | "apiKey" | "customHeaders" | "passthrough";
/**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
+ * @description Name of the sandbox-local credential whose value is injected. For
+ * `basic` the referenced credential contains pre-encoded
+ * base64(username:password). Required for `bearer`, `basic`,
+ * `apiKey`, and the typeless exchange form; must be absent otherwise.
*/
- type: "customHeaders";
- headers: components["schemas"]["CustomHeaderEntry"][];
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- PassthroughCredentialAuth: {
+ credential?: string;
+ /** @description Request header name. Required for `apiKey`; must be absent otherwise. */
+ name?: string;
+ /** @description Static header set. Required for `customHeaders`; must be absent otherwise. */
+ headers?: components["schemas"]["CustomHeaderEntry"][];
/**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
+ * @description Optional placeholder replacement set. Accepted for the five static
+ * kinds; must be absent for the typeless exchange form.
*/
- type: "passthrough";
substitutions?: components["schemas"]["CredentialSubstitution"][];
};
CustomHeaderEntry: {
@@ -676,9 +694,11 @@ export interface components {
/** @description Request surfaces where the placeholder may be replaced. Query and path replacements are URL-encoded, JSON string bodies are escaped, x-www-form-urlencoded bodies are form-encoded, compressed bodies are skipped, and multipart bodies are skipped. */
in: ("path" | "query" | "header" | "body")[];
};
+ /** @description Sanitized auth shape — `type` (plus `name` for `apiKey`) for static kinds; `credential` only for the typeless exchange form. */
CredentialAuthMetadata: {
- type: string;
+ type?: string;
name?: string;
+ credential?: string;
};
};
responses: {
diff --git a/sdks/sandbox/javascript/src/api/lifecycle.ts b/sdks/sandbox/javascript/src/api/lifecycle.ts
index 8a992dae4..aba2797b1 100644
--- a/sdks/sandbox/javascript/src/api/lifecycle.ts
+++ b/sdks/sandbox/javascript/src/api/lifecycle.ts
@@ -1978,6 +1978,7 @@ export interface components {
};
CredentialMetadata: {
name: string;
+ /** @description Credential source kind (`inline` or `exchange`). */
sourceType: string;
/**
* @description Revision that last touched this record. Fsb stamps records with
@@ -1993,19 +1994,44 @@ export interface components {
match?: components["schemas"]["CredentialMatch"];
auth?: components["schemas"]["CredentialAuthMetadata"];
};
- /** @description Sanitized auth shape — type always, name for apiKey only. */
+ /** @description Sanitized auth shape — `type` (plus `name` for `apiKey`) for static kinds; `credential` only for the typeless exchange form. */
CredentialAuthMetadata: {
- type: string;
+ type?: string;
name?: string;
+ credential?: string;
};
Credential: {
name: string;
- source: components["schemas"]["InlineCredentialSource"];
+ source: components["schemas"]["CredentialSource"];
};
- InlineCredentialSource: {
+ /**
+ * @description Where the credential material comes from. Exactly one kind, selected
+ * by `type`:
+ *
+ * - `inline`: the secret value travels in this request via `value`.
+ * Inline values are write-only and never appear in reads.
+ * - `exchange`: no local material. Egress resolves header sets per
+ * request from a header-resolver service addressed by `endpoint`.
+ * Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ * Unix domain socket) and `https://host[:port]` (TLS); anything else
+ * is rejected with 400.
+ *
+ * Fields of the other kind must be absent; for example `value` together
+ * with `type: exchange` is rejected with 400.
+ */
+ CredentialSource: {
/** @enum {string} */
- type: "inline";
- value: string;
+ type: "inline" | "exchange";
+ /**
+ * @description Inline secret value. Required when `type` is `inline`; must be
+ * absent otherwise.
+ */
+ value?: string;
+ /**
+ * @description Header-resolver endpoint. Required when `type` is `exchange`; must
+ * be absent otherwise.
+ */
+ endpoint?: string;
};
CredentialBinding: {
name: string;
@@ -2042,53 +2068,45 @@ export interface components {
*/
paths: string[];
};
- CredentialAuth: components["schemas"]["BearerCredentialAuth"] | components["schemas"]["BasicCredentialAuth"] | components["schemas"]["ApiKeyCredentialAuth"] | components["schemas"]["CustomHeadersCredentialAuth"] | components["schemas"]["PassthroughCredentialAuth"];
- BearerCredentialAuth: {
- /**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
- */
- type: "bearer";
- /** @description Credential name whose value becomes the bearer token. */
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- BasicCredentialAuth: {
- /**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
- */
- type: "basic";
- /** @description Credential containing pre-encoded base64(username:password). */
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- ApiKeyCredentialAuth: {
+ /**
+ * @description How a binding injects credential material. Exactly one auth kind:
+ *
+ * - `bearer`: `type: bearer` plus `credential`.
+ * - `basic`: `type: basic` plus `credential`.
+ * - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ * - `customHeaders`: `type: customHeaders` plus `headers`.
+ * - `passthrough`: `type: passthrough`, no credential reference.
+ * - typeless exchange: `type` omitted with only `credential` set. The
+ * referenced credential must be exchange-sourced; egress resolves the
+ * header set per request from the credential's endpoint.
+ *
+ * Static kinds must reference inline-sourced credentials, and the
+ * typeless form must reference an exchange-sourced credential and must
+ * not set `name`, `headers`, or `substitutions`. The five static kinds
+ * accept optional `substitutions`. Violations are rejected with 400.
+ */
+ CredentialAuth: {
/**
- * @description discriminator enum property added by openapi-typescript
+ * @description Static auth kind. Omit entirely for the typeless exchange form.
* @enum {string}
*/
- type: "apiKey";
- name: string;
- /** @description Credential name whose value is the API key. */
- credential: string;
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- CustomHeadersCredentialAuth: {
+ type?: "bearer" | "basic" | "apiKey" | "customHeaders" | "passthrough";
/**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
+ * @description Name of the sandbox-local credential whose value is injected. For
+ * `bearer` the value becomes the bearer token; for `basic` it
+ * contains pre-encoded base64(username:password). Required for
+ * `bearer`, `basic`, `apiKey`, and the typeless exchange form; must
+ * be absent otherwise.
*/
- type: "customHeaders";
- headers: components["schemas"]["CustomHeaderEntry"][];
- substitutions?: components["schemas"]["CredentialSubstitution"][];
- };
- PassthroughCredentialAuth: {
+ credential?: string;
+ /** @description Request header name. Required for `apiKey`; must be absent otherwise. */
+ name?: string;
+ /** @description Static header set. Required for `customHeaders`; must be absent otherwise. */
+ headers?: components["schemas"]["CustomHeaderEntry"][];
/**
- * @description discriminator enum property added by openapi-typescript
- * @enum {string}
+ * @description Optional placeholder replacement set. Accepted for the five static
+ * kinds; must be absent for the typeless exchange form.
*/
- type: "passthrough";
substitutions?: components["schemas"]["CredentialSubstitution"][];
};
CustomHeaderEntry: {
diff --git a/sdks/sandbox/javascript/src/index.ts b/sdks/sandbox/javascript/src/index.ts
index 297a824b7..686664d7e 100644
--- a/sdks/sandbox/javascript/src/index.ts
+++ b/sdks/sandbox/javascript/src/index.ts
@@ -68,6 +68,7 @@ export type {
ActivityProbe,
IdlePolicy,
RenewalPolicy,
+ ExchangeCredentialSource,
InlineCredentialSource,
LifecycleHook,
ListSnapshotsParams,
diff --git a/sdks/sandbox/javascript/src/models/sandboxes.ts b/sdks/sandbox/javascript/src/models/sandboxes.ts
index d770407d8..a4e0628f5 100644
--- a/sdks/sandbox/javascript/src/models/sandboxes.ts
+++ b/sdks/sandbox/javascript/src/models/sandboxes.ts
@@ -102,15 +102,27 @@ export interface InlineCredentialSource extends Record<string, unknown> {
value: string;
}
+export interface ExchangeCredentialSource extends Record<string, unknown> {
+ /**
+ * Marks the credential as exchange-sourced.
+ */
+ type: "exchange";
+ /**
+ * Header-resolver endpoint (`unix:///path` or `https://host[:port]`). The
+ * egress validates the endpoint form; no inline material travels with it.
+ */
+ endpoint: string;
+}
+
export interface Credential extends Record<string, unknown> {
/**
* Sandbox-local credential name.
*/
name: string;
/**
- * Write-only credential source.
+ * Write-only credential source (inline material or exchange endpoint).
*/
- source: InlineCredentialSource;
+ source: InlineCredentialSource | ExchangeCredentialSource;
}
export type CredentialMatchScheme = "https" | "http";
@@ -193,7 +205,15 @@ export type CredentialAuth =
} & CredentialAuthSubstitutions)
| ({
type: "passthrough";
- } & CredentialAuthSubstitutions);
+ } & CredentialAuthSubstitutions)
+ /**
+ * Typeless exchange form: only a credential reference whose source must be
+ * exchange-sourced. The egress resolves the header set per request; static
+ * fields (name/headers/substitutions) are not allowed on this form.
+ */
+ | {
+ credential: string;
+ };
export interface CredentialBinding extends Record<string, unknown> {
/**
@@ -213,18 +233,26 @@ export interface CredentialBinding extends Record<string, unknown> {
export interface CredentialMetadata {
name: string;
/**
- * Source type only; plaintext source material is not returned.
+ * Source type only (`inline` or `exchange`); plaintext source material is
+ * never returned.
*/
sourceType: string;
revision: number;
}
export interface CredentialAuthMetadata {
- type: string;
+ /**
+ * Static auth kind; omitted entirely for the typeless exchange form.
+ */
+ type?: string;
/**
* Public auth parameter name, such as an API key header name.
*/
name?: string;
+ /**
+ * Exchange-sourced credential reference, present only on the typeless form.
+ */
+ credential?: string;
}
export interface CredentialBindingMetadata {
diff --git a/sdks/sandbox/javascript/tests/credential-vault.test.mjs b/sdks/sandbox/javascript/tests/credential-vault.test.mjs
index 46e838650..367448a03 100644
--- a/sdks/sandbox/javascript/tests/credential-vault.test.mjs
+++ b/sdks/sandbox/javascript/tests/credential-vault.test.mjs
@@ -91,7 +91,7 @@ function jsonResponse(body, init = {}) {
});
}
-function createAdapter() {
+function createAdapter(stateOverride) {
const requests = [];
const fetchImpl = async (input, init = {}) => {
const url = new URL(String(input));
@@ -105,29 +105,30 @@ function createAdapter() {
};
requests.push(request);
+ const state = stateOverride ?? stateResponse();
if (request.pathname === "/credential-vault") {
if (request.method === "DELETE") {
return new Response(null, { status: 204 });
}
- return jsonResponse(stateResponse());
+ return jsonResponse(state);
}
if (request.pathname === "/credential-vault/credentials") {
return jsonResponse({
revision: 9,
- credentials: [stateResponse().credentials[0]],
+ credentials: [state.credentials[0]],
});
}
if (request.pathname === "/credential-vault/credentials/api-token%2Fprimary") {
- return jsonResponse(stateResponse().credentials[0]);
+ return jsonResponse(state.credentials[0]);
}
if (request.pathname === "/credential-vault/bindings") {
return jsonResponse({
revision: 9,
- bindings: [stateResponse().bindings[0]],
+ bindings: state.bindings,
});
}
if (request.pathname === "/credential-vault/bindings/api%20binding") {
- return jsonResponse(stateResponse().bindings[0]);
+ return jsonResponse(state.bindings[0]);
}
return jsonResponse({ code: "NOT_FOUND", message: "not found" }, { status: 404 });
};
@@ -250,7 +251,11 @@ test("Credential Vault state omits plaintext secret fields", async () => {
assert.doesNotMatch(credentialMetadata, /extends Record/);
assert.doesNotMatch(credentialMetadata, /\bsource\s*[?:]/);
assert.doesNotMatch(authMetadata, /extends Record/);
- assert.doesNotMatch(authMetadata, /\bcredential\s*[?:]/);
+ // The typeless exchange form exposes only its credential reference; the
+ // plaintext-value carriers (`headers`, and `credential` values) never ride
+ // the sanitized metadata.
+ assert.match(authMetadata, /\btype\?: string/);
+ assert.match(authMetadata, /\bcredential\?: string/);
assert.doesNotMatch(authMetadata, /\bheaders\s*[?:]/);
assert.doesNotMatch(bindingMetadata, /extends Record/);
assert.match(bindingMetadata, /\bauth\??: CredentialAuthMetadata/);
@@ -267,6 +272,71 @@ test("Egress declarations keep Credential Vault optional for custom adapters", a
assert.match(egressStack, /\bcredentialVault\??: CredentialVault/);
});
+test("exchange credentials and typeless auth round-trip losslessly (OSEP-0025)", async () => {
+ const exchangeCredential = {
+ name: "spi-signer",
+ source: { type: "exchange", endpoint: "unix:///run/spi/spi.sock" },
+ };
+ const typelessBinding = {
+ name: "internal-api",
+ match: { hosts: ["*.internal.example.com"] },
+ auth: { credential: "spi-signer" },
+ };
+
+ const exchangeState = {
+ revision: 3,
+ credentials: [{ name: "spi-signer", sourceType: "exchange", revision: 3 }],
+ bindings: [
+ {
+ name: "internal-api",
+ revision: 3,
+ match: { hosts: ["*.internal.example.com"] },
+ // Raw auth carries extra keys; the sanitizer must keep exactly the
+ // credential reference and never produce `type: null`.
+ auth: { credential: "spi-signer", headers: [] },
+ },
+ ],
+ };
+ const { adapter, requests } = createAdapter(exchangeState);
+
+ const created = await adapter.create({
+ credentials: [exchangeCredential],
+ bindings: [typelessBinding],
+ });
+ const state = await adapter.get();
+
+ assert.deepEqual(requests[0].body, {
+ credentials: [exchangeCredential],
+ bindings: [typelessBinding],
+ });
+ assert.deepEqual(created, {
+ revision: 3,
+ credentials: [{ name: "spi-signer", sourceType: "exchange", revision: 3 }],
+ bindings: [
+ {
+ name: "internal-api",
+ revision: 3,
+ match: { hosts: ["*.internal.example.com"] },
+ auth: { credential: "spi-signer" },
+ },
+ ],
+ });
+ assert.deepEqual(state, created);
+ assert.equal(Object.hasOwn(state.bindings[0].auth, "type"), false);
+ assert.equal(JSON.stringify(state).includes("spi.sock"), false);
+});
+
+test("sanitizer rejects auth metadata without type or credential", async () => {
+ const brokenState = {
+ revision: 1,
+ credentials: [],
+ bindings: [{ name: "b", revision: 1, auth: {} }],
+ };
+ const { adapter } = createAdapter(brokenState);
+
+ await assert.rejects(() => adapter.get(), /auth: expected "type" or "credential"/);
+});
+
async function readDistDeclarations() {
const distDir = new URL("../dist/", import.meta.url);
const entries = await readdir(distDir);
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/__init__.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/__init__.py
index 94a276832..88cde9d36 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/__init__.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/__init__.py
@@ -16,14 +16,10 @@
"""Contains all the data models used in inputs/outputs"""
-from .api_key_credential_auth import ApiKeyCredentialAuth
-from .api_key_credential_auth_type import ApiKeyCredentialAuthType
-from .basic_credential_auth import BasicCredentialAuth
-from .basic_credential_auth_type import BasicCredentialAuthType
-from .bearer_credential_auth import BearerCredentialAuth
-from .bearer_credential_auth_type import BearerCredentialAuthType
from .credential import Credential
+from .credential_auth import CredentialAuth
from .credential_auth_metadata import CredentialAuthMetadata
+from .credential_auth_type import CredentialAuthType
from .credential_binding import CredentialBinding
from .credential_binding_list_response import CredentialBindingListResponse
from .credential_binding_metadata import CredentialBindingMetadata
@@ -33,33 +29,25 @@ from .credential_match import CredentialMatch
from .credential_match_schemes_item import CredentialMatchSchemesItem
from .credential_metadata import CredentialMetadata
from .credential_mutation_set import CredentialMutationSet
+from .credential_source import CredentialSource
+from .credential_source_type import CredentialSourceType
from .credential_substitution import CredentialSubstitution
from .credential_substitution_in_item import CredentialSubstitutionInItem
from .credential_vault_create_request import CredentialVaultCreateRequest
from .credential_vault_mutation_request import CredentialVaultMutationRequest
from .credential_vault_state import CredentialVaultState
from .custom_header_entry import CustomHeaderEntry
-from .custom_headers_credential_auth import CustomHeadersCredentialAuth
-from .custom_headers_credential_auth_type import CustomHeadersCredentialAuthType
-from .inline_credential_source import InlineCredentialSource
-from .inline_credential_source_type import InlineCredentialSourceType
from .network_policy import NetworkPolicy
from .network_policy_default_action import NetworkPolicyDefaultAction
from .network_rule import NetworkRule
from .network_rule_action import NetworkRuleAction
-from .passthrough_credential_auth import PassthroughCredentialAuth
-from .passthrough_credential_auth_type import PassthroughCredentialAuthType
from .policy_status_response import PolicyStatusResponse
__all__ = (
- "ApiKeyCredentialAuth",
- "ApiKeyCredentialAuthType",
- "BasicCredentialAuth",
- "BasicCredentialAuthType",
- "BearerCredentialAuth",
- "BearerCredentialAuthType",
"Credential",
+ "CredentialAuth",
"CredentialAuthMetadata",
+ "CredentialAuthType",
"CredentialBinding",
"CredentialBindingListResponse",
"CredentialBindingMetadata",
@@ -69,21 +57,17 @@ __all__ = (
"CredentialMatchSchemesItem",
"CredentialMetadata",
"CredentialMutationSet",
+ "CredentialSource",
+ "CredentialSourceType",
"CredentialSubstitution",
"CredentialSubstitutionInItem",
"CredentialVaultCreateRequest",
"CredentialVaultMutationRequest",
"CredentialVaultState",
"CustomHeaderEntry",
- "CustomHeadersCredentialAuth",
- "CustomHeadersCredentialAuthType",
- "InlineCredentialSource",
- "InlineCredentialSourceType",
"NetworkPolicy",
"NetworkPolicyDefaultAction",
"NetworkRule",
"NetworkRuleAction",
- "PassthroughCredentialAuth",
- "PassthroughCredentialAuthType",
"PolicyStatusResponse",
)
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth.py
deleted file mode 100644
index 106e243a5..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.api_key_credential_auth_type import ApiKeyCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="ApiKeyCredentialAuth")
-
-
-@_attrs_define
-class ApiKeyCredentialAuth:
- """
- Attributes:
- type_ (ApiKeyCredentialAuthType):
- name (str):
- credential (str):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: ApiKeyCredentialAuthType
- name: str
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- name = self.name
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "name": name,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = ApiKeyCredentialAuthType(d.pop("type"))
-
- name = d.pop("name")
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- api_key_credential_auth = cls(
- type_=type_,
- name=name,
- credential=credential,
- substitutions=substitutions,
- )
-
- return api_key_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth_type.py
deleted file mode 100644
index 4ec226962..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/api_key_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class ApiKeyCredentialAuthType(str, Enum):
- APIKEY = "apiKey"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth.py
deleted file mode 100644
index b5b2931ec..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.basic_credential_auth_type import BasicCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="BasicCredentialAuth")
-
-
-@_attrs_define
-class BasicCredentialAuth:
- """
- Attributes:
- type_ (BasicCredentialAuthType):
- credential (str): Credential containing pre-encoded base64(username:password).
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: BasicCredentialAuthType
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = BasicCredentialAuthType(d.pop("type"))
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- basic_credential_auth = cls(
- type_=type_,
- credential=credential,
- substitutions=substitutions,
- )
-
- return basic_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth_type.py
deleted file mode 100644
index 9802eb3c2..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/basic_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class BasicCredentialAuthType(str, Enum):
- BASIC = "basic"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth.py
deleted file mode 100644
index e2c1440da..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.bearer_credential_auth_type import BearerCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="BearerCredentialAuth")
-
-
-@_attrs_define
-class BearerCredentialAuth:
- """
- Attributes:
- type_ (BearerCredentialAuthType):
- credential (str):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: BearerCredentialAuthType
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = BearerCredentialAuthType(d.pop("type"))
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- bearer_credential_auth = cls(
- type_=type_,
- credential=credential,
- substitutions=substitutions,
- )
-
- return bearer_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth_type.py
deleted file mode 100644
index 121821a80..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/bearer_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class BearerCredentialAuthType(str, Enum):
- BEARER = "bearer"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential.py
index f54bb0d13..15d5f350b 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential.py
@@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
if TYPE_CHECKING:
- from ..models.inline_credential_source import InlineCredentialSource
+ from ..models.credential_source import CredentialSource
T = TypeVar("T", bound="Credential")
@@ -33,11 +33,23 @@ class Credential:
"""
Attributes:
name (str):
- source (InlineCredentialSource):
+ source (CredentialSource): Where the credential material comes from. Exactly one kind, selected
+ by `type`:
+
+ - `inline`: the secret value travels in this request via `value`.
+ Inline values are write-only and never appear in reads.
+ - `exchange`: no local material. Egress resolves header sets per
+ request from a header-resolver service addressed by `endpoint`.
+ Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ Unix domain socket) and `https://host[:port]` (TLS); anything else
+ is rejected with 400.
+
+ Fields of the other kind must be absent; for example `value` together
+ with `type: exchange` is rejected with 400.
"""
name: str
- source: InlineCredentialSource
+ source: CredentialSource
def to_dict(self) -> dict[str, Any]:
name = self.name
@@ -57,12 +69,12 @@ class Credential:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.inline_credential_source import InlineCredentialSource
+ from ..models.credential_source import CredentialSource
d = dict(src_dict)
name = d.pop("name")
- source = InlineCredentialSource.from_dict(d.pop("source"))
+ source = CredentialSource.from_dict(d.pop("source"))
credential = cls(
name=name,
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth.py
new file mode 100644
index 000000000..d4a417e12
--- /dev/null
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth.py
@@ -0,0 +1,155 @@
+#
+# Copyright 2026 The OpenSandbox Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import annotations
+
+from collections.abc import Mapping
+from typing import TYPE_CHECKING, Any, TypeVar
+
+from attrs import define as _attrs_define
+
+from ..models.credential_auth_type import CredentialAuthType
+from ..types import UNSET, Unset
+
+if TYPE_CHECKING:
+ from ..models.credential_substitution import CredentialSubstitution
+ from ..models.custom_header_entry import CustomHeaderEntry
+
+
+T = TypeVar("T", bound="CredentialAuth")
+
+
+@_attrs_define
+class CredentialAuth:
+ """How a binding injects credential material. Exactly one auth kind:
+
+ - `bearer`: `type: bearer` plus `credential`.
+ - `basic`: `type: basic` plus `credential`.
+ - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ - `customHeaders`: `type: customHeaders` plus `headers`.
+ - `passthrough`: `type: passthrough`, no credential reference.
+ - typeless exchange: `type` omitted with only `credential` set. The
+ referenced credential must be exchange-sourced; egress resolves the
+ header set per request from the credential's endpoint.
+
+ Static kinds must reference inline-sourced credentials, and the
+ typeless form must reference an exchange-sourced credential and must
+ not set `name`, `headers`, or `substitutions`. The five static kinds
+ accept optional `substitutions`. Violations are rejected with 400.
+
+ Attributes:
+ type_ (CredentialAuthType | Unset): Static auth kind. Omit entirely for the typeless exchange form.
+ credential (str | Unset): Name of the sandbox-local credential whose value is injected. For
+ `basic` the referenced credential contains pre-encoded
+ base64(username:password). Required for `bearer`, `basic`,
+ `apiKey`, and the typeless exchange form; must be absent otherwise.
+ name (str | Unset): Request header name. Required for `apiKey`; must be absent otherwise.
+ headers (list[CustomHeaderEntry] | Unset): Static header set. Required for `customHeaders`; must be absent
+ otherwise.
+ substitutions (list[CredentialSubstitution] | Unset): Optional placeholder replacement set. Accepted for the
+ five static
+ kinds; must be absent for the typeless exchange form.
+ """
+
+ type_: CredentialAuthType | Unset = UNSET
+ credential: str | Unset = UNSET
+ name: str | Unset = UNSET
+ headers: list[CustomHeaderEntry] | Unset = UNSET
+ substitutions: list[CredentialSubstitution] | Unset = UNSET
+
+ def to_dict(self) -> dict[str, Any]:
+ type_: str | Unset = UNSET
+ if not isinstance(self.type_, Unset):
+ type_ = self.type_.value
+
+ credential = self.credential
+
+ name = self.name
+
+ headers: list[dict[str, Any]] | Unset = UNSET
+ if not isinstance(self.headers, Unset):
+ headers = []
+ for headers_item_data in self.headers:
+ headers_item = headers_item_data.to_dict()
+ headers.append(headers_item)
+
+ substitutions: list[dict[str, Any]] | Unset = UNSET
+ if not isinstance(self.substitutions, Unset):
+ substitutions = []
+ for substitutions_item_data in self.substitutions:
+ substitutions_item = substitutions_item_data.to_dict()
+ substitutions.append(substitutions_item)
+
+ field_dict: dict[str, Any] = {}
+
+ field_dict.update({})
+ if type_ is not UNSET:
+ field_dict["type"] = type_
+ if credential is not UNSET:
+ field_dict["credential"] = credential
+ if name is not UNSET:
+ field_dict["name"] = name
+ if headers is not UNSET:
+ field_dict["headers"] = headers
+ if substitutions is not UNSET:
+ field_dict["substitutions"] = substitutions
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.credential_substitution import CredentialSubstitution
+ from ..models.custom_header_entry import CustomHeaderEntry
+
+ d = dict(src_dict)
+ _type_ = d.pop("type", UNSET)
+ type_: CredentialAuthType | Unset
+ if isinstance(_type_, Unset):
+ type_ = UNSET
+ else:
+ type_ = CredentialAuthType(_type_)
+
+ credential = d.pop("credential", UNSET)
+
+ name = d.pop("name", UNSET)
+
+ _headers = d.pop("headers", UNSET)
+ headers: list[CustomHeaderEntry] | Unset = UNSET
+ if _headers is not UNSET:
+ headers = []
+ for headers_item_data in _headers:
+ headers_item = CustomHeaderEntry.from_dict(headers_item_data)
+
+ headers.append(headers_item)
+
+ _substitutions = d.pop("substitutions", UNSET)
+ substitutions: list[CredentialSubstitution] | Unset = UNSET
+ if _substitutions is not UNSET:
+ substitutions = []
+ for substitutions_item_data in _substitutions:
+ substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
+
+ substitutions.append(substitutions_item)
+
+ credential_auth = cls(
+ type_=type_,
+ credential=credential,
+ name=name,
+ headers=headers,
+ substitutions=substitutions,
+ )
+
+ return credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_metadata.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_metadata.py
index 0958e3a07..f71e7f52a 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_metadata.py
@@ -28,42 +28,51 @@ T = TypeVar("T", bound="CredentialAuthMetadata")
@_attrs_define
class CredentialAuthMetadata:
- """
- Attributes:
- type_ (str):
- name (str | Unset):
+ """Sanitized auth shape — `type` (plus `name` for `apiKey`) for static kinds; `credential` only for the typeless
+ exchange form.
+
+ Attributes:
+ type_ (str | Unset):
+ name (str | Unset):
+ credential (str | Unset):
"""
- type_: str
+ type_: str | Unset = UNSET
name: str | Unset = UNSET
+ credential: str | Unset = UNSET
def to_dict(self) -> dict[str, Any]:
type_ = self.type_
name = self.name
+ credential = self.credential
+
field_dict: dict[str, Any] = {}
- field_dict.update(
- {
- "type": type_,
- }
- )
+ field_dict.update({})
+ if type_ is not UNSET:
+ field_dict["type"] = type_
if name is not UNSET:
field_dict["name"] = name
+ if credential is not UNSET:
+ field_dict["credential"] = credential
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
- type_ = d.pop("type")
+ type_ = d.pop("type", UNSET)
name = d.pop("name", UNSET)
+ credential = d.pop("credential", UNSET)
+
credential_auth_metadata = cls(
type_=type_,
name=name,
+ credential=credential,
)
return credential_auth_metadata
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_type.py
similarity index 84%
rename from sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth_type.py
rename to sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_type.py
index f0faf5c51..7d5efea79 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth_type.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_auth_type.py
@@ -17,8 +17,12 @@
from enum import Enum
-class CustomHeadersCredentialAuthType(str, Enum):
+class CredentialAuthType(str, Enum):
+ APIKEY = "apiKey"
+ BASIC = "basic"
+ BEARER = "bearer"
CUSTOMHEADERS = "customHeaders"
+ PASSTHROUGH = "passthrough"
def __str__(self) -> str:
return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding.py
index 3e3ef2199..ce0084667 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding.py
@@ -22,12 +22,8 @@ from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
if TYPE_CHECKING:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
+ from ..models.credential_auth import CredentialAuth
from ..models.credential_match import CredentialMatch
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
- from ..models.passthrough_credential_auth import PassthroughCredentialAuth
T = TypeVar("T", bound="CredentialBinding")
@@ -39,41 +35,33 @@ class CredentialBinding:
Attributes:
name (str):
match (CredentialMatch):
- auth (ApiKeyCredentialAuth | BasicCredentialAuth | BearerCredentialAuth | CustomHeadersCredentialAuth |
- PassthroughCredentialAuth):
+ auth (CredentialAuth): How a binding injects credential material. Exactly one auth kind:
+
+ - `bearer`: `type: bearer` plus `credential`.
+ - `basic`: `type: basic` plus `credential`.
+ - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ - `customHeaders`: `type: customHeaders` plus `headers`.
+ - `passthrough`: `type: passthrough`, no credential reference.
+ - typeless exchange: `type` omitted with only `credential` set. The
+ referenced credential must be exchange-sourced; egress resolves the
+ header set per request from the credential's endpoint.
+
+ Static kinds must reference inline-sourced credentials, and the
+ typeless form must reference an exchange-sourced credential and must
+ not set `name`, `headers`, or `substitutions`. The five static kinds
+ accept optional `substitutions`. Violations are rejected with 400.
"""
name: str
match: CredentialMatch
- auth: (
- ApiKeyCredentialAuth
- | BasicCredentialAuth
- | BearerCredentialAuth
- | CustomHeadersCredentialAuth
- | PassthroughCredentialAuth
- )
+ auth: CredentialAuth
def to_dict(self) -> dict[str, Any]:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
-
name = self.name
match = self.match.to_dict()
- auth: dict[str, Any]
- if isinstance(self.auth, BearerCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, BasicCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, ApiKeyCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, CustomHeadersCredentialAuth):
- auth = self.auth.to_dict()
- else:
- auth = self.auth.to_dict()
+ auth = self.auth.to_dict()
field_dict: dict[str, Any] = {}
@@ -89,66 +77,15 @@ class CredentialBinding:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
+ from ..models.credential_auth import CredentialAuth
from ..models.credential_match import CredentialMatch
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
- from ..models.passthrough_credential_auth import PassthroughCredentialAuth
d = dict(src_dict)
name = d.pop("name")
match = CredentialMatch.from_dict(d.pop("match"))
- def _parse_auth(
- data: object,
- ) -> (
- ApiKeyCredentialAuth
- | BasicCredentialAuth
- | BearerCredentialAuth
- | CustomHeadersCredentialAuth
- | PassthroughCredentialAuth
- ):
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_0 = BearerCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_0
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_1 = BasicCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_1
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_2 = ApiKeyCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_2
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_3 = CustomHeadersCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_3
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_4 = PassthroughCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_4
-
- auth = _parse_auth(d.pop("auth"))
+ auth = CredentialAuth.from_dict(d.pop("auth"))
credential_binding = cls(
name=name,
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding_metadata.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding_metadata.py
index 4f4aaadee..0a1bb4aae 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_binding_metadata.py
@@ -38,7 +38,8 @@ class CredentialBindingMetadata:
name (str):
revision (int):
match (CredentialMatch | Unset):
- auth (CredentialAuthMetadata | Unset):
+ auth (CredentialAuthMetadata | Unset): Sanitized auth shape — `type` (plus `name` for `apiKey`) for static
+ kinds; `credential` only for the typeless exchange form.
"""
name: str
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_metadata.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_metadata.py
index 2b993c482..e905f349d 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_metadata.py
@@ -29,7 +29,7 @@ class CredentialMetadata:
"""
Attributes:
name (str):
- source_type (str):
+ source_type (str): Credential source kind (`inline` or `exchange`).
revision (int):
"""
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source.py
new file mode 100644
index 000000000..e4b5edc0a
--- /dev/null
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source.py
@@ -0,0 +1,109 @@
+#
+# Copyright 2026 The OpenSandbox Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import annotations
+
+from collections.abc import Mapping
+from typing import Any, TypeVar
+
+from attrs import define as _attrs_define
+
+from ..models.credential_source_type import CredentialSourceType
+from ..types import UNSET, Unset
+
+T = TypeVar("T", bound="CredentialSource")
+
+
+@_attrs_define
+class CredentialSource:
+ """Where the credential material comes from. Exactly one kind, selected
+ by `type`:
+
+ - `inline`: the secret value travels in this request via `value`.
+ Inline values are write-only and never appear in reads.
+ - `exchange`: no local material. Egress resolves header sets per
+ request from a header-resolver service addressed by `endpoint`.
+ Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ Unix domain socket) and `https://host[:port]` (TLS); anything else
+ is rejected with 400.
+
+ Fields of the other kind must be absent; for example `value` together
+ with `type: exchange` is rejected with 400.
+
+ Attributes:
+ type_ (CredentialSourceType):
+ value (str | Unset): Inline secret value. Required when `type` is `inline`; must be
+ absent otherwise.
+ endpoint (str | Unset): Header-resolver endpoint. Required when `type` is `exchange`; must
+ be absent otherwise.
+ """
+
+ type_: CredentialSourceType
+ value: str | Unset = UNSET
+ endpoint: str | Unset = UNSET
+
+ def to_dict(self) -> dict[str, Any]:
+ type_ = self.type_.value
+
+ value = self.value
+
+ endpoint = self.endpoint
+
+ field_dict: dict[str, Any] = {}
+
+ field_dict.update(
+ {
+ "type": type_,
+ }
+ )
+ if value is not UNSET:
+ field_dict["value"] = value
+ if endpoint is not UNSET:
+ field_dict["endpoint"] = endpoint
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ type_ = CredentialSourceType(d.pop("type"))
+
+ value = d.pop("value", UNSET)
+
+ endpoint = d.pop("endpoint", UNSET)
+
+ credential_source = cls(
+ type_=type_,
+ value=value,
+ endpoint=endpoint,
+ )
+
+ return credential_source
+
+
+# Redacted repr: the credential value is write-only and must never
+# surface in logs, exception messages, or debug output. attrs would
+# overwrite a class-level __repr__, so the override is applied on the
+# class object after definition.
+def _redacted_repr(self: CredentialSource) -> str:
+ value = "***" if self.value is not UNSET else "UNSET"
+ return (
+ f"{type(self).__name__}(type_={self.type_!r}, value={value},"
+ f" endpoint={self.endpoint!r})"
+ )
+
+
+CredentialSource.__repr__ = _redacted_repr # type: ignore[method-assign]
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source_type.py
similarity index 91%
rename from sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source_type.py
rename to sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source_type.py
index a15e435ff..3c2ae43ad 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source_type.py
+++ b/sdks/sandbox/python/src/opensandbox/api/egress/models/credential_source_type.py
@@ -17,7 +17,8 @@
from enum import Enum
-class InlineCredentialSourceType(str, Enum):
+class CredentialSourceType(str, Enum):
+ EXCHANGE = "exchange"
INLINE = "inline"
def __str__(self) -> str:
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth.py
deleted file mode 100644
index 7b95dc59a..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.custom_headers_credential_auth_type import CustomHeadersCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
- from ..models.custom_header_entry import CustomHeaderEntry
-
-
-T = TypeVar("T", bound="CustomHeadersCredentialAuth")
-
-
-@_attrs_define
-class CustomHeadersCredentialAuth:
- """
- Attributes:
- type_ (CustomHeadersCredentialAuthType):
- headers (list[CustomHeaderEntry]):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: CustomHeadersCredentialAuthType
- headers: list[CustomHeaderEntry]
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- headers = []
- for headers_item_data in self.headers:
- headers_item = headers_item_data.to_dict()
- headers.append(headers_item)
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "headers": headers,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
- from ..models.custom_header_entry import CustomHeaderEntry
-
- d = dict(src_dict)
- type_ = CustomHeadersCredentialAuthType(d.pop("type"))
-
- headers = []
- _headers = d.pop("headers")
- for headers_item_data in _headers:
- headers_item = CustomHeaderEntry.from_dict(headers_item_data)
-
- headers.append(headers_item)
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- custom_headers_credential_auth = cls(
- type_=type_,
- headers=headers,
- substitutions=substitutions,
- )
-
- return custom_headers_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source.py
deleted file mode 100644
index 2bf7cc67f..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/inline_credential_source.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.inline_credential_source_type import InlineCredentialSourceType
-
-T = TypeVar("T", bound="InlineCredentialSource")
-
-
-@_attrs_define
-class InlineCredentialSource:
- """
- Attributes:
- type_ (InlineCredentialSourceType):
- value (str):
- """
-
- type_: InlineCredentialSourceType
- value: str
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- value = self.value
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "value": value,
- }
- )
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- d = dict(src_dict)
- type_ = InlineCredentialSourceType(d.pop("type"))
-
- value = d.pop("value")
-
- inline_credential_source = cls(
- type_=type_,
- value=value,
- )
-
- return inline_credential_source
-
-
-# Redacted repr: the credential value is write-only and must never
-# surface in logs, exception messages, or debug output. attrs would
-# overwrite a class-level __repr__, so the override is applied on the
-# class object after definition.
-def _redacted_repr(self: InlineCredentialSource) -> str:
- return f"{type(self).__name__}(value=***)"
-
-
-InlineCredentialSource.__repr__ = _redacted_repr # type: ignore[method-assign]
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth.py
deleted file mode 100644
index 586b08146..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.passthrough_credential_auth_type import PassthroughCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="PassthroughCredentialAuth")
-
-
-@_attrs_define
-class PassthroughCredentialAuth:
- """
- Attributes:
- type_ (PassthroughCredentialAuthType):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: PassthroughCredentialAuthType
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = PassthroughCredentialAuthType(d.pop("type"))
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- passthrough_credential_auth = cls(
- type_=type_,
- substitutions=substitutions,
- )
-
- return passthrough_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth_type.py
deleted file mode 100644
index 1ce563103..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/passthrough_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class PassthroughCredentialAuthType(str, Enum):
- PASSTHROUGH = "passthrough"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/api/sandboxes/get_sandbox_network_policy.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/api/sandboxes/get_sandbox_network_policy.py
index a0db11536..60a144b1d 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/api/sandboxes/get_sandbox_network_policy.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/api/sandboxes/get_sandbox_network_policy.py
@@ -73,7 +73,10 @@ def _parse_response(
return response_404
if response.status_code == 409:
- response_409 = ErrorResponse.from_dict(response.json())
+ try:
+ response_409 = ErrorResponse.from_dict(response.json())
+ except (ValueError, TypeError, KeyError):
+ return None
return response_409
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/__init__.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/__init__.py
index 9e02cc4b2..758e7fdd5 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/__init__.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/__init__.py
@@ -20,12 +20,6 @@ from .activity_probe import ActivityProbe
from .allocation_summary import AllocationSummary
from .allocation_summary_mode import AllocationSummaryMode
from .allocation_summary_state import AllocationSummaryState
-from .api_key_credential_auth import ApiKeyCredentialAuth
-from .api_key_credential_auth_type import ApiKeyCredentialAuthType
-from .basic_credential_auth import BasicCredentialAuth
-from .basic_credential_auth_type import BasicCredentialAuthType
-from .bearer_credential_auth import BearerCredentialAuth
-from .bearer_credential_auth_type import BearerCredentialAuthType
from .create_fsb_template_request import CreateFsbTemplateRequest
from .create_fsb_template_request_env import CreateFsbTemplateRequestEnv
from .create_fsb_template_request_format import CreateFsbTemplateRequestFormat
@@ -39,7 +33,9 @@ from .create_sandbox_response_extensions import CreateSandboxResponseExtensions
from .create_sandbox_response_metadata import CreateSandboxResponseMetadata
from .create_snapshot_request import CreateSnapshotRequest
from .credential import Credential
+from .credential_auth import CredentialAuth
from .credential_auth_metadata import CredentialAuthMetadata
+from .credential_auth_type import CredentialAuthType
from .credential_binding import CredentialBinding
from .credential_binding_list_response import CredentialBindingListResponse
from .credential_binding_metadata import CredentialBindingMetadata
@@ -50,14 +46,14 @@ from .credential_match_schemes_item import CredentialMatchSchemesItem
from .credential_metadata import CredentialMetadata
from .credential_mutation_set import CredentialMutationSet
from .credential_proxy_config import CredentialProxyConfig
+from .credential_source import CredentialSource
+from .credential_source_type import CredentialSourceType
from .credential_substitution import CredentialSubstitution
from .credential_substitution_in_item import CredentialSubstitutionInItem
from .credential_vault_create_request import CredentialVaultCreateRequest
from .credential_vault_mutation_request import CredentialVaultMutationRequest
from .credential_vault_state import CredentialVaultState
from .custom_header_entry import CustomHeaderEntry
-from .custom_headers_credential_auth import CustomHeadersCredentialAuth
-from .custom_headers_credential_auth_type import CustomHeadersCredentialAuthType
from .endpoint import Endpoint
from .endpoint_headers import EndpointHeaders
from .error_response import ErrorResponse
@@ -73,8 +69,6 @@ from .idle_policy import IdlePolicy
from .idle_policy_on_idle import IdlePolicyOnIdle
from .image_spec import ImageSpec
from .image_spec_auth import ImageSpecAuth
-from .inline_credential_source import InlineCredentialSource
-from .inline_credential_source_type import InlineCredentialSourceType
from .lifecycle_hook import LifecycleHook
from .list_fsb_templates_response import ListFsbTemplatesResponse
from .list_sandboxes_response import ListSandboxesResponse
@@ -88,8 +82,6 @@ from .network_rule_action import NetworkRuleAction
from .ossfs import OSSFS
from .ossfs_version import OSSFSVersion
from .pagination_info import PaginationInfo
-from .passthrough_credential_auth import PassthroughCredentialAuth
-from .passthrough_credential_auth_type import PassthroughCredentialAuthType
from .patch_sandbox_metadata_request import PatchSandboxMetadataRequest
from .periodic_lifecycle_hook import PeriodicLifecycleHook
from .platform_spec import PlatformSpec
@@ -115,12 +107,6 @@ __all__ = (
"AllocationSummary",
"AllocationSummaryMode",
"AllocationSummaryState",
- "ApiKeyCredentialAuth",
- "ApiKeyCredentialAuthType",
- "BasicCredentialAuth",
- "BasicCredentialAuthType",
- "BearerCredentialAuth",
- "BearerCredentialAuthType",
"CreateFsbTemplateRequest",
"CreateFsbTemplateRequestEnv",
"CreateFsbTemplateRequestFormat",
@@ -134,7 +120,9 @@ __all__ = (
"CreateSandboxResponseMetadata",
"CreateSnapshotRequest",
"Credential",
+ "CredentialAuth",
"CredentialAuthMetadata",
+ "CredentialAuthType",
"CredentialBinding",
"CredentialBindingListResponse",
"CredentialBindingMetadata",
@@ -145,14 +133,14 @@ __all__ = (
"CredentialMetadata",
"CredentialMutationSet",
"CredentialProxyConfig",
+ "CredentialSource",
+ "CredentialSourceType",
"CredentialSubstitution",
"CredentialSubstitutionInItem",
"CredentialVaultCreateRequest",
"CredentialVaultMutationRequest",
"CredentialVaultState",
"CustomHeaderEntry",
- "CustomHeadersCredentialAuth",
- "CustomHeadersCredentialAuthType",
"Endpoint",
"EndpointHeaders",
"ErrorResponse",
@@ -168,8 +156,6 @@ __all__ = (
"IdlePolicyOnIdle",
"ImageSpec",
"ImageSpecAuth",
- "InlineCredentialSource",
- "InlineCredentialSourceType",
"LifecycleHook",
"ListFsbTemplatesResponse",
"ListSandboxesResponse",
@@ -183,8 +169,6 @@ __all__ = (
"OSSFS",
"OSSFSVersion",
"PaginationInfo",
- "PassthroughCredentialAuth",
- "PassthroughCredentialAuthType",
"PatchSandboxMetadataRequest",
"PeriodicLifecycleHook",
"PlatformSpec",
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth.py
deleted file mode 100644
index 624a2b596..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.api_key_credential_auth_type import ApiKeyCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="ApiKeyCredentialAuth")
-
-
-@_attrs_define
-class ApiKeyCredentialAuth:
- """
- Attributes:
- type_ (ApiKeyCredentialAuthType):
- name (str):
- credential (str): Credential name whose value is the API key.
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: ApiKeyCredentialAuthType
- name: str
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- name = self.name
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "name": name,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = ApiKeyCredentialAuthType(d.pop("type"))
-
- name = d.pop("name")
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- api_key_credential_auth = cls(
- type_=type_,
- name=name,
- credential=credential,
- substitutions=substitutions,
- )
-
- return api_key_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth_type.py
deleted file mode 100644
index 4ec226962..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/api_key_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class ApiKeyCredentialAuthType(str, Enum):
- APIKEY = "apiKey"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth.py
deleted file mode 100644
index b5b2931ec..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.basic_credential_auth_type import BasicCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="BasicCredentialAuth")
-
-
-@_attrs_define
-class BasicCredentialAuth:
- """
- Attributes:
- type_ (BasicCredentialAuthType):
- credential (str): Credential containing pre-encoded base64(username:password).
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: BasicCredentialAuthType
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = BasicCredentialAuthType(d.pop("type"))
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- basic_credential_auth = cls(
- type_=type_,
- credential=credential,
- substitutions=substitutions,
- )
-
- return basic_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth_type.py
deleted file mode 100644
index 9802eb3c2..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/basic_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class BasicCredentialAuthType(str, Enum):
- BASIC = "basic"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth.py
deleted file mode 100644
index 981953a57..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth.py
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.bearer_credential_auth_type import BearerCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="BearerCredentialAuth")
-
-
-@_attrs_define
-class BearerCredentialAuth:
- """
- Attributes:
- type_ (BearerCredentialAuthType):
- credential (str): Credential name whose value becomes the bearer token.
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: BearerCredentialAuthType
- credential: str
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- credential = self.credential
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "credential": credential,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = BearerCredentialAuthType(d.pop("type"))
-
- credential = d.pop("credential")
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- bearer_credential_auth = cls(
- type_=type_,
- credential=credential,
- substitutions=substitutions,
- )
-
- return bearer_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth_type.py
deleted file mode 100644
index 121821a80..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/bearer_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class BearerCredentialAuthType(str, Enum):
- BEARER = "bearer"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential.py
index f54bb0d13..15d5f350b 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential.py
@@ -22,7 +22,7 @@ from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
if TYPE_CHECKING:
- from ..models.inline_credential_source import InlineCredentialSource
+ from ..models.credential_source import CredentialSource
T = TypeVar("T", bound="Credential")
@@ -33,11 +33,23 @@ class Credential:
"""
Attributes:
name (str):
- source (InlineCredentialSource):
+ source (CredentialSource): Where the credential material comes from. Exactly one kind, selected
+ by `type`:
+
+ - `inline`: the secret value travels in this request via `value`.
+ Inline values are write-only and never appear in reads.
+ - `exchange`: no local material. Egress resolves header sets per
+ request from a header-resolver service addressed by `endpoint`.
+ Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ Unix domain socket) and `https://host[:port]` (TLS); anything else
+ is rejected with 400.
+
+ Fields of the other kind must be absent; for example `value` together
+ with `type: exchange` is rejected with 400.
"""
name: str
- source: InlineCredentialSource
+ source: CredentialSource
def to_dict(self) -> dict[str, Any]:
name = self.name
@@ -57,12 +69,12 @@ class Credential:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.inline_credential_source import InlineCredentialSource
+ from ..models.credential_source import CredentialSource
d = dict(src_dict)
name = d.pop("name")
- source = InlineCredentialSource.from_dict(d.pop("source"))
+ source = CredentialSource.from_dict(d.pop("source"))
credential = cls(
name=name,
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth.py
new file mode 100644
index 000000000..40c48e3fb
--- /dev/null
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth.py
@@ -0,0 +1,156 @@
+#
+# Copyright 2026 The OpenSandbox Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import annotations
+
+from collections.abc import Mapping
+from typing import TYPE_CHECKING, Any, TypeVar
+
+from attrs import define as _attrs_define
+
+from ..models.credential_auth_type import CredentialAuthType
+from ..types import UNSET, Unset
+
+if TYPE_CHECKING:
+ from ..models.credential_substitution import CredentialSubstitution
+ from ..models.custom_header_entry import CustomHeaderEntry
+
+
+T = TypeVar("T", bound="CredentialAuth")
+
+
+@_attrs_define
+class CredentialAuth:
+ """How a binding injects credential material. Exactly one auth kind:
+
+ - `bearer`: `type: bearer` plus `credential`.
+ - `basic`: `type: basic` plus `credential`.
+ - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ - `customHeaders`: `type: customHeaders` plus `headers`.
+ - `passthrough`: `type: passthrough`, no credential reference.
+ - typeless exchange: `type` omitted with only `credential` set. The
+ referenced credential must be exchange-sourced; egress resolves the
+ header set per request from the credential's endpoint.
+
+ Static kinds must reference inline-sourced credentials, and the
+ typeless form must reference an exchange-sourced credential and must
+ not set `name`, `headers`, or `substitutions`. The five static kinds
+ accept optional `substitutions`. Violations are rejected with 400.
+
+ Attributes:
+ type_ (CredentialAuthType | Unset): Static auth kind. Omit entirely for the typeless exchange form.
+ credential (str | Unset): Name of the sandbox-local credential whose value is injected. For
+ `bearer` the value becomes the bearer token; for `basic` it
+ contains pre-encoded base64(username:password). Required for
+ `bearer`, `basic`, `apiKey`, and the typeless exchange form; must
+ be absent otherwise.
+ name (str | Unset): Request header name. Required for `apiKey`; must be absent otherwise.
+ headers (list[CustomHeaderEntry] | Unset): Static header set. Required for `customHeaders`; must be absent
+ otherwise.
+ substitutions (list[CredentialSubstitution] | Unset): Optional placeholder replacement set. Accepted for the
+ five static
+ kinds; must be absent for the typeless exchange form.
+ """
+
+ type_: CredentialAuthType | Unset = UNSET
+ credential: str | Unset = UNSET
+ name: str | Unset = UNSET
+ headers: list[CustomHeaderEntry] | Unset = UNSET
+ substitutions: list[CredentialSubstitution] | Unset = UNSET
+
+ def to_dict(self) -> dict[str, Any]:
+ type_: str | Unset = UNSET
+ if not isinstance(self.type_, Unset):
+ type_ = self.type_.value
+
+ credential = self.credential
+
+ name = self.name
+
+ headers: list[dict[str, Any]] | Unset = UNSET
+ if not isinstance(self.headers, Unset):
+ headers = []
+ for headers_item_data in self.headers:
+ headers_item = headers_item_data.to_dict()
+ headers.append(headers_item)
+
+ substitutions: list[dict[str, Any]] | Unset = UNSET
+ if not isinstance(self.substitutions, Unset):
+ substitutions = []
+ for substitutions_item_data in self.substitutions:
+ substitutions_item = substitutions_item_data.to_dict()
+ substitutions.append(substitutions_item)
+
+ field_dict: dict[str, Any] = {}
+
+ field_dict.update({})
+ if type_ is not UNSET:
+ field_dict["type"] = type_
+ if credential is not UNSET:
+ field_dict["credential"] = credential
+ if name is not UNSET:
+ field_dict["name"] = name
+ if headers is not UNSET:
+ field_dict["headers"] = headers
+ if substitutions is not UNSET:
+ field_dict["substitutions"] = substitutions
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ from ..models.credential_substitution import CredentialSubstitution
+ from ..models.custom_header_entry import CustomHeaderEntry
+
+ d = dict(src_dict)
+ _type_ = d.pop("type", UNSET)
+ type_: CredentialAuthType | Unset
+ if isinstance(_type_, Unset):
+ type_ = UNSET
+ else:
+ type_ = CredentialAuthType(_type_)
+
+ credential = d.pop("credential", UNSET)
+
+ name = d.pop("name", UNSET)
+
+ _headers = d.pop("headers", UNSET)
+ headers: list[CustomHeaderEntry] | Unset = UNSET
+ if _headers is not UNSET:
+ headers = []
+ for headers_item_data in _headers:
+ headers_item = CustomHeaderEntry.from_dict(headers_item_data)
+
+ headers.append(headers_item)
+
+ _substitutions = d.pop("substitutions", UNSET)
+ substitutions: list[CredentialSubstitution] | Unset = UNSET
+ if _substitutions is not UNSET:
+ substitutions = []
+ for substitutions_item_data in _substitutions:
+ substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
+
+ substitutions.append(substitutions_item)
+
+ credential_auth = cls(
+ type_=type_,
+ credential=credential,
+ name=name,
+ headers=headers,
+ substitutions=substitutions,
+ )
+
+ return credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_metadata.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_metadata.py
index 357169719..f71e7f52a 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_metadata.py
@@ -28,43 +28,51 @@ T = TypeVar("T", bound="CredentialAuthMetadata")
@_attrs_define
class CredentialAuthMetadata:
- """Sanitized auth shape — type always, name for apiKey only.
+ """Sanitized auth shape — `type` (plus `name` for `apiKey`) for static kinds; `credential` only for the typeless
+ exchange form.
- Attributes:
- type_ (str):
- name (str | Unset):
+ Attributes:
+ type_ (str | Unset):
+ name (str | Unset):
+ credential (str | Unset):
"""
- type_: str
+ type_: str | Unset = UNSET
name: str | Unset = UNSET
+ credential: str | Unset = UNSET
def to_dict(self) -> dict[str, Any]:
type_ = self.type_
name = self.name
+ credential = self.credential
+
field_dict: dict[str, Any] = {}
- field_dict.update(
- {
- "type": type_,
- }
- )
+ field_dict.update({})
+ if type_ is not UNSET:
+ field_dict["type"] = type_
if name is not UNSET:
field_dict["name"] = name
+ if credential is not UNSET:
+ field_dict["credential"] = credential
return field_dict
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
d = dict(src_dict)
- type_ = d.pop("type")
+ type_ = d.pop("type", UNSET)
name = d.pop("name", UNSET)
+ credential = d.pop("credential", UNSET)
+
credential_auth_metadata = cls(
type_=type_,
name=name,
+ credential=credential,
)
return credential_auth_metadata
diff --git a/sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_type.py
similarity index 84%
rename from sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth_type.py
rename to sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_type.py
index f0faf5c51..7d5efea79 100644
--- a/sdks/sandbox/python/src/opensandbox/api/egress/models/custom_headers_credential_auth_type.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_auth_type.py
@@ -17,8 +17,12 @@
from enum import Enum
-class CustomHeadersCredentialAuthType(str, Enum):
+class CredentialAuthType(str, Enum):
+ APIKEY = "apiKey"
+ BASIC = "basic"
+ BEARER = "bearer"
CUSTOMHEADERS = "customHeaders"
+ PASSTHROUGH = "passthrough"
def __str__(self) -> str:
return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding.py
index 3e3ef2199..ce0084667 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding.py
@@ -22,12 +22,8 @@ from typing import TYPE_CHECKING, Any, TypeVar
from attrs import define as _attrs_define
if TYPE_CHECKING:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
+ from ..models.credential_auth import CredentialAuth
from ..models.credential_match import CredentialMatch
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
- from ..models.passthrough_credential_auth import PassthroughCredentialAuth
T = TypeVar("T", bound="CredentialBinding")
@@ -39,41 +35,33 @@ class CredentialBinding:
Attributes:
name (str):
match (CredentialMatch):
- auth (ApiKeyCredentialAuth | BasicCredentialAuth | BearerCredentialAuth | CustomHeadersCredentialAuth |
- PassthroughCredentialAuth):
+ auth (CredentialAuth): How a binding injects credential material. Exactly one auth kind:
+
+ - `bearer`: `type: bearer` plus `credential`.
+ - `basic`: `type: basic` plus `credential`.
+ - `apiKey`: `type: apiKey` plus `name` and `credential`.
+ - `customHeaders`: `type: customHeaders` plus `headers`.
+ - `passthrough`: `type: passthrough`, no credential reference.
+ - typeless exchange: `type` omitted with only `credential` set. The
+ referenced credential must be exchange-sourced; egress resolves the
+ header set per request from the credential's endpoint.
+
+ Static kinds must reference inline-sourced credentials, and the
+ typeless form must reference an exchange-sourced credential and must
+ not set `name`, `headers`, or `substitutions`. The five static kinds
+ accept optional `substitutions`. Violations are rejected with 400.
"""
name: str
match: CredentialMatch
- auth: (
- ApiKeyCredentialAuth
- | BasicCredentialAuth
- | BearerCredentialAuth
- | CustomHeadersCredentialAuth
- | PassthroughCredentialAuth
- )
+ auth: CredentialAuth
def to_dict(self) -> dict[str, Any]:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
-
name = self.name
match = self.match.to_dict()
- auth: dict[str, Any]
- if isinstance(self.auth, BearerCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, BasicCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, ApiKeyCredentialAuth):
- auth = self.auth.to_dict()
- elif isinstance(self.auth, CustomHeadersCredentialAuth):
- auth = self.auth.to_dict()
- else:
- auth = self.auth.to_dict()
+ auth = self.auth.to_dict()
field_dict: dict[str, Any] = {}
@@ -89,66 +77,15 @@ class CredentialBinding:
@classmethod
def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.api_key_credential_auth import ApiKeyCredentialAuth
- from ..models.basic_credential_auth import BasicCredentialAuth
- from ..models.bearer_credential_auth import BearerCredentialAuth
+ from ..models.credential_auth import CredentialAuth
from ..models.credential_match import CredentialMatch
- from ..models.custom_headers_credential_auth import CustomHeadersCredentialAuth
- from ..models.passthrough_credential_auth import PassthroughCredentialAuth
d = dict(src_dict)
name = d.pop("name")
match = CredentialMatch.from_dict(d.pop("match"))
- def _parse_auth(
- data: object,
- ) -> (
- ApiKeyCredentialAuth
- | BasicCredentialAuth
- | BearerCredentialAuth
- | CustomHeadersCredentialAuth
- | PassthroughCredentialAuth
- ):
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_0 = BearerCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_0
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_1 = BasicCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_1
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_2 = ApiKeyCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_2
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- try:
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_3 = CustomHeadersCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_3
- except (TypeError, ValueError, AttributeError, KeyError):
- pass
- if not isinstance(data, dict):
- raise TypeError()
- componentsschemas_credential_auth_type_4 = PassthroughCredentialAuth.from_dict(data)
-
- return componentsschemas_credential_auth_type_4
-
- auth = _parse_auth(d.pop("auth"))
+ auth = CredentialAuth.from_dict(d.pop("auth"))
credential_binding = cls(
name=name,
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding_metadata.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding_metadata.py
index c244b7078..52677fb4f 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_binding_metadata.py
@@ -38,7 +38,8 @@ class CredentialBindingMetadata:
name (str):
revision (int): See CredentialMetadata.revision for the Fsb caveat.
match (CredentialMatch | Unset):
- auth (CredentialAuthMetadata | Unset): Sanitized auth shape — type always, name for apiKey only.
+ auth (CredentialAuthMetadata | Unset): Sanitized auth shape — `type` (plus `name` for `apiKey`) for static
+ kinds; `credential` only for the typeless exchange form.
"""
name: str
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_metadata.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_metadata.py
index 37d58425f..9dd929770 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_metadata.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_metadata.py
@@ -29,7 +29,7 @@ class CredentialMetadata:
"""
Attributes:
name (str):
- source_type (str):
+ source_type (str): Credential source kind (`inline` or `exchange`).
revision (int): Revision that last touched this record. Fsb stamps records with
the read revision (the relay surface does not carry per-record
revisions); other backends track per-record revisions.
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source.py
new file mode 100644
index 000000000..e4b5edc0a
--- /dev/null
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source.py
@@ -0,0 +1,109 @@
+#
+# Copyright 2026 The OpenSandbox Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from __future__ import annotations
+
+from collections.abc import Mapping
+from typing import Any, TypeVar
+
+from attrs import define as _attrs_define
+
+from ..models.credential_source_type import CredentialSourceType
+from ..types import UNSET, Unset
+
+T = TypeVar("T", bound="CredentialSource")
+
+
+@_attrs_define
+class CredentialSource:
+ """Where the credential material comes from. Exactly one kind, selected
+ by `type`:
+
+ - `inline`: the secret value travels in this request via `value`.
+ Inline values are write-only and never appear in reads.
+ - `exchange`: no local material. Egress resolves header sets per
+ request from a header-resolver service addressed by `endpoint`.
+ Supported endpoint forms are `unix:///absolute/path` (HTTP over a
+ Unix domain socket) and `https://host[:port]` (TLS); anything else
+ is rejected with 400.
+
+ Fields of the other kind must be absent; for example `value` together
+ with `type: exchange` is rejected with 400.
+
+ Attributes:
+ type_ (CredentialSourceType):
+ value (str | Unset): Inline secret value. Required when `type` is `inline`; must be
+ absent otherwise.
+ endpoint (str | Unset): Header-resolver endpoint. Required when `type` is `exchange`; must
+ be absent otherwise.
+ """
+
+ type_: CredentialSourceType
+ value: str | Unset = UNSET
+ endpoint: str | Unset = UNSET
+
+ def to_dict(self) -> dict[str, Any]:
+ type_ = self.type_.value
+
+ value = self.value
+
+ endpoint = self.endpoint
+
+ field_dict: dict[str, Any] = {}
+
+ field_dict.update(
+ {
+ "type": type_,
+ }
+ )
+ if value is not UNSET:
+ field_dict["value"] = value
+ if endpoint is not UNSET:
+ field_dict["endpoint"] = endpoint
+
+ return field_dict
+
+ @classmethod
+ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
+ d = dict(src_dict)
+ type_ = CredentialSourceType(d.pop("type"))
+
+ value = d.pop("value", UNSET)
+
+ endpoint = d.pop("endpoint", UNSET)
+
+ credential_source = cls(
+ type_=type_,
+ value=value,
+ endpoint=endpoint,
+ )
+
+ return credential_source
+
+
+# Redacted repr: the credential value is write-only and must never
+# surface in logs, exception messages, or debug output. attrs would
+# overwrite a class-level __repr__, so the override is applied on the
+# class object after definition.
+def _redacted_repr(self: CredentialSource) -> str:
+ value = "***" if self.value is not UNSET else "UNSET"
+ return (
+ f"{type(self).__name__}(type_={self.type_!r}, value={value},"
+ f" endpoint={self.endpoint!r})"
+ )
+
+
+CredentialSource.__repr__ = _redacted_repr # type: ignore[method-assign]
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source_type.py
similarity index 91%
rename from sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source_type.py
rename to sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source_type.py
index a15e435ff..3c2ae43ad 100644
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source_type.py
+++ b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/credential_source_type.py
@@ -17,7 +17,8 @@
from enum import Enum
-class InlineCredentialSourceType(str, Enum):
+class CredentialSourceType(str, Enum):
+ EXCHANGE = "exchange"
INLINE = "inline"
def __str__(self) -> str:
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth.py
deleted file mode 100644
index 7b95dc59a..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/custom_headers_credential_auth.py
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.custom_headers_credential_auth_type import CustomHeadersCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
- from ..models.custom_header_entry import CustomHeaderEntry
-
-
-T = TypeVar("T", bound="CustomHeadersCredentialAuth")
-
-
-@_attrs_define
-class CustomHeadersCredentialAuth:
- """
- Attributes:
- type_ (CustomHeadersCredentialAuthType):
- headers (list[CustomHeaderEntry]):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: CustomHeadersCredentialAuthType
- headers: list[CustomHeaderEntry]
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- headers = []
- for headers_item_data in self.headers:
- headers_item = headers_item_data.to_dict()
- headers.append(headers_item)
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "headers": headers,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
- from ..models.custom_header_entry import CustomHeaderEntry
-
- d = dict(src_dict)
- type_ = CustomHeadersCredentialAuthType(d.pop("type"))
-
- headers = []
- _headers = d.pop("headers")
- for headers_item_data in _headers:
- headers_item = CustomHeaderEntry.from_dict(headers_item_data)
-
- headers.append(headers_item)
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- custom_headers_credential_auth = cls(
- type_=type_,
- headers=headers,
- substitutions=substitutions,
- )
-
- return custom_headers_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source.py
deleted file mode 100644
index 2bf7cc67f..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/inline_credential_source.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.inline_credential_source_type import InlineCredentialSourceType
-
-T = TypeVar("T", bound="InlineCredentialSource")
-
-
-@_attrs_define
-class InlineCredentialSource:
- """
- Attributes:
- type_ (InlineCredentialSourceType):
- value (str):
- """
-
- type_: InlineCredentialSourceType
- value: str
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- value = self.value
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- "value": value,
- }
- )
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- d = dict(src_dict)
- type_ = InlineCredentialSourceType(d.pop("type"))
-
- value = d.pop("value")
-
- inline_credential_source = cls(
- type_=type_,
- value=value,
- )
-
- return inline_credential_source
-
-
-# Redacted repr: the credential value is write-only and must never
-# surface in logs, exception messages, or debug output. attrs would
-# overwrite a class-level __repr__, so the override is applied on the
-# class object after definition.
-def _redacted_repr(self: InlineCredentialSource) -> str:
- return f"{type(self).__name__}(value=***)"
-
-
-InlineCredentialSource.__repr__ = _redacted_repr # type: ignore[method-assign]
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth.py
deleted file mode 100644
index 586b08146..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth.py
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from __future__ import annotations
-
-from collections.abc import Mapping
-from typing import TYPE_CHECKING, Any, TypeVar
-
-from attrs import define as _attrs_define
-
-from ..models.passthrough_credential_auth_type import PassthroughCredentialAuthType
-from ..types import UNSET, Unset
-
-if TYPE_CHECKING:
- from ..models.credential_substitution import CredentialSubstitution
-
-
-T = TypeVar("T", bound="PassthroughCredentialAuth")
-
-
-@_attrs_define
-class PassthroughCredentialAuth:
- """
- Attributes:
- type_ (PassthroughCredentialAuthType):
- substitutions (list[CredentialSubstitution] | Unset):
- """
-
- type_: PassthroughCredentialAuthType
- substitutions: list[CredentialSubstitution] | Unset = UNSET
-
- def to_dict(self) -> dict[str, Any]:
- type_ = self.type_.value
-
- substitutions: list[dict[str, Any]] | Unset = UNSET
- if not isinstance(self.substitutions, Unset):
- substitutions = []
- for substitutions_item_data in self.substitutions:
- substitutions_item = substitutions_item_data.to_dict()
- substitutions.append(substitutions_item)
-
- field_dict: dict[str, Any] = {}
-
- field_dict.update(
- {
- "type": type_,
- }
- )
- if substitutions is not UNSET:
- field_dict["substitutions"] = substitutions
-
- return field_dict
-
- @classmethod
- def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
- from ..models.credential_substitution import CredentialSubstitution
-
- d = dict(src_dict)
- type_ = PassthroughCredentialAuthType(d.pop("type"))
-
- _substitutions = d.pop("substitutions", UNSET)
- substitutions: list[CredentialSubstitution] | Unset = UNSET
- if _substitutions is not UNSET:
- substitutions = []
- for substitutions_item_data in _substitutions:
- substitutions_item = CredentialSubstitution.from_dict(substitutions_item_data)
-
- substitutions.append(substitutions_item)
-
- passthrough_credential_auth = cls(
- type_=type_,
- substitutions=substitutions,
- )
-
- return passthrough_credential_auth
diff --git a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth_type.py b/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth_type.py
deleted file mode 100644
index 1ce563103..000000000
--- a/sdks/sandbox/python/src/opensandbox/api/lifecycle/models/passthrough_credential_auth_type.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright 2026 The OpenSandbox Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-from enum import Enum
-
-
-class PassthroughCredentialAuthType(str, Enum):
- PASSTHROUGH = "passthrough"
-
- def __str__(self) -> str:
- return str(self.value)
diff --git a/sdks/sandbox/python/src/opensandbox/models/__init__.py b/sdks/sandbox/python/src/opensandbox/models/__init__.py
index cb8378276..2d5fe16f9 100644
--- a/sdks/sandbox/python/src/opensandbox/models/__init__.py
+++ b/sdks/sandbox/python/src/opensandbox/models/__init__.py
@@ -75,6 +75,7 @@ from opensandbox.models.sandboxes import (
CredentialVaultPatchRequest,
CredentialVaultState,
CustomHeaderEntry,
+ ExchangeCredentialSource,
Host,
IdlePolicy,
InlineCredentialSource,
@@ -146,6 +147,7 @@ __all__ = [
"NetworkRule",
"CredentialProxyConfig",
"CredentialSubstitution",
+ "ExchangeCredentialSource",
"InlineCredentialSource",
"LifecycleHook",
"PeriodicLifecycleHook",
diff --git a/sdks/sandbox/python/src/opensandbox/models/sandboxes.py b/sdks/sandbox/python/src/opensandbox/models/sandboxes.py
index 982ea6fd8..5f83dd29b 100644
--- a/sdks/sandbox/python/src/opensandbox/models/sandboxes.py
+++ b/sdks/sandbox/python/src/opensandbox/models/sandboxes.py
@@ -459,12 +459,35 @@ class InlineCredentialSource(BaseModel):
return v
+class ExchangeCredentialSource(BaseModel):
+ """
+ Exchange credential source (OSEP-0025): no local material.
+
+ The egress resolves header sets per request from the header-resolver
+ endpoint; ``endpoint`` is configuration, not secret material.
+ """
+
+ type: Literal["exchange"] = Field(
+ default="exchange", description="Credential source type."
+ )
+ endpoint: str = Field(
+ description="Header-resolver endpoint (unix:///path or https://host[:port])."
+ )
+
+ @field_validator("endpoint")
+ @classmethod
+ def endpoint_must_not_be_empty(cls, v: str) -> str:
+ if not v.strip():
+ raise ValueError("Credential source endpoint cannot be blank")
+ return v
+
+
class Credential(BaseModel):
"""Sandbox-local Credential Vault credential."""
name: str = Field(description="Sandbox-local credential name.")
- source: InlineCredentialSource | dict[str, str] = Field(
- description="Write-only credential source."
+ source: InlineCredentialSource | ExchangeCredentialSource | dict[str, str] = Field(
+ description="Write-only credential source (inline material or exchange endpoint)."
)
@field_validator("name")
@@ -477,7 +500,10 @@ class Credential(BaseModel):
@model_validator(mode="after")
def normalize_source(self) -> "Credential":
if isinstance(self.source, dict):
- self.source = InlineCredentialSource.model_validate(self.source)
+ if self.source.get("type", "inline") == "exchange":
+ self.source = ExchangeCredentialSource.model_validate(self.source)
+ else:
+ self.source = InlineCredentialSource.model_validate(self.source)
return self
@@ -518,9 +544,16 @@ class CredentialSubstitution(BaseModel):
class CredentialAuth(BaseModel):
- """Typed Credential Vault auth rule."""
+ """Credential Vault auth rule.
+
+ ``type`` selects one of the five static kinds. Leaving it unset (None)
+ selects the typeless exchange form (OSEP-0025), which sets only
+ ``credential`` — a reference to an exchange-sourced credential.
+ """
- type: Literal["bearer", "basic", "apiKey", "customHeaders", "passthrough"]
+ type: Literal["bearer", "basic", "apiKey", "customHeaders", "passthrough"] | None = (
+ None
+ )
credential: str | None = None
name: str | None = None
headers: list[CustomHeaderEntry] | None = None
@@ -554,17 +587,26 @@ class CredentialMetadata(BaseModel):
"""Sanitized credential metadata returned by Credential Vault."""
name: str
- source_type: str = Field(alias="sourceType")
+ source_type: str = Field(
+ alias="sourceType",
+ description="Credential source kind (inline or exchange).",
+ )
revision: int
model_config = ConfigDict(populate_by_name=True)
class CredentialAuthMetadata(BaseModel):
- """Sanitized auth metadata returned for a Credential Vault binding."""
+ """Sanitized auth metadata returned for a Credential Vault binding.
- type: str
+ Static kinds carry ``type`` (plus ``name`` for apiKey); the typeless
+ exchange form carries only ``credential`` (a credential reference, never
+ material).
+ """
+
+ type: str | None = None
name: str | None = None
+ credential: str | None = None
class CredentialBindingMetadata(BaseModel):
diff --git a/sdks/sandbox/python/tests/test_credential_vault_adapter.py b/sdks/sandbox/python/tests/test_credential_vault_adapter.py
index fd75dbcfd..8e0a36d5a 100644
--- a/sdks/sandbox/python/tests/test_credential_vault_adapter.py
+++ b/sdks/sandbox/python/tests/test_credential_vault_adapter.py
@@ -29,15 +29,17 @@ from opensandbox.sync.adapters.egress_adapter import EgressAdapterSync
class _CredentialVaultAsyncTransport(httpx.AsyncBaseTransport):
- def __init__(self) -> None:
+ def __init__(self, post_response: dict | None = None) -> None:
self.requests: list[httpx.Request] = []
+ self._post_response = post_response
async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
self.requests.append(request)
if request.method == "POST" and request.url.path == "/credential-vault":
return httpx.Response(
201,
- json={
+ json=self._post_response
+ or {
"revision": 1,
"credentials": [
{"name": "gitlab-token", "sourceType": "inline", "revision": 1}
@@ -165,3 +167,63 @@ def test_sync_credential_vault_get_and_delete() -> None:
with pytest.raises(SandboxApiException) as exc_info:
adapter.get_credential("missing")
assert exc_info.value.status_code == 404
+
+
+async def test_async_credential_vault_exchange_round_trip() -> None:
+ """OSEP-0025: exchange sources and typeless auth serialize losslessly and
+ the sanitized typeless read shape (credential reference, no `type`) parses
+ without surfacing a `type: null`."""
+ transport = _CredentialVaultAsyncTransport(
+ post_response={
+ "revision": 1,
+ "credentials": [
+ {"name": "spi-signer", "sourceType": "exchange", "revision": 1}
+ ],
+ "bindings": [
+ {
+ "name": "internal-api",
+ "revision": 1,
+ "auth": {"credential": "spi-signer"},
+ "match": {"hosts": ["*.internal.example.com"]},
+ }
+ ],
+ }
+ )
+ adapter = EgressAdapter(
+ ConnectionConfig(transport=transport),
+ SandboxEndpoint(endpoint="sandbox.internal:18080"),
+ )
+
+ state = await adapter.create(
+ credentials=[
+ {
+ "name": "spi-signer",
+ "source": {"type": "exchange", "endpoint": "unix:///run/spi/spi.sock"},
+ }
+ ],
+ bindings=[
+ {
+ "name": "internal-api",
+ "match": {"hosts": ["*.internal.example.com"]},
+ "auth": {"credential": "spi-signer"},
+ }
+ ],
+ )
+
+ post_body = json.loads(transport.requests[0].content)
+ assert post_body["credentials"][0] == {
+ "name": "spi-signer",
+ "source": {"type": "exchange", "endpoint": "unix:///run/spi/spi.sock"},
+ }
+ assert post_body["bindings"][0]["auth"] == {"credential": "spi-signer"}
+ assert "type" not in post_body["bindings"][0]["auth"]
+
+ assert state.credentials[0] is not None
+ assert state.credentials[0].source_type == "exchange"
+ typeless = state.bindings[0].auth
+ assert typeless is not None
+ assert typeless.credential == "spi-signer"
+ dumped = typeless.model_dump(by_alias=True, exclude_none=True)
+ assert dumped == {"credential": "spi-signer"}
+ assert "type" not in dumped
diff --git a/server/opensandbox_server/api/schema.py b/server/opensandbox_server/api/schema.py
index 92deeb09b..bdd9995e7 100644
--- a/server/opensandbox_server/api/schema.py
+++ b/server/opensandbox_server/api/schema.py
@@ -21,7 +21,7 @@ for request/response validation and serialization.
import ipaddress
from datetime import datetime
-from typing import Annotated, Dict, List, Literal, Optional
+from typing import Dict, List, Literal, Optional
from pydantic import BaseModel, Field, PrivateAttr, RootModel, field_validator, model_validator
@@ -234,9 +234,30 @@ class InlineCredentialSource(BaseModel):
extra = "forbid"
+class ExchangeCredentialSource(BaseModel):
+ """Exchange credential source (OSEP-0025): no local material.
+
+ The egress owns endpoint semantics (unix:///path or https://host) and the
+ inline/exchange cross-lock validation authoritatively; the server only
+ checks the wire shape here.
+ """
+
+ type: Literal["exchange"] = Field(..., description="Credential source type.")
+ endpoint: str = Field(
+ ...,
+ description="Header-resolver endpoint; egress validates the scheme.",
+ )
+
+ class Config:
+ populate_by_name = True
+ extra = "forbid"
+
+
class Credential(BaseModel):
name: str = Field(..., min_length=1, description="Unique credential name.")
- source: InlineCredentialSource = Field(..., description="Credential value source.")
+ source: InlineCredentialSource | ExchangeCredentialSource = Field(
+ ..., description="Credential value source."
+ )
class Config:
populate_by_name = True
@@ -333,14 +354,36 @@ class PassthroughCredentialAuth(BaseModel):
extra = "forbid"
-CredentialAuth = Annotated[
+class ExchangeCredentialAuth(BaseModel):
+ """Typeless exchange auth (OSEP-0025): only a credential reference.
+
+ The referenced credential must be exchange-sourced; that cross-lock and
+ the rejection of any other field here is enforced authoritatively by the
+ egress (extra="forbid" already pins the server-side wire shape).
+ """
+
+ credential: str = Field(
+ ...,
+ min_length=1,
+ description="Name of the exchange-sourced credential to resolve per request.",
+ )
+
+ class Config:
+ populate_by_name = True
+ extra = "forbid"
+
+
+# No discriminator: the exchange variant carries no `type` key at all, so the
+# Literal-tagged static variants and the typeless variant are mutually
+# exclusive by shape and the smart union resolves without ambiguity.
+CredentialAuth = (
BearerCredentialAuth
| BasicCredentialAuth
| ApiKeyCredentialAuth
| CustomHeadersCredentialAuth
- | PassthroughCredentialAuth,
- Field(discriminator="type"),
-]
+ | PassthroughCredentialAuth
+ | ExchangeCredentialAuth
+)
class CredentialMatch(BaseModel):
@@ -440,10 +483,19 @@ class CredentialVaultMutationRequest(BaseModel):
class CredentialAuthMetadata(BaseModel):
- type: str = Field(..., description="Injected credential shape type.")
+ """Sanitized auth shape — `type` (plus `name` for `apiKey`) for static
+ kinds; `credential` only for the typeless exchange form."""
+
+ type: Optional[str] = Field(
+ default=None, description="Injected credential shape type (static kinds)."
+ )
name: Optional[str] = Field(
default=None, description="Header name, for the apiKey shape only."
)
+ credential: Optional[str] = Field(
+ default=None,
+ description="Exchange-sourced credential name, typeless form only.",
+ )
class Config:
populate_by_name = True
@@ -451,7 +503,11 @@ class CredentialAuthMetadata(BaseModel):
class CredentialMetadata(BaseModel):
name: str
- source_type: str = Field(..., alias="sourceType", description="Credential source type.")
+ source_type: str = Field(
+ ...,
+ alias="sourceType",
+ description="Credential source kind (inline or exchange).",
+ )
revision: int
class Config:
diff --git a/server/opensandbox_server/services/fast_sandbox/vault.py b/server/opensandbox_server/services/fast_sandbox/vault.py
index d7de52768..58cacc27c 100644
--- a/server/opensandbox_server/services/fast_sandbox/vault.py
+++ b/server/opensandbox_server/services/fast_sandbox/vault.py
@@ -78,11 +78,21 @@ def vault_relay_error(status_code: int, message: str) -> HTTPException:
def _sanitize_auth(auth: Optional[dict]) -> Optional[dict]:
- """Mirror the egress sanitizeAuth: type always, name for apiKey only."""
+ """Mirror the egress sanitizeAuth: type always, name for apiKey only.
+
+ Typeless exchange auth keeps only its credential reference and must never
+ serialize a ``"type": null`` key.
+ """
if not isinstance(auth, dict):
return None
- metadata: dict[str, Any] = {"type": auth.get("type")}
- if auth.get("type") == "apiKey" and auth.get("name") is not None:
+ auth_type = auth.get("type")
+ if auth_type is None:
+ credential = auth.get("credential")
+ if not isinstance(credential, str) or not credential:
+ return None
+ return {"credential": credential}
+ metadata: dict[str, Any] = {"type": auth_type}
+ if auth_type == "apiKey" and auth.get("name") is not None:
metadata["name"] = auth.get("name")
return metadata
diff --git a/server/tests/test_fsb_vault.py b/server/tests/test_fsb_vault.py
index 91a5b9add..232f102cb 100644
--- a/server/tests/test_fsb_vault.py
+++ b/server/tests/test_fsb_vault.py
@@ -70,6 +70,36 @@ _FULL_REVISION = {
],
}
+# Exchange vault revision (OSEP-0025): an exchange-sourced credential plus a
+# typeless binding referencing it, alongside static records.
+_EXCHANGE_CREDENTIAL = {
+ "name": "spi-signer",
+ "source": {"type": "exchange", "endpoint": "unix:///run/spi/spi.sock"},
+}
+_TYPELESS_BINDING = {
+ "name": "internal-api",
+ "match": {"hosts": ["*.internal.example.com"]},
+ "auth": {"credential": "spi-signer"},
+}
+
+
+def _exchange_full_revision() -> dict:
+ return {
+ "revision": 2,
+ "credentials": [
+ _EXCHANGE_CREDENTIAL,
+ {"name": "tok", "source": {"type": "inline", "value": "sekrit"}},
+ ],
+ "bindings": [
+ _TYPELESS_BINDING,
+ {
+ "name": "ext",
+ "match": {"hosts": ["ext.test"]},
+ "auth": {"type": "apiKey", "name": "X-Api-Key", "credential": "tok"},
+ },
+ ],
+ }
+
class _FakeFastPathService(pb2_grpc.FastPathServiceServicer):
"""Scripted FastPath: records relay calls, answers with fixed outcomes."""
@@ -307,6 +337,183 @@ def test_public_reads_sanitize_credential_values(vault_fsb):
assert binding_missing.status_code == 404
+def test_create_with_exchange_vault_relays_losslessly(vault_fsb):
+ """OSEP-0025 core acceptance: an exchange source plus a typeless binding
+ passes the server shape gate (previously 422) and relays byte-shape
+ intact; endpoint semantics stay with the egress."""
+ client, fake, _ = vault_fsb
+ fake.outcome = (201, _vault_ack(1))
+ response = client.post(
+ f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault",
+ json={
+ "credentials": [_EXCHANGE_CREDENTIAL],
+ "bindings": [_TYPELESS_BINDING],
+ },
+ )
+
+ assert response.status_code == 201, response.text
+ body = json.loads(fake.payloads[0])
+ assert body["credentials"] == [_EXCHANGE_CREDENTIAL]
+ assert body["bindings"] == [_TYPELESS_BINDING]
+
+
+def test_public_reads_sanitize_exchange_vault(vault_fsb):
+ """Sanitized reads carry `sourceType: exchange` and the typeless auth
+ credential reference, never the endpoint, and never `"type": null`."""
+ client, fake, _ = vault_fsb
+ fake.outcome = (200, json.dumps(_exchange_full_revision()).encode())
+
+ response = client.get(f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault")
+ assert response.status_code == 200
+ assert "spi.sock" not in response.text
+ assert '"type": null' not in response.text
+ state = response.json()
+ assert state["credentials"] == [
+ {"name": "spi-signer", "sourceType": "exchange", "revision": 2},
+ {"name": "tok", "sourceType": "inline", "revision": 2},
+ ]
+ assert state["bindings"][0]["auth"] == {"credential": "spi-signer"}
+ assert state["bindings"][1]["auth"] == {"type": "apiKey", "name": "X-Api-Key"}
+
+
+def test_patch_merges_exchange_records_losslessly(vault_fsb):
+ """PATCH-added exchange records re-serialize verbatim; untouched exchange
+ records round-trip through the merge unchanged."""
+ client, fake, _ = vault_fsb
+ https_exchange = {
+ "name": "corp-resolver",
+ "source": {"type": "exchange", "endpoint": "https://header-resolver.internal"},
+ }
+ fake.outcomes = [
+ (200, json.dumps(_exchange_full_revision()).encode()),
+ (200, _vault_ack(3)),
+ ]
+ response = client.patch(
+ f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault",
+ json={
+ "credentials": {"add": [https_exchange]},
+ "bindings": {
+ "add": [
+ {
+ "name": "internal-api-2",
+ "match": {"hosts": ["*.corp.example.com"]},
+ "auth": {"credential": "corp-resolver"},
+ }
+ ]
+ },
+ },
+ )
+
+ assert response.status_code == 200, response.text
+ merged = json.loads(fake.payloads[1])
+ assert merged["expectedRevision"] == 2
+ # Records are name-sorted in the PUT body: the added exchange credential
+ # re-serializes from the request shape; the read-back exchange credential
+ # and inline value round-trip verbatim (relay-only surface).
+ assert merged["credentials"] == [
+ https_exchange,
+ _EXCHANGE_CREDENTIAL,
+ _FULL_REVISION["credentials"][0],
+ ]
+ # Bindings are name-sorted too: untouched records round-trip verbatim,
+ # the added typeless binding re-serializes from the request shape.
+ assert merged["bindings"] == [
+ _exchange_full_revision()["bindings"][1],
+ _TYPELESS_BINDING,
+ {
+ "name": "internal-api-2",
+ "match": {"hosts": ["*.corp.example.com"]},
+ "auth": {"credential": "corp-resolver"},
+ },
+ ]
+
+
+def test_endpoint_semantics_stay_with_egress(vault_fsb):
+ """The server checks shape only: any string endpoint relays through and an
+ egress 400 (scheme validation, cross-lock) passes the relay mapping."""
+ client, fake, _ = vault_fsb
+ fake.outcome = (201, _vault_ack(1))
+ response = client.post(
+ f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault",
+ json={
+ "credentials": [
+ {"name": "weird", "source": {"type": "exchange", "endpoint": "ftp://x"}}
+ ],
+ "bindings": [],
+ },
+ )
+ assert response.status_code == 201
+
+ fake.calls.clear()
+ fake.outcome = (400, b"unsupported resolver endpoint scheme")
+ response = client.post(
+ f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault",
+ json={
+ "credentials": [
+ {"name": "weird", "source": {"type": "exchange", "endpoint": "ftp://x"}}
+ ],
+ "bindings": [],
+ },
+ )
+ assert response.status_code == 400
+ assert response.json()["detail"]["code"] == "SANDBOX::INVALID_PARAMETER"
+
+
+def test_exchange_shape_violations_are_422(vault_fsb):
+ """The smart union stays unambiguous: each malformed exchange shape is
+ rejected while `extra="forbid"` remains in force."""
+ client, _, _ = vault_fsb
+ cases = [
+ # exchange source without endpoint
+ {
+ "credentials": [{"name": "x", "source": {"type": "exchange"}}],
+ "bindings": [],
+ },
+ # inline-only field on an exchange source
+ {
+ "credentials": [
+ {"name": "x", "source": {"type": "exchange", "endpoint": "e", "value": "v"}}
+ ],
+ "bindings": [],
+ },
+ # exchange-only field on an inline source
+ {
+ "credentials": [{"name": "x", "source": {"type": "inline", "endpoint": "e"}}],
+ "bindings": [],
+ },
+ # `type: exchange` is not a static auth kind; typeless must omit type
+ {
+ "credentials": [],
+ "bindings": [
+ {"name": "b", "match": {"hosts": ["h"]}, "auth": {"type": "exchange", "credential": "x"}}
+ ],
+ },
+ # typeless auth with a static-only field
+ {
+ "credentials": [],
+ "bindings": [
+ {
+ "name": "b",
+ "match": {"hosts": ["h"]},
+ "auth": {"credential": "x", "substitutions": []},
+ }
+ ],
+ },
+ # explicit null type is not the typeless form
+ {
+ "credentials": [],
+ "bindings": [
+ {"name": "b", "match": {"hosts": ["h"]}, "auth": {"type": None, "credential": "x"}}
+ ],
+ },
+ ]
+ for case in cases:
+ response = client.post(
+ f"/v1/sandboxes/{_SANDBOX_ID}/credential-vault", json=case
+ )
+ assert response.status_code == 422, case
+
+
def test_patch_composes_get_merge_put_with_expected_revision(vault_fsb):
client, fake, _ = vault_fsb
# GET (read revision 2) then PUT ack (revision 3).
diff --git a/server/tests/test_routes_proxy.py b/server/tests/test_routes_proxy.py
index ac52c02fa..563c33742 100644
--- a/server/tests/test_routes_proxy.py
+++ b/server/tests/test_routes_proxy.py
@@ -1814,6 +1814,62 @@ def test_credential_vault_route_forwards_egress_auth_header(
assert len(egress_headers) == 1
assert egress_headers[0][1] == "injected-egress-token"
+
+def test_credential_vault_route_forwards_exchange_payload_verbatim(
+ client: TestClient,
+ auth_headers: dict,
+ monkeypatch,
+) -> None:
+ """OSEP-0025: the server shape gate accepts exchange sources and typeless
+ auth (previously 422) and the sidecar proxy forwards the body verbatim —
+ semantic validation stays with the egress."""
+
+ class StubService:
+ @staticmethod
+ def get_endpoint(sandbox_id: str, port: int, resolve_internal: bool = False, use_proxy_host: bool = False) -> Endpoint:
+ assert port == 18080
+ return Endpoint(endpoint="10.57.1.91:18080")
+
+ monkeypatch.setattr(lifecycle, "sandbox_service", StubService())
+
+ fake_client = _FakeAsyncClient()
+ fake_client.response = _FakeStreamingResponse(
+ status_code=201,
+ headers={"content-type": "application/json"},
+ chunks=[b'{"revision":1,"credentials":[],"bindings":[]}'],
+ )
+ _set_http_client(client, fake_client)
+
+ payload = {
+ "credentials": [
+ {
+ "name": "spi-signer",
+ "source": {"type": "exchange", "endpoint": "unix:///run/spi/spi.sock"},
+ }
+ ],
+ "bindings": [
+ {
+ "name": "internal-api",
+ "match": {"hosts": ["*.internal.example.com"]},
+ "auth": {"credential": "spi-signer"},
+ }
+ ],
+ }
+ response = client.post(
+ "/v1/sandboxes/sbx-123/credential-vault",
+ headers=auth_headers,
+ json=payload,
+ )
+
+ assert response.status_code == 201
+ assert fake_client.built is not None
+ assert fake_client.built["method"] == "POST"
+ assert fake_client.built["url"] == "http://10.57.1.91:18080/credential-vault"
+ # The body rides the raw request stream (verbatim passthrough like every
+ # other proxied body); reaching the sidecar at all proves the shape gate
+ # accepted the exchange payload.
+ assert fake_client.built["content"] is not None
+
class _StubRenewCoordinator:
def __init__(self) -> None:
self.scheduled: list[str] = []