Skip to content

Commit d7da0c7

Browse files
authored
refactor(credentials): extract embedded credential issuer (#5266)
* refactor(credentials): extract embedded credential issuer Move credential backend orchestration, storage dispatch, typed secret owners, and existing driver transport into an embedded library. Keep provider policy and refresh orchestration in the gateway, preserving existing configuration and durable credential identities. Refs #4358 Signed-off-by: Seth Jennings <[email protected]> * fix(credentials): keep test hooks off issuer trait Signed-off-by: Seth Jennings <[email protected]> --------- Signed-off-by: Seth Jennings <[email protected]>
1 parent eeccc21 commit d7da0c7

21 files changed

Lines changed: 4048 additions & 2419 deletions

‎AGENTS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Do not rely on this file for a full inventory. The detailed public and contribut
2323
|------|-----------|---------|
2424
| `crates/openshell-cli/` | CLI binary | User-facing command-line interface |
2525
| `crates/openshell-server/` | Gateway server | Control-plane API, sandbox lifecycle, auth boundary |
26+
| `crates/openshell-credential-issuer/` | Embedded credential issuer | Credential backend orchestration, typed secret owners, storage dispatch, and existing driver transport |
2627
| `crates/openshell-sandbox/` | Sandbox runtime | Capability-free workload launcher, process identity, and seccomp-mediated I/O |
2728
| `crates/openshell-supervisor/` | Supervisor runtime | Gateway session, policy evaluation, credentials, and upstream networking |
2829
| `crates/openshell-supervisor-control/` | Shared supervisor control | Gateway-owned assignment controller, launch registrations, recovery coordination, and host observations for a supervisor shared by many sandboxes |

‎Cargo.lock‎

Lines changed: 23 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[package]
5+
name = "openshell-credential-issuer"
6+
description = "Embedded credential issuer and storage boundary for OpenShell"
7+
version.workspace = true
8+
edition.workspace = true
9+
rust-version.workspace = true
10+
license.workspace = true
11+
repository.workspace = true
12+
13+
[dependencies]
14+
openshell-core = { path = "../openshell-core", default-features = false }
15+
openshell-crypto = { workspace = true }
16+
openshell-driver-db-credstore = { path = "../openshell-driver-db-credstore" }
17+
openshell-driver-kubernetes-secrets = { path = "../openshell-driver-kubernetes-secrets" }
18+
openshell-driver-vault = { path = "../openshell-driver-vault" }
19+
async-trait = "0.1"
20+
futures = { workspace = true }
21+
hyper-util = { workspace = true }
22+
prost-types = { workspace = true }
23+
rustix = { workspace = true }
24+
tokio = { workspace = true }
25+
toml = { workspace = true }
26+
tonic = { workspace = true }
27+
tower = { workspace = true }
28+
tracing = { workspace = true }
29+
30+
[features]
31+
test-support = []
32+
33+
[dev-dependencies]
34+
tempfile = "3"
35+
36+
[lints]
37+
workspace = true
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Embedded credential issuer
2+
3+
`openshell-credential-issuer` owns credential backend selection, secret storage and resolution, refresh-material storage-key translation, and the existing external-driver UDS transport. The gateway embeds this library in its existing process. This crate has no executable, listener, generated service contract, or deployment configuration.
4+
5+
## Boundary
6+
7+
The gateway uses the object-safe `CredentialIssuer` trait. `EmbeddedCredentialIssuer` implements it using the existing encrypted database, Kubernetes Secrets, or Vault drivers. Driver capability negotiation, timeout behavior, batching, staged object IDs, and opaque handles retain the existing credential-driver contract.
8+
9+
The gateway still owns provider records and profiles, workspace authorization, attachment validation, provider expiration, public credential export, refresh scheduling/minting/recovery, and supervisor delivery. The gateway's thin `credentials` facade adapts those concerns to this library. The issuer does not depend on `openshell-server` or gateway-private protobufs.
10+
11+
`IssuerConfig` is an internal projection of the existing credential settings. The embedding process loads configuration and passes credential-specific settings to the issuer. This does not add or change any operator-facing configuration fields.
12+
13+
## Persistence
14+
15+
The `persistence` module re-exports the existing `DbCredstoreObjectStore` port and its conditional-write types from `openshell-driver-db-credstore`. The gateway supplies a small adapter over its already-open SQLite/Postgres `Store`; the issuer does not open a second pool or duplicate the SQL implementation. The adapter only translates encrypted object records, write conditions, and errors. Envelope encryption and key management remain in the database driver.
16+
17+
Refresh-state persistence and advisory locks are not extracted in this phase. A future standalone issuer will need its own database adapter and refresh-state store; this library is not yet a standalone service.
18+
19+
## Owners and compatibility
20+
21+
`SecretOwner` scopes each operation to a workspace and one of three kinds:
22+
23+
- `Provider`: the existing provider UUID and name.
24+
- `Sandbox`: the sandbox UUID for its SSH host identity.
25+
- `SupervisorInstance`: the sandbox UUID owning a launch-material assignment, not the shared supervisor route or host.
26+
27+
Only the issuer's owner adapter translates internal kinds into legacy provider-shaped driver requests. SSH keys keep `sandbox-ssh-<sandbox UUID>` and launch material keeps `sandbox-instance-<sandbox UUID>`. Existing workspace fields, backend paths, envelope ownership, keys, and opaque handles are unchanged. Typed kinds do not introduce new durable ownership metadata or stronger authorization into old external drivers.
28+
29+
`StoreSecrets::object_id` identifies a particular staged write, not its owner. Distinct candidate IDs remain essential: a losing candidate must not overwrite or delete another writer's committed secret. Refresh-material keys retain the same domain-separated SHA-256 bytes, computed through `openshell-crypto` with failures propagated.
30+
31+
Raw resolution returns backend expiration metadata without applying provider policy. The gateway combines provider and backend expiration and withholds expired values. Refresh material has no provider expiration and retains its existing zero-time backend-expiration cutoff.
32+
33+
## Tests
34+
35+
Issuer tests cover registry/configuration/transport behavior, owner translation, storage batching, response correlation, and material-key compatibility. The existing server tests continue to cover provider orchestration, refresh races/recovery, credential export, SSH identity, launch material, and delivery through the extracted implementation.
36+
37+
The `test-support` feature exposes the existing static backend and deterministic failure/concurrency hooks on `EmbeddedCredentialIssuer` to server tests. The hooks are not part of `CredentialIssuer`, so other implementations need only implement the storage contract even when this feature is enabled. The server's test helpers retain the same concrete issuer allocation used by its trait object. The feature is enabled by the server's dev-dependency and explicit test-support feature, not by release defaults. A dependency does not inherit its caller's `cfg(test)`.
38+
39+
```shell
40+
cargo test -p openshell-credential-issuer
41+
cargo test -p openshell-server --features test-support
42+
```
43+
44+
No new e2e suite or runtime artifact is needed. Versioned references, refresh-engine extraction, remote RPCs, authentication, watches/caching, and service packaging remain later RFC 0023 phases.

0 commit comments

Comments
 (0)