@cratis/pi 7.179.1 → 7.179.2

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.
@@ -0,0 +1,84 @@
1
+ ---
2
+ applyTo: "**/Deployment/**,**/*AuthProxy*,**/*Capabilit*,**/Mcp/**"
3
+ paths:
4
+ - "**/Deployment/**"
5
+ - "**/*AuthProxy*"
6
+ - "**/*Capabilit*"
7
+ - "**/Mcp/**"
8
+ ---
9
+ <!-- cratis-ai: generated Copilot instructions. Do not edit; rules/ is the source. -->
10
+ # The AuthProxy is the first and the last line of defense; applications never authenticate
11
+
12
+ Every line is **[contract]** (binding; see [`general.md`](../../../rules/general.md)). The AuthProxy is the only
13
+ component that decides who a caller is, and it does so before a request reaches an application. An
14
+ application trusts the identity and tenant the proxy forwards and contains no code that decides who
15
+ a caller is. A surface that reaches an application without the proxy having authenticated the
16
+ caller is a security hole, however well the application checks it afterwards.
17
+
18
+ ## The application never authenticates
19
+
20
+ - **No code in an application checks a caller's credential to grant access:** no bearer-token,
21
+ JWT, API-key, personal-access-token, password or signature check on a request, no middleware,
22
+ filter or `Authorization` header reader that decides who is calling. Do not build one, and do
23
+ not copy one from another Cratis product. Move an existing one to the proxy.
24
+ - **Last line means unreachable around the proxy.** An application accepts traffic only from the
25
+ proxy: a network policy lets only the proxy reach its listener, and it trusts only the identity
26
+ and tenant headers the proxy writes (the proxy strips inbound copies). Where available, verify the
27
+ proxy's forwarded-identity signature; that verifies the proxy, not the caller.
28
+ - **The application neither issues nor verifies credentials.** Signing keys, token minting, consent,
29
+ refresh and revocation belong to the product's own Cratis Identity instance, which publishes issuer
30
+ metadata and keys. The application answers only the questions Identity asks it, such as which
31
+ tenants a person may enter, over an isolated internal listener with a shared secret and a network
32
+ policy that admits only Identity. That callback is service-to-service trust, not caller
33
+ authentication.
34
+
35
+ ## Never expose a credential-bearing path unauthenticated
36
+
37
+ - **A path that carries a credential is never an `AnonymousPaths` entry.** That includes MCP (`/mcp`),
38
+ OpenAI-compatible and other API surfaces (`/v1`), and anything else a caller presents a token,
39
+ key or secret to. An anonymous path is reachable by anyone who knows the URL; the proxy strips
40
+ identity from it and does not authenticate it.
41
+ - **`PassCallerAuthorizationPaths` is not a way around this.** Forwarding the caller's
42
+ `Authorization` header so the application verifies it moves authentication into the application.
43
+ Use it only for a request that signs itself with its own scheme (a webhook with a signature
44
+ header), never for a bearer token, API key or personal access token.
45
+ - **What may be anonymous:** health, static public content, a webhook receiver that verifies the
46
+ sender's signature, public metadata (`/.well-known/oauth-protected-resource*`, issuer metadata
47
+ and public keys) and an introspection endpoint that only reports whether a presented token is
48
+ active. Each entry names the narrowest prefix, and the reason sits beside it.
49
+
50
+ ## How a non-browser caller gets in
51
+
52
+ Declare the route on the AuthProxy so the proxy authenticates before the request is forwarded:
53
+
54
+ - **Bearer route with the product's Identity issuer.** `BearerRoutes` with `PathPrefix`, `Issuers`,
55
+ `Audiences` and `RequiredScopes`. The proxy validates the signature, `iss`, `aud`, `exp`/`nbf` and
56
+ scopes, reads the tenant from a single tenant claim, and forwards the principal. Set `Introspection`
57
+ on the issuer so a revoked token stops working within seconds. Each product runs its own Identity
58
+ instance at its own origin (for example `identity.<product host>`), with its own keys and accounts.
59
+ - **People sign in with authorization code and PKCE** (device flow where there is no browser). A
60
+ token pasted into a client is a fallback: short-lived, issued by Identity, never created by the
61
+ application.
62
+ - **Client credentials** in the application (a secret hash the proxy checks over a back channel) are
63
+ a transitional shape only. Do not add one; move an existing one to Identity when it can replace it.
64
+ - **Personal access tokens** (`PersonalAccessTokens`) are recognized by the proxy but not
65
+ authenticated by it, so the backend would have to authenticate each one. Do not use them.
66
+
67
+ ## Tenancy
68
+
69
+ - The organization comes from the token's tenant claim, resolved by the proxy (`Claim` strategy,
70
+ or `Route`/`Host`/`SubHost` constraints that refuse a token for another tenant with `403`). It
71
+ never comes from a header, a query string, a request body or a tool argument.
72
+ - A credential belongs to one tenant. Someone in several organizations holds one per organization.
73
+ - The application still enforces the tenant and membership it receives. That is authorization of
74
+ the forwarded identity, not authentication, and a second layer.
75
+
76
+ ## Prove it before shipping
77
+
78
+ - A Pulumi mock spec reads the rendered AuthProxy configuration and fails when a path that serves
79
+ a credential-bearing endpoint is in `AnonymousPaths` or `PassCallerAuthorizationPaths`.
80
+ - A spec or scan fails when application code reads the `Authorization` header or validates a JWT,
81
+ key or password on a request.
82
+ - Calling the endpoint through the proxy without a token gives `401`; with a token for another
83
+ tenant `403`; with a spoofed `x-cratis-tenant-id` or `x-ms-client-principal*` header the header
84
+ is ignored; a request that skips the proxy is refused by the network.
@@ -0,0 +1,83 @@
1
+ ---
2
+ applyTo: "**/Deployment/**,**/*AuthProxy*,**/*Capabilit*,**/Mcp/**"
3
+ paths:
4
+ - "**/Deployment/**"
5
+ - "**/*AuthProxy*"
6
+ - "**/*Capabilit*"
7
+ - "**/Mcp/**"
8
+ ---
9
+ # The AuthProxy is the first and the last line of defense; applications never authenticate
10
+
11
+ Every line is **[contract]** (binding; see [`general.md`](./general.md)). The AuthProxy is the only
12
+ component that decides who a caller is, and it does so before a request reaches an application. An
13
+ application trusts the identity and tenant the proxy forwards and contains no code that decides who
14
+ a caller is. A surface that reaches an application without the proxy having authenticated the
15
+ caller is a security hole, however well the application checks it afterwards.
16
+
17
+ ## The application never authenticates
18
+
19
+ - **No code in an application checks a caller's credential to grant access:** no bearer-token,
20
+ JWT, API-key, personal-access-token, password or signature check on a request, no middleware,
21
+ filter or `Authorization` header reader that decides who is calling. Do not build one, and do
22
+ not copy one from another Cratis product. Move an existing one to the proxy.
23
+ - **Last line means unreachable around the proxy.** An application accepts traffic only from the
24
+ proxy: a network policy lets only the proxy reach its listener, and it trusts only the identity
25
+ and tenant headers the proxy writes (the proxy strips inbound copies). Where available, verify the
26
+ proxy's forwarded-identity signature; that verifies the proxy, not the caller.
27
+ - **The application neither issues nor verifies credentials.** Signing keys, token minting, consent,
28
+ refresh and revocation belong to the product's own Cratis Identity instance, which publishes issuer
29
+ metadata and keys. The application answers only the questions Identity asks it, such as which
30
+ tenants a person may enter, over an isolated internal listener with a shared secret and a network
31
+ policy that admits only Identity. That callback is service-to-service trust, not caller
32
+ authentication.
33
+
34
+ ## Never expose a credential-bearing path unauthenticated
35
+
36
+ - **A path that carries a credential is never an `AnonymousPaths` entry.** That includes MCP (`/mcp`),
37
+ OpenAI-compatible and other API surfaces (`/v1`), and anything else a caller presents a token,
38
+ key or secret to. An anonymous path is reachable by anyone who knows the URL; the proxy strips
39
+ identity from it and does not authenticate it.
40
+ - **`PassCallerAuthorizationPaths` is not a way around this.** Forwarding the caller's
41
+ `Authorization` header so the application verifies it moves authentication into the application.
42
+ Use it only for a request that signs itself with its own scheme (a webhook with a signature
43
+ header), never for a bearer token, API key or personal access token.
44
+ - **What may be anonymous:** health, static public content, a webhook receiver that verifies the
45
+ sender's signature, public metadata (`/.well-known/oauth-protected-resource*`, issuer metadata
46
+ and public keys) and an introspection endpoint that only reports whether a presented token is
47
+ active. Each entry names the narrowest prefix, and the reason sits beside it.
48
+
49
+ ## How a non-browser caller gets in
50
+
51
+ Declare the route on the AuthProxy so the proxy authenticates before the request is forwarded:
52
+
53
+ - **Bearer route with the product's Identity issuer.** `BearerRoutes` with `PathPrefix`, `Issuers`,
54
+ `Audiences` and `RequiredScopes`. The proxy validates the signature, `iss`, `aud`, `exp`/`nbf` and
55
+ scopes, reads the tenant from a single tenant claim, and forwards the principal. Set `Introspection`
56
+ on the issuer so a revoked token stops working within seconds. Each product runs its own Identity
57
+ instance at its own origin (for example `identity.<product host>`), with its own keys and accounts.
58
+ - **People sign in with authorization code and PKCE** (device flow where there is no browser). A
59
+ token pasted into a client is a fallback: short-lived, issued by Identity, never created by the
60
+ application.
61
+ - **Client credentials** in the application (a secret hash the proxy checks over a back channel) are
62
+ a transitional shape only. Do not add one; move an existing one to Identity when it can replace it.
63
+ - **Personal access tokens** (`PersonalAccessTokens`) are recognized by the proxy but not
64
+ authenticated by it, so the backend would have to authenticate each one. Do not use them.
65
+
66
+ ## Tenancy
67
+
68
+ - The organization comes from the token's tenant claim, resolved by the proxy (`Claim` strategy,
69
+ or `Route`/`Host`/`SubHost` constraints that refuse a token for another tenant with `403`). It
70
+ never comes from a header, a query string, a request body or a tool argument.
71
+ - A credential belongs to one tenant. Someone in several organizations holds one per organization.
72
+ - The application still enforces the tenant and membership it receives. That is authorization of
73
+ the forwarded identity, not authentication, and a second layer.
74
+
75
+ ## Prove it before shipping
76
+
77
+ - A Pulumi mock spec reads the rendered AuthProxy configuration and fails when a path that serves
78
+ a credential-bearing endpoint is in `AnonymousPaths` or `PassCallerAuthorizationPaths`.
79
+ - A spec or scan fails when application code reads the `Authorization` header or validates a JWT,
80
+ key or password on a request.
81
+ - Calling the endpoint through the proxy without a token gives `401`; with a token for another
82
+ tenant `403`; with a spoofed `x-cratis-tenant-id` or `x-ms-client-principal*` header the header
83
+ is ignored; a request that skips the proxy is refused by the network.
@@ -151,6 +151,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
151
151
  | Reading, citing and superseding a decision record | the **cratis-engineering-decision-record** skill |
152
152
  | Before any browser call: production permit, handoff, artifact paths, evidence | `browser.md` |
153
153
  | Whether you are allowed to do the thing you are able to do | `capability-is-not-authority.md` |
154
+ | Exposing an endpoint, API or MCP to callers that present a token; AuthProxy anonymous paths, bearer routes | `authentication-boundary.md` |
154
155
  | Before running a command that could print a credential, or when a secret value appears in output | `secrets.md` |
155
156
  | Session notes, plans and handovers (`.ai-work/` only) | `local-work-artifacts.md` |
156
157
  | Command wrappers, exact output and exit codes | `rtk.md`, then **cratis-rtk** |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.179.1",
3
+ "version": "7.179.2",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [