@datacules/agent-identity-store-spiffe 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +34 -81
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,106 +1,59 @@
1
- # `@datacules/agent-identity-store-spiffe`
2
-
3
- SPIFFE/SPIRE workload identity credential store for [`@datacules/agent-identity`](https://github.com/hvrcharon1/agent-identity).
4
-
5
- Instead of static long-lived API keys stored in a vault, this store uses the **SPIFFE Workload API** to fetch short-lived **X.509 SVIDs** (SPIFFE Verifiable Identity Documents) on demand. A full store compromise yields only workload metadata — no usable credential material.
6
-
7
- ---
8
-
9
- ## How it works
1
+ <p align="center">
2
+ <img src="../../../assets/logo.svg" alt="Agent Identity — by Datacules LLC" width="360"/>
3
+ </p>
10
4
 
11
- 1. On `resolve()`, the store looks up credential metadata by `ref`.
12
- 2. It calls the SPIRE Workload API socket to fetch the current X.509 SVID bundle for that workload.
13
- 3. The SVID's PEM certificate chain is returned as the live credential value.
14
- 4. Downstream services verify the chain against the trust bundle — no static API key ever travels over the wire.
15
- 5. SVIDs are cached in memory until 5 minutes before expiry (configurable), then re-fetched transparently.
5
+ # `@datacules/agent-identity-store-spiffe`
16
6
 
17
- ---
7
+ SPIFFE/SPIRE workload identity store for the agent-identity framework. Zero static credentials — the agent is cryptographically attested by SPIRE and receives short-lived X.509 SVIDs that are auto-renewed.
18
8
 
19
- ## Installation
9
+ ## Install
20
10
 
21
11
  ```bash
22
- npm install @datacules/agent-identity-store-spiffe @spiffe/spiffe-workload-api
12
+ npm install @datacules/agent-identity-store-spiffe
23
13
  ```
24
14
 
25
- ---
26
-
27
15
  ## Usage
28
16
 
29
17
  ```typescript
30
- import { SpiffeCredentialStore } from '@datacules/agent-identity-store-spiffe';
18
+ import { SpiffeCredentialStore } from '@datacules/agent-identity-store-spiffe';
31
19
  import { createRouterFromStore } from '@datacules/agent-identity';
32
20
 
33
21
  const store = new SpiffeCredentialStore({
34
- trustDomain: 'acme.org',
35
- endpointSocket: 'unix:///run/spire/sockets/agent.sock', // or SPIFFE_ENDPOINT_SOCKET env
36
- credentials: [
37
- {
38
- id: 'cred-orders-service',
39
- ref: 'orders-service', // matched against SVID hint or path segment
40
- kind: 'fixed',
41
- name: 'Orders service workload identity',
42
- scope: 'all',
43
- status: 'active',
44
- provider: 'local',
45
- },
46
- ],
22
+ spiffeEndpointSocket: 'unix:///run/spire/sockets/agent.sock',
23
+ trustDomain: 'acme.com',
47
24
  });
48
25
 
26
+ // Routing rule matched by SPIFFE ID
27
+ const rules = [
28
+ {
29
+ id: 'rule-orders-agent',
30
+ matchSpiffeId: 'spiffe://acme.com/ns/production/sa/orders-agent',
31
+ credentialRef: 'orders-db-slot',
32
+ credentialKind:'fixed',
33
+ priority: 90,
34
+ },
35
+ ];
36
+
49
37
  const router = createRouterFromStore(store, rules, logger);
38
+ // ctx.spiffeId must be set to the workload's SPIFFE ID
50
39
  const resolved = await router.resolveAsync(ctx);
51
- // resolved.ref contains the PEM X.509 SVID — pass it to mTLS or a
52
- // downstream service that verifies SPIFFE SVIDs
53
40
  ```
54
41
 
55
- ---
56
-
57
- ## Configuration
58
-
59
- | Option | Type | Default | Description |
60
- |--------|------|---------|-------------|
61
- | `credentials` | `Credential[]` | required | Static metadata for each workload |
62
- | `endpointSocket` | `string` | `SPIFFE_ENDPOINT_SOCKET` env or `/tmp/spire-agent/public/api.sock` | SPIFFE Workload API socket path |
63
- | `trustDomain` | `string` | `example.org` | SPIFFE trust domain (e.g. `acme.org`) |
64
- | `cacheTtlSeconds` | `number` | `3300` (55 min) | How long to cache SVIDs before re-fetching |
65
-
66
- ---
42
+ ## How it works
67
43
 
68
- ## SVID matching
44
+ 1. The SPIRE agent runs as a DaemonSet (Kubernetes) or system service.
45
+ 2. On `findByRef()` the store calls the SPIRE Workload API over a Unix socket to fetch the workload's current X.509 SVID bundle.
46
+ 3. The SVID is cached until 60 seconds before its `notAfter` time, then automatically renewed.
47
+ 4. The credential's `ref` field contains the PEM-encoded certificate — injected server-side into the outbound request.
48
+ 5. Routing rules use `matchSpiffeId` (exact string or glob) to select the right SVID for each downstream service.
69
49
 
70
- The store matches a credential `ref` to an SVID using three strategies (first match wins):
50
+ ## Why use this?
71
51
 
72
- 1. **Hint match** — SVID `hint` field equals the credential `ref`
73
- 2. **Path suffix** — SPIFFE ID ends with `/<ref>` (e.g. `spiffe://acme.org/orders-service`)
74
- 3. **Exact SPIFFE ID** — SPIFFE ID equals `spiffe://<trustDomain>/<ref>`
52
+ - **Zero static secrets** — no API keys, passwords, or tokens stored anywhere.
53
+ - **Cryptographic attestation** — SPIRE verifies the workload's identity via OS primitives (kernel attestation, Kubernetes service account, AWS EC2 instance identity).
54
+ - **Short-lived credentials** — default SVID TTL is 1 hour; compromise window is minimal.
55
+ - **mTLS ready** — SVIDs can authenticate mutual TLS connections to downstream services directly.
75
56
 
76
57
  ---
77
58
 
78
- ## SPIRE server setup
79
-
80
- ```bash
81
- # Register a workload entry for your service
82
- spire-server entry create \
83
- -spiffeID spiffe://acme.org/orders-service \
84
- -parentID spiffe://acme.org/agent/prod \
85
- -selector k8s:pod-label:app:orders-service
86
-
87
- # The SPIRE agent on the node will attest the workload and issue SVIDs
88
- # automatically. No API key management required.
89
- ```
90
-
91
- ---
92
-
93
- ## Zero-trust architecture
94
-
95
- Combine with `@datacules/agent-identity-otel` for full observability:
96
-
97
- ```typescript
98
- import { withOtel } from '@datacules/agent-identity-otel';
99
-
100
- const router = withOtel(
101
- createRouterFromStore(spiffeStore, rules, logger),
102
- { tracer: trace.getTracer('agent-identity') }
103
- );
104
- ```
105
-
106
- Every SVID fetch, cache hit/miss, and credential resolution is traced.
59
+ Part of the [agent-identity monorepo](https://github.com/hvrcharon1/agent-identity) by [Datacules LLC](https://datacules.com).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datacules/agent-identity-store-spiffe",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "SPIFFE/SPIRE workload identity credential store for @datacules/agent-identity",
5
5
  "private": false,
6
6
  "type": "module",