Skip to content

Commit c94e0de

Browse files
authored
docs: blueprint auth, job triggers, webhooks, x402, pricing updates (#139)
* docs: blueprint auth, triggers, pricing, and gateways - Add auth proxy docs (blueprint-auth) - Add job trigger map plus dedicated Webhooks and x402 pages - Update pricing docs and note x402 settlement fields in pricing engine - Align runner docs with TangleProducer/TangleConsumer/TangleLayer - Add tnt-core protocol deployment pointers and refresh operator pricing Verification: yarn lint * docs: align vision pages with integration primitives - Add a high-level integration section (on-chain triggers, webhooks, x402, auth proxy) - Avoid implementation details and link to developer docs Verification: yarn lint * fix(docs): remove v2 branch links - Update docs links from /v2 to /main for blueprint and tnt-core - Fix Tangle client context page to match current SDK names Verification: yarn lint, yarn format:check * docs(blueprints): document service renewal and expiry
1 parent a1f8eff commit c94e0de

57 files changed

Lines changed: 1058 additions & 273 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components/NetworkResources.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ const NETWORK_DATA = {
5656
property: "Protocol Contracts",
5757
value: {
5858
type: "link",
59-
url: "https://github.com/tangle-network/tnt-core/tree/v2",
59+
url: "https://github.com/tangle-network/tnt-core/tree/main",
6060
text: "github.com/tangle-network/tnt-core",
6161
},
6262
},
6363
{
6464
property: "Blueprint SDK",
6565
value: {
6666
type: "link",
67-
url: "https://github.com/tangle-network/blueprint/tree/v2",
67+
url: "https://github.com/tangle-network/blueprint/tree/main",
6868
text: "github.com/tangle-network/blueprint",
6969
},
7070
},
@@ -109,15 +109,15 @@ const NETWORK_DATA = {
109109
property: "Protocol Contracts",
110110
value: {
111111
type: "link",
112-
url: "https://github.com/tangle-network/tnt-core/tree/v2",
112+
url: "https://github.com/tangle-network/tnt-core/tree/main",
113113
text: "github.com/tangle-network/tnt-core",
114114
},
115115
},
116116
{
117117
property: "Blueprint SDK",
118118
value: {
119119
type: "link",
120-
url: "https://github.com/tangle-network/blueprint/tree/v2",
120+
url: "https://github.com/tangle-network/blueprint/tree/main",
121121
text: "github.com/tangle-network/blueprint",
122122
},
123123
},

pages/developers/_meta.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const meta: Meta = {
1313
},
1414
"blueprint-contexts": "Contexts",
1515
"blueprint-runner": "Blueprint Runner",
16+
"blueprint-auth": "Auth Proxy",
1617
"blueprint-qos": "Quality of Service",
1718
"p2p-networking": "P2P Networking",
1819
"-- tooling": {
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
title: Blueprint Auth Proxy
3+
description: How blueprint-manager enforces authn/authz for off-chain HTTP/gRPC services (multi-tenancy, scopes, OAuth, mTLS).
4+
---
5+
6+
# Blueprint Auth Proxy (`blueprint-auth`)
7+
8+
Blueprints often expose off-chain HTTP/gRPC endpoints (APIs, agents, gateways, etc.). In the Tangle Blueprint stack,
9+
those endpoints are typically fronted by an **auth proxy** that runs inside `blueprint-manager`.
10+
11+
That proxy is implemented by the `blueprint-auth` crate and is the **single enforcement point** for:
12+
13+
- Authentication (API keys, OAuth assertions, mTLS)
14+
- Authorization (scopes)
15+
- Multi-tenancy (canonical tenant identity injection)
16+
- Header hygiene (strip spoofable auth headers; validate forwarded headers)
17+
18+
This page focuses on how **service users** obtain credentials and how **service developers** consume identity safely.
19+
20+
Source of truth (implementation-focused):
21+
22+
- Auth proxy flows and endpoints: https://github.com/tangle-network/blueprint/blob/main/crates/auth/AUTH_WORKFLOW.md
23+
- OAuth JWT bearer assertion policy: https://github.com/tangle-network/blueprint/blob/main/crates/auth/src/oauth/README.md
24+
25+
## What It Applies To (And What It Does Not)
26+
27+
- Applies to: **off-chain** requests that go through the manager’s proxy to your service `upstream_url`.
28+
- Does not apply to: **on-chain jobs** (`jobs submit`, contract calls). On-chain callers authenticate by signing transactions.
29+
30+
## Key Concepts
31+
32+
- `service_id`: Identifies the service behind the proxy. Minting endpoints require `X-Service-Id: <service_id>`.
33+
- Tenant identity: The proxy injects **`x-tenant-id`** (a privacy-safe hash) so upstreams can partition data safely.
34+
- Scopes: The proxy can inject **`x-scopes`** (space-delimited) derived from an authorized token.
35+
- Trust boundary: Upstreams should treat the proxy as the only trusted source of tenant/scopes headers.
36+
37+
## How A User Gets An Access Token
38+
39+
Users don’t generate `v4.local...` access tokens locally. They obtain them from the auth proxy by proving identity via
40+
one of the supported mechanisms.
41+
42+
### Option A: OAuth 2.0 JWT Bearer Assertion (Typical End-User Flow)
43+
44+
If your service is configured with an OAuth policy, a user can exchange a signed JWT assertion for a short-lived access
45+
token:
46+
47+
1. The user authenticates with an issuer you trust (your IdP) and receives a signed JWT assertion containing `sub`,
48+
`iss`, `iat`, `exp`, and a unique `jti`.
49+
2. The user calls the proxy:
50+
51+
```bash
52+
curl -sS -X POST "http://<manager-host>:8276/v1/oauth/token" \
53+
-H "X-Service-Id: <service_id>" \
54+
-H "Content-Type: application/x-www-form-urlencoded" \
55+
--data-urlencode "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \
56+
--data-urlencode "assertion=<compact-jwt>"
57+
```
58+
59+
3. The proxy verifies the assertion (signature + claims + replay protection via `jti`) and returns a short-lived
60+
`v4.local...` token.
61+
4. The user calls your service through the proxy:
62+
63+
```bash
64+
curl -sS "http://<manager-host>:8276/<your-upstream-path>" \
65+
-H "Authorization: Bearer v4.local.<...>"
66+
```
67+
68+
What your upstream receives (conceptually):
69+
70+
- `x-tenant-id`: derived from the verified OAuth `sub` (hashed)
71+
- `x-scopes`: a normalized scope list if allowed by your per-service policy
72+
73+
### Option B: API Key Exchange (Service Owner / Operator Flow)
74+
75+
This is primarily for service owners/operators and automation:
76+
77+
1. Owner proves control of a registered owner key (challenge/verify).
78+
2. Proxy returns a long-lived API key (`ak_...`).
79+
3. Owner exchanges the API key for a short-lived access token:
80+
81+
```bash
82+
curl -sS -X POST "http://<manager-host>:8276/v1/auth/exchange" \
83+
-H "Authorization: Bearer ak_<key_id>.<secret>" \
84+
-H "Content-Type: application/json" \
85+
-d '{"additional_headers": {"X-Tenant-Id": "optional-tenant-hint"}}'
86+
```
87+
88+
### Option C: mTLS (High-Trust Environments)
89+
90+
If a service is configured to require client mTLS, the client authenticates using a certificate trusted by the proxy.
91+
The proxy can inject certificate identity headers (subject/issuer/serial) and an auth method header.
92+
93+
## Multi-Tenancy: What Happens For A New User vs Existing User
94+
95+
From the proxy’s perspective, multi-tenancy is **stateless**:
96+
97+
- A “new user” is simply a request whose derived `x-tenant-id` has not been seen by your upstream before.
98+
- An “existing user” is one whose derived `x-tenant-id` matches previously observed requests.
99+
100+
The proxy is responsible for:
101+
102+
- Deriving/injecting a canonical `x-tenant-id` after validating the caller
103+
- Stripping any client-supplied `x-tenant-*` or `x-scopes` headers (prevent spoofing)
104+
- Validating/normalizing any additional forwarded headers (size, count, forbidden headers)
105+
106+
Your upstream is responsible for:
107+
108+
- Using `x-tenant-id` as the partition key (database namespace, row-level filter, object prefix, etc.)
109+
- Enforcing scope checks based on `x-scopes` (if your service uses scopes)
110+
- Ensuring requests cannot bypass the proxy (network policy, firewall rules, service binding to localhost/private network)
111+
112+
## Operator Notes (Manager Defaults)
113+
114+
`blueprint-manager` runs the auth proxy by default and exposes CLI flags:
115+
116+
- `--auth-proxy-host` (default `0.0.0.0`)
117+
- `--auth-proxy-port` (default `8276`)
118+
119+
See: https://github.com/tangle-network/blueprint/blob/main/crates/manager/src/config/mod.rs
120+
121+
## Configuration Status (OAuth Policy)
122+
123+
OAuth verification is driven by a **per-service policy** (allowed issuers/audiences/public keys/scopes/TTL caps)
124+
stored by `service_id`.
125+
126+
At time of writing, the policy format and verification rules are implemented and tested, but operator-facing tooling for
127+
managing policies may be limited. Start here:
128+
129+
- Policy schema + rules: https://github.com/tangle-network/blueprint/blob/main/crates/auth/src/oauth/README.md

pages/developers/blueprint-contexts/evm-provider-context.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import GithubFileReaderDisplay from '/components/GithubFileReaderDisplay';
66

77
# EVM Provider Context
88

9-
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/v2/crates/contexts
9+
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/main/crates/contexts
1010

1111
The `EvmInstrumentedClientContext` trait provides a standardized [alloy-rs](https://github.com/alloy-rs) EVM provider for interacting with EVM-compatible blockchain networks in your Blueprint.
1212

@@ -15,7 +15,7 @@ The `EvmInstrumentedClientContext` trait provides a standardized [alloy-rs](http
1515
The `EvmInstrumentedClientContext` trait provides access to an EVM provider:
1616

1717
<GithubFileReaderDisplay
18-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/contexts/src/instrumented_evm_client.rs"
18+
url="https://github.com/tangle-network/blueprint/blob/main/crates/contexts/src/instrumented_evm_client.rs"
1919
fromLine={3}
2020
toLine={6}
2121
title="EvmInstrumentedClientContext Trait Definition"
@@ -28,7 +28,7 @@ The `EvmInstrumentedClientContext` trait provides access to an EVM provider:
2828
First, define your context struct that implements the `EvmProviderContext` trait:
2929

3030
<GithubFileReaderDisplay
31-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
31+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
3232
fromLine={13}
3333
toLine={22}
3434
title="EVM Provider Context Definition"
@@ -39,7 +39,7 @@ First, define your context struct that implements the `EvmProviderContext` trait
3939
You can then use this context to access EVM provider parameters:
4040

4141
<GithubFileReaderDisplay
42-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
42+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
4343
fromLine={36}
4444
toLine={36}
4545
title="Accessing EVM Provider Parameters"

pages/developers/blueprint-contexts/introduction.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: Introduction to Contexts
33
---
44

5-
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/v2/crates/contexts
5+
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/main/crates/contexts
66

77
## What is a Context?
88

9-
In the [Blueprint SDK](https://github.com/tangle-network/blueprint/tree/v2), a Context holds utilities and dependencies that a job may need that aren't direct inputs. Think of it as a container for all the external resources and services your job requires to function.
9+
In the [Blueprint SDK](https://github.com/tangle-network/blueprint/tree/main), a Context holds utilities and dependencies that a job may need that aren't direct inputs. Think of it as a container for all the external resources and services your job requires to function.
1010

1111
A Context can include various elements such as:
1212

pages/developers/blueprint-contexts/keystore-context.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import GithubFileReaderDisplay from '/components/GithubFileReaderDisplay';
66

77
# Keystore Context
88

9-
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/v2/crates/contexts
9+
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/main/crates/contexts
1010

1111
The `KeystoreContext` trait provides a standardized interface for accessing, managing, and signing using cryptographic keys in your Blueprint.
1212

@@ -21,7 +21,7 @@ The `KeystoreContext` trait provides access to a `Keystore` that implements the
2121
- Key Import/Export - Import existing keys and export key data
2222

2323
<GithubFileReaderDisplay
24-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/contexts/src/keystore.rs"
24+
url="https://github.com/tangle-network/blueprint/blob/main/crates/contexts/src/keystore.rs"
2525
fromLine={4}
2626
toLine={7}
2727
title="KeystoreContext Trait Definition"
@@ -34,7 +34,7 @@ The `KeystoreContext` trait provides access to a `Keystore` that implements the
3434
First, define your context struct that implements the `KeystoreContext` trait:
3535

3636
<GithubFileReaderDisplay
37-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
37+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
3838
fromLine={13}
3939
toLine={22}
4040
title="Keystore Context Definition"
@@ -45,7 +45,7 @@ First, define your context struct that implements the `KeystoreContext` trait:
4545
You can then use this context to access the keystore and perform key operations:
4646

4747
<GithubFileReaderDisplay
48-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
48+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
4949
fromLine={35}
5050
toLine={35}
5151
title="Accessing Keystore Functionality"

pages/developers/blueprint-contexts/tangle-client-context.mdx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,47 @@ import GithubFileReaderDisplay from '/components/GithubFileReaderDisplay';
66

77
# Tangle Client Context
88

9-
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/v2/crates/contexts
9+
SDK source (GitHub): https://github.com/tangle-network/blueprint/tree/main/crates/contexts
1010

11-
The `TangleEvmClientContext` trait provides a standardized interface for interacting with the Tangle EVM protocol from a Blueprint. It exposes a typed `TangleEvmClient` configured from the blueprint environment.
11+
The `TangleClientContext` trait provides a standardized interface for interacting with the Tangle protocol from a
12+
Blueprint. It exposes a typed `TangleClient` configured from the blueprint environment.
1213

1314
## Context Summary
1415

15-
The `TangleEvmClientContext` trait provides access to an EVM client that enables:
16+
The `TangleClientContext` trait provides access to a client that enables:
1617

1718
- Transaction submission to core protocol contracts
1819
- Service and operator state queries
1920
- Job submission and result reporting
2021
- Access to operator identity and keystore-backed signing
2122

2223
<GithubFileReaderDisplay
23-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/contexts/src/tangle_evm.rs"
24+
url="https://github.com/tangle-network/blueprint/blob/main/crates/contexts/src/tangle.rs"
2425
fromLine={1}
25-
toLine={44}
26-
title="TangleEvmClientContext Trait Definition"
26+
toLine={70}
27+
title="TangleClientContext Trait Definition"
2728
/>
2829

2930
## Using the Context
3031

3132
### 1. Define Your Context
3233

33-
First, define your context struct that implements the `TangleEvmClientContext` trait:
34+
First, define your context struct that implements the `TangleClientContext` trait:
3435

3536
<GithubFileReaderDisplay
36-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
37+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
3738
fromLine={13}
3839
toLine={22}
3940
title="Tangle Client Context Definition"
4041
/>
4142

42-
### 2. Access Tangle EVM Client Functionality
43+
### 2. Access Tangle Client Functionality
4344

44-
You can then use this context to access the client and interact with the Tangle EVM protocol:
45+
You can then use this context to access the client and interact with the Tangle protocol:
4546

4647
<GithubFileReaderDisplay
47-
url="https://github.com/tangle-network/blueprint/blob/v2/crates/macros/context-derive/tests/ui/basic.rs"
48-
fromLine={35}
49-
toLine={35}
50-
title="Accessing Tangle EVM Client Functionality"
48+
url="https://github.com/tangle-network/blueprint/blob/main/crates/macros/context-derive/tests/ui/basic.rs"
49+
fromLine={25}
50+
toLine={32}
51+
title="Accessing Tangle Client Functionality"
5152
/>

0 commit comments

Comments
 (0)