@cratis/pi 8.5.0 → 8.6.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 (217) hide show
  1. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +5 -3
  2. package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -1
  3. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -1
  4. package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +6 -3
  5. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +5 -2
  6. package/package/corpus/rules/glossary.md +5 -3
  7. package/package/corpus/rules/react.md +3 -1
  8. package/package/corpus/rules/reactors.md +3 -1
  9. package/package/corpus/rules/specs.csharp.md +6 -3
  10. package/package/corpus/rules/vertical-slices.md +5 -2
  11. package/package/corpus/skills/cratis-application-growth/SKILL.md +1 -2
  12. package/package/corpus/skills/cratis-application-growth/references/csharp.md +0 -2
  13. package/package/corpus/skills/cratis-application-growth/references/move-and-untangle.md +1 -2
  14. package/package/corpus/skills/cratis-application-growth/references/rename-window.md +1 -3
  15. package/package/corpus/skills/cratis-application-growth/references/service-and-delivery.md +3 -2
  16. package/package/corpus/skills/cratis-application-growth/references/stages.md +2 -2
  17. package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +2 -2
  18. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +19 -0
  19. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +15 -0
  20. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +12 -3
  21. package/package/corpus/skills/cratis-arc-declare-command/SKILL.md +2 -0
  22. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +46 -7
  23. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-controller.md +3 -1
  24. package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +4 -1
  25. package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +31 -4
  26. package/package/corpus/skills/cratis-arc-declare-command/references/go.md +1 -1
  27. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +24 -2
  28. package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +49 -0
  29. package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +3 -1
  30. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +27 -4
  31. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -0
  32. package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +49 -2
  33. package/package/corpus/skills/cratis-arc-generate-proxies/references/typescript.md +9 -0
  34. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  35. package/package/corpus/skills/cratis-arc-host-application/references/csharp-configuration.md +54 -0
  36. package/package/corpus/skills/cratis-arc-host-application/references/csharp-deployment.md +98 -0
  37. package/package/corpus/skills/cratis-arc-host-application/references/csharp-http.md +9 -1
  38. package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +84 -2
  39. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +2 -0
  40. package/package/corpus/skills/cratis-arc-invoke-command/references/csharp.md +2 -1
  41. package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +18 -1
  42. package/package/corpus/skills/cratis-arc-page-query/references/csharp.md +2 -0
  43. package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +18 -16
  44. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +8 -3
  45. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +84 -16
  46. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +22 -2
  47. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-instant-feedback.md +81 -0
  48. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +80 -0
  49. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-navigation.md +103 -0
  50. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +40 -1
  51. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-structure.md +117 -0
  52. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +7 -3
  53. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +3 -3
  54. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +27 -6
  55. package/package/corpus/skills/cratis-arc-validate-command/references/csharp-rules.md +23 -2
  56. package/package/corpus/skills/cratis-arc-validate-command/references/csharp.md +28 -2
  57. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +136 -0
  58. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +125 -0
  59. package/package/corpus/skills/cratis-authproxy-configure/references/aspire.md +154 -0
  60. package/package/corpus/skills/cratis-authproxy-configure/references/operations.md +122 -0
  61. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +114 -0
  62. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +126 -0
  63. package/package/corpus/skills/cratis-authproxy-configure/references/sign-in-providers.md +116 -0
  64. package/package/corpus/skills/cratis-authproxy-configure/references/tenant-resolution.md +135 -0
  65. package/package/corpus/skills/cratis-choreography-run-workflow/SKILL.md +117 -0
  66. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp-chronicle.md +164 -0
  67. package/package/corpus/skills/cratis-choreography-run-workflow/references/csharp.md +354 -0
  68. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +2 -2
  69. package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +28 -0
  70. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-services.md +13 -2
  71. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp.md +12 -0
  72. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -0
  73. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript.md +10 -1
  74. package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +8 -1
  75. package/package/corpus/skills/cratis-chronicle-constrain-append/references/csharp.md +35 -3
  76. package/package/corpus/skills/cratis-chronicle-constrain-append/references/go.md +1 -1
  77. package/package/corpus/skills/cratis-chronicle-constrain-append/references/operations.md +70 -0
  78. package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +2 -0
  79. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +27 -0
  80. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/container-and-kubernetes.md +293 -0
  81. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +13 -6
  82. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +45 -0
  83. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +91 -1
  84. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +9 -0
  85. package/package/corpus/skills/cratis-chronicle-evolve-event/SKILL.md +12 -0
  86. package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +11 -1
  87. package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +1 -1
  88. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
  89. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +14 -3
  90. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +3 -0
  91. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +3 -2
  92. package/package/corpus/skills/cratis-chronicle-project-view/references/csharp.md +23 -0
  93. package/package/corpus/skills/cratis-chronicle-project-view/references/elixir.md +1 -0
  94. package/package/corpus/skills/cratis-chronicle-project-view/references/go.md +2 -1
  95. package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +2 -0
  96. package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +1 -0
  97. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
  98. package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +2 -0
  99. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +40 -3
  100. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +20 -2
  101. package/package/corpus/skills/cratis-chronicle-protect-decision/references/elixir.md +7 -0
  102. package/package/corpus/skills/cratis-chronicle-protect-decision/references/go.md +9 -1
  103. package/package/corpus/skills/cratis-chronicle-protect-decision/references/java.md +8 -0
  104. package/package/corpus/skills/cratis-chronicle-protect-decision/references/kotlin.md +9 -0
  105. package/package/corpus/skills/cratis-chronicle-protect-decision/references/typescript.md +7 -0
  106. package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +24 -1
  107. package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +1 -1
  108. package/package/corpus/skills/cratis-chronicle-publish-contract/references/csharp.md +41 -0
  109. package/package/corpus/skills/cratis-chronicle-publish-contract/references/webhook-signature-wire-format.md +82 -0
  110. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +17 -0
  111. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-outputs.md +3 -1
  112. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +35 -2
  113. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/elixir.md +11 -0
  114. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -0
  115. package/package/corpus/skills/cratis-chronicle-react-to-fact/references/kotlin.md +1 -0
  116. package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +1 -1
  117. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-coordination.md +31 -2
  118. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp-history.md +21 -4
  119. package/package/corpus/skills/cratis-chronicle-record-event/references/csharp.md +20 -2
  120. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +1 -1
  121. package/package/corpus/skills/cratis-chronicle-record-event/references/java.md +1 -1
  122. package/package/corpus/skills/cratis-chronicle-record-event/references/kotlin.md +3 -0
  123. package/package/corpus/skills/cratis-chronicle-reduce-state/SKILL.md +2 -1
  124. package/package/corpus/skills/cratis-chronicle-reduce-state/references/csharp.md +3 -1
  125. package/package/corpus/skills/cratis-chronicle-reduce-state/references/java.md +10 -1
  126. package/package/corpus/skills/cratis-chronicle-reduce-state/references/kotlin.md +10 -1
  127. package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +27 -5
  128. package/package/corpus/skills/cratis-chronicle-select-client/SKILL.md +18 -0
  129. package/package/corpus/skills/cratis-chronicle-select-client/references/elixir.md +21 -1
  130. package/package/corpus/skills/cratis-chronicle-select-client/references/go.md +13 -0
  131. package/package/corpus/skills/cratis-chronicle-select-client/references/java.md +15 -0
  132. package/package/corpus/skills/cratis-chronicle-select-client/references/kotlin.md +15 -0
  133. package/package/corpus/skills/cratis-chronicle-select-client/references/typescript.md +16 -0
  134. package/package/corpus/skills/cratis-code-review/references/csharp-diagnostics.md +28 -2
  135. package/package/corpus/skills/cratis-code-review/references/csharp.md +1 -1
  136. package/package/corpus/skills/cratis-components-accessibility/SKILL.md +6 -8
  137. package/package/corpus/skills/cratis-components-accessibility/references/typescript.md +32 -14
  138. package/package/corpus/skills/cratis-components-build-canvas/SKILL.md +4 -3
  139. package/package/corpus/skills/cratis-components-build-canvas/references/typescript-props.md +1 -1
  140. package/package/corpus/skills/cratis-components-build-canvas/references/typescript.md +4 -2
  141. package/package/corpus/skills/cratis-components-choose-control/SKILL.md +13 -7
  142. package/package/corpus/skills/cratis-components-choose-control/references/from-primereact.md +116 -0
  143. package/package/corpus/skills/cratis-components-choose-control/references/menu.md +90 -0
  144. package/package/corpus/skills/cratis-components-choose-control/references/typescript-composition.md +48 -0
  145. package/package/corpus/skills/cratis-components-choose-control/references/typescript.md +2 -2
  146. package/package/corpus/skills/cratis-components-compose-toolbar/SKILL.md +2 -1
  147. package/package/corpus/skills/cratis-components-compose-toolbar/references/floating-toolbar.md +146 -0
  148. package/package/corpus/skills/cratis-components-diagnose-screen/SKILL.md +102 -0
  149. package/package/corpus/skills/cratis-components-display-list/SKILL.md +10 -10
  150. package/package/corpus/skills/cratis-components-display-list/references/typescript-custom-panel.md +74 -0
  151. package/package/corpus/skills/cratis-components-display-list/references/typescript-datatables.md +2 -7
  152. package/package/corpus/skills/cratis-components-display-list/references/typescript.md +3 -2
  153. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commandform.md +72 -2
  154. package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +5 -3
  155. package/package/corpus/skills/cratis-components-theme-application/SKILL.md +17 -15
  156. package/package/corpus/skills/cratis-components-theme-application/references/localization.md +166 -0
  157. package/package/corpus/skills/cratis-components-theme-application/references/typescript.md +18 -14
  158. package/package/corpus/skills/cratis-components-theme-application/references/upgrade-from-previous-major.md +141 -0
  159. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +2 -0
  160. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-domain-philosophy.md +31 -3
  161. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp-fundamentals-helpers.md +119 -0
  162. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/csharp.md +4 -0
  163. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +70 -0
  164. package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +8 -0
  165. package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -0
  166. package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +33 -0
  167. package/package/corpus/skills/cratis-fundamentals-name-value/references/csharp.md +2 -1
  168. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +5 -0
  169. package/package/corpus/skills/cratis-fundamentals-type-discovery/references/go-dependency-injection.md +3 -0
  170. package/package/corpus/skills/cratis-modeling-design-event-model/SKILL.md +6 -4
  171. package/package/corpus/skills/cratis-modeling-design-event-model/references/command-inventory.md +7 -1
  172. package/package/corpus/skills/cratis-modeling-design-event-model/references/model-first.md +13 -1
  173. package/package/corpus/skills/cratis-modeling-design-event-model/references/review-one-slice.md +6 -0
  174. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +6 -6
  175. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/csharp-aspire.md +116 -28
  176. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +2 -2
  177. package/package/corpus/skills/cratis-observability/references/chronicle-kernel-export.md +46 -0
  178. package/package/corpus/skills/cratis-orleans-jobs/SKILL.md +4 -2
  179. package/package/corpus/skills/cratis-platform-build-application/SKILL.md +8 -0
  180. package/package/corpus/skills/cratis-platform-build-application/references/cratis-identity.md +71 -0
  181. package/package/corpus/skills/cratis-platform-build-application/references/studio-repository.md +96 -0
  182. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +14 -8
  183. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +167 -3
  184. package/package/corpus/skills/cratis-platform-deliver-slice/references/eventual-consistency.md +150 -0
  185. package/package/corpus/skills/cratis-platform-diagnose-slice/SKILL.md +1 -1
  186. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +21 -0
  187. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +77 -3
  188. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +118 -0
  189. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +117 -0
  190. package/package/corpus/skills/cratis-platform-upgrade-application/references/java.md +53 -0
  191. package/package/corpus/skills/cratis-platform-upgrade-application/references/kotlin.md +53 -0
  192. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +71 -0
  193. package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +29 -0
  194. package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +82 -1
  195. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +1 -1
  196. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +10 -0
  197. package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +5 -4
  198. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/cli.md +19 -2
  199. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/smallest-model.md +87 -0
  200. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/typescript.md +13 -0
  201. package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/workspace-mcp.md +5 -0
  202. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +2 -0
  203. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-colocated.md +101 -0
  204. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +3 -1
  205. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-decision-reads.md +1 -0
  206. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +1 -0
  207. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +4 -2
  208. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +3 -3
  209. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +34 -1
  210. package/package/corpus/skills/cratis-specifications-exercise-backend/references/elixir.md +2 -0
  211. package/package/corpus/skills/cratis-specifications-isolate-behavior/SKILL.md +1 -1
  212. package/package/corpus/skills/cratis-specifications-isolate-behavior/references/csharp-running.md +10 -3
  213. package/package/corpus/skills/cratis-specifications-test-application-ui/references/typescript.md +22 -4
  214. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/SKILL.md +2 -1
  215. package/package/corpus/skills/cratis-specifications-test-typescript-behavior/references/typescript.md +40 -0
  216. package/package/profile-catalog.json +15 -0
  217. package/package.json +1 -1
@@ -0,0 +1,136 @@
1
+ ---
2
+ name: cratis-authproxy-configure
3
+ description: "Use when putting Cratis AuthProxy in front of an application or changing its configuration: sign-in providers, who is admitted, tenant resolution and switching, sessions and sign-out, routing to services, running it in production or under Aspire. Not for authorizing a command or query (`cratis-arc-authorize-request`) or reading identity in the backend (`cratis-arc-host-application`)."
4
+ ---
5
+
6
+ # Configure Cratis AuthProxy: the ingress that signs people in
7
+
8
+ ## Contents
9
+
10
+ - What AuthProxy owns
11
+ - Default path
12
+ - What the backend must do
13
+ - What a caller gets
14
+ - Decide by situation
15
+ - Reference index
16
+ - Anti-patterns
17
+ - Verify
18
+
19
+ ## What AuthProxy owns
20
+
21
+ Cratis AuthProxy is the default ingress for a Cratis application. It runs as its own container in front of the frontend and the backend. Nothing in the application references it.
22
+
23
+ | AuthProxy owns | The application owns |
24
+ |---|---|
25
+ | Sign-in at the identity provider, the session cookie, sign-out | No login page, no password or token handling |
26
+ | Who is admitted at all | Authorization of each command and query (`cratis-arc-authorize-request`) |
27
+ | Which tenant a request belongs to | What the tenant may see and do (`cratis-arc-isolate-tenant`) |
28
+ | Routing to the frontend and the backend | The answer on `/.cratis/me` for the signed-in person |
29
+
30
+ All configuration lives under `Cratis:AuthProxy`, in `appsettings.json` or as environment variables with `__` between segments (`Cratis__AuthProxy__Session__Lifetime`). Under Aspire the same settings are written by AppHost methods: see [references/aspire.md](references/aspire.md).
31
+
32
+ ## Default path
33
+
34
+ One application, one sign-in provider, one tenant. Run the `cratis/authproxy` image with:
35
+
36
+ ```json
37
+ {
38
+ "Cratis": {
39
+ "AuthProxy": {
40
+ "Authentication": {
41
+ "OidcProviders": [
42
+ {
43
+ "Name": "Microsoft",
44
+ "Type": "Microsoft",
45
+ "Authority": "https://login.microsoftonline.com/<tenant-id>/v2.0",
46
+ "ClientId": "<client-id>",
47
+ "ClientSecret": "<client-secret>"
48
+ }
49
+ ]
50
+ },
51
+ "TenantResolutions": [
52
+ { "Strategy": "Specified", "Options": { "TenantId": "acme" } }
53
+ ],
54
+ "Services": {
55
+ "main": {
56
+ "Backend": { "BaseUrl": "http://backend:8080/" },
57
+ "Frontend": { "BaseUrl": "http://frontend:3000/" }
58
+ }
59
+ }
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ 1. **Provider.** One entry signs people in. Register `https://<proxy-host>/signin-microsoft` as the redirect URI and `https://<proxy-host>/.cratis/logout/callback` as the post-logout redirect URI at the provider. Supply `ClientSecret` from a secret store.
66
+ 2. **Tenant.** At least one tenant resolution is required: the proxy refuses to start without one while a service uses the default identity verification. `Specified` fixes one tenant for the deployment.
67
+ 3. **Service.** `/api/...` goes to the backend, everything else to the frontend.
68
+ 4. **Admission.** Add a required claim when the provider signs in more people than should get in. See [references/admission.md](references/admission.md).
69
+
70
+ ## What the backend must do
71
+
72
+ 1. **Trust the forwarded identity.** Arc ignores identity headers until it is told to trust them. Enable that, and sign the hop so the backend can tell the proxy from any other caller. `cratis-arc-host-application` (identity reference) teaches the backend settings; under Aspire one AppHost call sets both sides.
73
+ 2. **Answer `/.cratis/me`.** After sign-in the proxy calls `GET /.cratis/me` on the backend. With the default `Required` verification only a positive answer admits the person; a refusal, an error or no answer in time keeps everyone out. Arc serves the endpoint. An identity details provider that returns `IsUserAuthorized: false` refuses the person.
74
+ 3. **Be reachable only through the proxy.** The proxy removes identity and tenant headers a caller sent and writes its own. A route around the proxy does neither.
75
+ 4. **Keep the default tenant header.** The proxy writes the tenant to `x-cratis-tenant-id`, which Arc reads by default.
76
+
77
+ ## What a caller gets
78
+
79
+ | Caller | Response |
80
+ |---|---|
81
+ | A browser navigating to a page, not signed in | Redirect to the provider, or the provider-selection page when several are configured |
82
+ | A `fetch`, command, query or API client without a session | `401`. Never a login page. |
83
+ | A signed-in person who is not admitted | `403` by default. When the application refuses a person who signed in through an OIDC provider set to `DenialResponse: FailedSignIn`, the session ends instead: a navigation is redirected to sign-in with a failed-sign-in notice, anything else gets `401`. |
84
+ | A signed-in person when a `Required` service cannot be asked | `503`. The session is kept; it is an outage, not a refusal. |
85
+ | A signed-in, admitted person | The request is forwarded with identity and tenant headers |
86
+
87
+ ## Decide by situation
88
+
89
+ | Situation | Do | Read |
90
+ |---|---|---|
91
+ | Add Microsoft, Google, GitHub or another provider | Declare it under `Authentication` | [sign-in-providers.md](references/sign-in-providers.md) |
92
+ | Only some people at the provider may enter | Require a claim | [admission.md](references/admission.md) |
93
+ | The application decides who may enter | Answer `/.cratis/me`; keep `Required` | [admission.md](references/admission.md) |
94
+ | Several tenants | Choose a resolution strategy | [tenant-resolution.md](references/tenant-resolution.md) |
95
+ | A person switches between tenants | `Selection` strategy and `/.cratis/select-tenant` | [tenant-resolution.md](references/tenant-resolution.md) |
96
+ | Add a sign-out link | Navigate to `/.cratis/logout` | [sessions-and-logout.md](references/sessions-and-logout.md) |
97
+ | A sensitive page needs a recent sign-in | `FreshAuthentication` on the path | [sessions-and-logout.md](references/sessions-and-logout.md) |
98
+ | Several applications behind one sign-in | Route by host, path prefix or header | [services-and-routing.md](references/services-and-routing.md) |
99
+ | A webhook or public page without sign-in | `AnonymousPaths` on the service | `cratis-arc-authorize-request` |
100
+ | A CLI, agent or other program calls the API | A bearer route | `cratis-arc-authorize-request` |
101
+ | The backend calls another API as the user | `AccessToken` on the service | [services-and-routing.md](references/services-and-routing.md) |
102
+ | A live query drops after minutes of silence | Raise `ActivityTimeout` | [services-and-routing.md](references/services-and-routing.md) |
103
+ | More than one replica, or people are signed out at restart | Share the data protection key ring | [operations.md](references/operations.md) |
104
+ | TLS ends at an ingress in front of the proxy | Declare trusted proxies | [operations.md](references/operations.md) |
105
+ | Health probes | Enable the management listener | [operations.md](references/operations.md) |
106
+ | The AppHost is Aspire | Use the AppHost methods | [aspire.md](references/aspire.md) |
107
+
108
+ ## Reference index
109
+
110
+ | Reference | Read when |
111
+ |---|---|
112
+ | [references/sign-in-providers.md](references/sign-in-providers.md) | Adding or changing a sign-in provider, registering callbacks, or offering sign-in by e-mail code. |
113
+ | [references/admission.md](references/admission.md) | Deciding who gets past the proxy: required claims, GitHub organizations and teams, the `/.cratis/me` verdict. |
114
+ | [references/tenant-resolution.md](references/tenant-resolution.md) | Choosing how the tenant is resolved, verifying it exists, or building a tenant switcher. |
115
+ | [references/sessions-and-logout.md](references/sessions-and-logout.md) | Setting session lifetime, adding sign-out, requiring a recent sign-in, or handling a `401` in the frontend. |
116
+ | [references/services-and-routing.md](references/services-and-routing.md) | Routing several services, limiting forwarded paths, reading the forwarded headers, or keeping long-lived connections open. |
117
+ | [references/operations.md](references/operations.md) | Deploying: key ring, ingress, health probes, TLS to the backend, custom pages, telemetry. |
118
+ | [references/aspire.md](references/aspire.md) | Wiring the proxy in an Aspire AppHost. |
119
+
120
+ ## Anti-patterns
121
+
122
+ - Building sign-in, session handling or token validation in the application.
123
+ - A backend that trusts forwarded identity while it is reachable around the proxy.
124
+ - A public host with a social provider and no admission requirement.
125
+ - Treating admission at the proxy as authorization of commands and queries.
126
+ - Sending `x-cratis-tenant-id` from the frontend to choose a tenant.
127
+ - Changing a service to `BestEffort` verification because `/.cratis/me` fails.
128
+ - Deploying several replicas without a shared key ring.
129
+
130
+ ## Verify
131
+
132
+ 1. Open the application in a private browser window: the provider's sign-in appears.
133
+ 2. After sign-in the application loads and shows the signed-in person.
134
+ 3. Call an API path without the session cookie: the answer is `401`, not a page.
135
+ 4. Sign in with an account that should not be admitted: the answer is `403`.
136
+ 5. Navigate to `/.cratis/logout`, then call an API path: the answer is `401`.
@@ -0,0 +1,125 @@
1
+ # Admission: who gets past the proxy
2
+
3
+ ## Contents
4
+
5
+ - Which gate decides
6
+ - Require a claim
7
+ - GitHub organizations and teams
8
+ - Narrow one service
9
+ - Let the application decide
10
+ - What a refused caller sees
11
+ - What the claim gate never covers
12
+ - Hide the deployment entirely
13
+ - Anti-patterns
14
+
15
+ ## Which gate decides
16
+
17
+ Signing in proves who a person is. It does not decide whether they may come in. A social provider signs in every account it has, so on a public host declare who is admitted.
18
+
19
+ | The decision depends on | Use |
20
+ |---|---|
21
+ | A claim the sign-in provider issues: a role, a group, a GitHub organization or team | [Required claims](#require-a-claim) in the proxy. The default. |
22
+ | Application data: an invitation, a subscription, a membership the application stores | The application's [identity details](#let-the-application-decide). |
23
+ | Both | Both. Each one can refuse on its own. |
24
+
25
+ These gates decide who reaches the application at all. Each command and query still declares its own authorization: see `cratis-arc-authorize-request`.
26
+
27
+ ## Require a claim
28
+
29
+ ```json
30
+ {
31
+ "Cratis": {
32
+ "AuthProxy": {
33
+ "Authorization": {
34
+ "RequiredClaims": [
35
+ { "Claim": "urn:github:organization", "AnyOf": [ "Acme" ] }
36
+ ]
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ - Several entries in `RequiredClaims` must all be satisfied.
44
+ - Several values in one `AnyOf` are alternatives; one match is enough.
45
+ - Without `AnyOf` the claim only has to be present. Use that when the provider issues the claim solely to the people who should get in.
46
+ - Values are compared case-insensitively.
47
+ - An entry with a blank `Claim` stops the proxy at startup.
48
+ - The gate is off until a requirement is declared.
49
+
50
+ ## GitHub organizations and teams
51
+
52
+ Add the `read:org` scope to the GitHub provider. The proxy then reads the person's organizations and teams during sign-in and adds them as claims:
53
+
54
+ | Claim | Value | Example |
55
+ |---|---|---|
56
+ | `urn:github:organization` | The organization's GitHub login | `Acme` |
57
+ | `urn:github:team` | `organization/team-slug` | `Acme/operations` |
58
+
59
+ Without the scope the claims are absent and every requirement on them refuses.
60
+
61
+ ## Narrow one service
62
+
63
+ The same block on a service applies in addition to the root requirements:
64
+
65
+ ```json
66
+ "Services": {
67
+ "admin": {
68
+ "Frontend": { "BaseUrl": "http://admin-web:3000/" },
69
+ "Authorization": {
70
+ "RequiredClaims": [
71
+ { "Claim": "urn:github:team", "AnyOf": [ "Acme/operations" ] }
72
+ ]
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ A service can narrow who reaches it, never widen it. The root requirements are a floor for every request that arrives on a proxy session. A bearer route is the one exception: with `IgnoreDeploymentRequiredClaims` it is held to its own `RequiredClaims` only, in place of the root and service requirements.
79
+
80
+ ## Let the application decide
81
+
82
+ After sign-in the proxy calls `GET /.cratis/me` on each service that has a `Backend` and has not set `ResolveIdentityDetails: false`. With the default `IdentityVerification: Required` the answer is the admission verdict for that person in that tenant:
83
+
84
+ - Only a positive answer admits.
85
+ - A refusal, an error or no answer within the timeout (10 seconds by default) keeps the person out.
86
+
87
+ In an Arc backend the answer comes from the identity details provider: `IsUserAuthorized: false` refuses. See `cratis-arc-host-application` (identity reference) for writing it.
88
+
89
+ | Setting on the service | Use when |
90
+ |---|---|
91
+ | `IdentityVerification: Required` (default) | The application decides who may enter. Fails closed. |
92
+ | `IdentityVerification: BestEffort` | The endpoint only adds display details. A `403` denies, and so does a call the proxy cannot sign when the service is set up for the signed hop. An unavailable service does not keep anyone out. |
93
+ | `ResolveIdentityDetails: false` | The service has no `/.cratis/me` at all. |
94
+
95
+ - A positive verdict is reused: `Session:IdentityRevalidationInterval` (10 minutes by default) bounds the verdict stored with the session, and `Session:IdentityResultCacheDuration` (30 seconds by default) bounds the proxy's in-memory copy. Removing a person's access does not take effect on the next request, and neither setting is an exact deadline. Lower both to shorten the delay.
96
+ - When a `Required` service cannot be asked, the person gets `503` and keeps the session. That is an outage, not a refusal.
97
+ - `Required` needs a tenant: the proxy refuses to start with a `Required` service and no entry in `TenantResolutions`. See [tenant-resolution.md](tenant-resolution.md).
98
+ - A `roles` field in the answer is ignored. Roles reach backends only from the sign-in provider's claims.
99
+
100
+ ## What a refused caller sees
101
+
102
+ | Caller | Response |
103
+ |---|---|
104
+ | A signed-in person who lacks a required claim | The not-authorized page with `403` and a sign-out link. |
105
+ | A bearer-route caller that lacks a required claim | `403` with the JSON body `{"error":"forbidden"}`. |
106
+ | A caller with no session | Not this gate: sign-in for a browser navigation, `401` for anything else. |
107
+
108
+ A caller refused by a required claim reaches nothing: no request is forwarded and `/.cratis/me` is not called. The proxy logs each refusal at warning level with the claim type that was not satisfied; look there first when someone is refused unexpectedly.
109
+
110
+ ## What the claim gate never covers
111
+
112
+ - **Paths in a service's `AnonymousPaths`.** They are public by declaration. Declare the narrowest prefix that works and let the application authorize what it serves there.
113
+ - **The proxy's own sign-in and sign-out endpoints.** A person must reach them to obtain the claims.
114
+
115
+ ## Hide the deployment entirely
116
+
117
+ By default the sign-in surface answers anyone, because a person has to reach it to sign in. For a deployment whose existence must not be discoverable, set `Admission:Mode` to `CapabilityOnly` and `Admission:Capability:VerifierUrl` to a verifier the deployment owns. The proxy then answers `404` to application paths, pages and the sign-in surface until a caller presents a capability the verifier admits. The management listener's health paths are not behind this gate. Admission decides whether anything is reachable; sign-in, required claims and tenancy apply unchanged afterwards. Use it only for that requirement.
118
+
119
+ ## Anti-patterns
120
+
121
+ - A public host with a social provider and neither a required claim nor a `Required` identity verdict. Every account at that provider gets in.
122
+ - Treating the proxy gate as the application's authorization. It is the first gate; operations still declare `[Authorize]` or roles.
123
+ - Returning roles from `/.cratis/me` and expecting them on the forwarded principal.
124
+ - Switching a service to `BestEffort` to get past a failing `/.cratis/me`. It admits exactly when the proxy knows least. Fix the endpoint.
125
+ - A broad prefix such as `/api` in `AnonymousPaths`. It opens every operation under it.
@@ -0,0 +1,154 @@
1
+ # AuthProxy in an Aspire AppHost
2
+
3
+ ## Contents
4
+
5
+ - Add the proxy
6
+ - Pair the backend
7
+ - Sign-in providers
8
+ - Admission
9
+ - Tenant resolution
10
+ - Services, hosts and paths
11
+ - Sessions and operations
12
+ - Settings without a method
13
+ - Anti-patterns
14
+
15
+ ## Add the proxy
16
+
17
+ Reference the `Cratis.AuthProxy.Aspire` package in the AppHost project. Its methods write the same `Cratis:AuthProxy` settings as environment variables, so every rule in the other references applies unchanged.
18
+
19
+ ```csharp
20
+ var authproxy = builder.AddAuthProxy("authproxy")
21
+ .WithHttpEndpoint(port: 8080)
22
+ .WithOidcProvider(
23
+ "Microsoft",
24
+ OidcProviderType.Microsoft,
25
+ authority: "https://login.microsoftonline.com/<tenant-id>/v2.0",
26
+ clientId: clientId,
27
+ clientSecret: clientSecret)
28
+ .WithSpecifiedTenantResolution("acme")
29
+ .WithBackend("main", api)
30
+ .WithSignedForwardingTo(api)
31
+ .WithFrontend("main", web);
32
+ ```
33
+
34
+ - `AddAuthProxy(name, tag)` runs the `cratis/authproxy` container image. `tag` defaults to `latest`; pin a version for anything that is deployed.
35
+ - `"main"` is the service name. `WithBackend` and `WithFrontend` with the same name form one service.
36
+ - Both take an optional `endpointName`, default `"http"`, that selects the endpoint of the target resource.
37
+ - During a local run the AppHost makes the proxy trust the local Aspire ingress. A published deployment declares its own with `WithTrustedProxies`.
38
+
39
+ ## Pair the backend
40
+
41
+ `WithSignedForwardingTo(api)` is the default for an Arc backend. It is a separate call; `WithBackend` does not imply it.
42
+
43
+ - It configures both sides: the proxy signs the identity it forwards, and the backend resource is set to trust forwarded identity and to accept only signed identity from this proxy.
44
+ - **Local run:** the AppHost generates a fresh key on every run. The run also selects the proxy's `LocalDevelopment` profile so the hop may use plain HTTP.
45
+ - **Publish:** no key is generated. Pass a secret parameter, provisioned with a base64-encoded, freshly generated 32-byte key, one per backend:
46
+
47
+ ```csharp
48
+ var apiSigningKey = builder.AddParameter("api-signing-key", secret: true);
49
+
50
+ authproxy
51
+ .WithBackend("main", api)
52
+ .WithSignedForwardingTo(api, signingKey: apiSigningKey);
53
+ ```
54
+
55
+ - Publishing without `signingKey` fails when the AppHost builds. A parameter that is not marked `secret: true` is refused.
56
+ - A published deployment also needs an HTTPS backend URL and a backend client certificate. See [operations.md](operations.md).
57
+ - A paired backend accepts no unsigned identity. Tools that switch identity by sending unsigned headers do not work against it; sign in through the proxy instead.
58
+
59
+ ## Sign-in providers
60
+
61
+ | Method | Use for |
62
+ |---|---|
63
+ | `WithOidcProvider(name, type, authority, clientId, clientSecret, scopes?)` | A provider with OpenID Connect discovery. `type` is `OidcProviderType.Microsoft`, `Google` or `Custom`. |
64
+ | `WithOAuthProvider(name, type, authorizationEndpoint, tokenEndpoint, userInformationEndpoint, clientId, clientSecret, scopes?, claimMappings?, ...)` | A provider without discovery, such as GitHub (`OidcProviderType.GitHub`). |
65
+
66
+ Call once per provider. Several providers give the provider-selection page. Pass client secrets from secret parameters or user secrets, not string literals. See [sign-in-providers.md](sign-in-providers.md).
67
+
68
+ ## Admission
69
+
70
+ | Method | Effect |
71
+ |---|---|
72
+ | `WithRequiredClaim(claim, anyOf...)` | A root requirement that applies to every service. |
73
+ | `WithRequiredClaimForService(serviceName, claim, anyOf...)` | An additional requirement for one service. |
74
+ | `WithIdentityVerification(serviceName, mode, timeout?)` | `IdentityVerificationMode.Required` (the default when not called) or `BestEffort`. |
75
+ | `WithBackend(serviceName, resource, resolveIdentityDetails: false)` | The service has no `/.cratis/me`. |
76
+ | `WithAnonymousPaths(serviceName, paths...)` | Paths served without a session. Calls accumulate. |
77
+ | `WithCapabilityOnlyAdmission(verifierUrl, ...)` | Hide the deployment until a capability is presented. |
78
+
79
+ ```csharp
80
+ authproxy.WithRequiredClaim("urn:github:organization", "Acme");
81
+ ```
82
+
83
+ See [admission.md](admission.md).
84
+
85
+ ## Tenant resolution
86
+
87
+ Strategies run in the order they are added.
88
+
89
+ | Method | Strategy |
90
+ |---|---|
91
+ | `WithSpecifiedTenantResolution(tenantId)` | `Specified` |
92
+ | `WithHostTenantResolution()` | `Host` |
93
+ | `WithSubHostTenantResolution()` | `SubHost` |
94
+ | `WithClaimTenantResolution(claimType?)` | `Claim` |
95
+ | `WithRouteTenantResolution(pattern)` | `Route` |
96
+ | `WithSelectionTenantResolution(resource, route)` or `(tenantsEndpoint)` | `Selection` |
97
+ | `WithDefaultTenantResolution(tenantId)` | `Default` |
98
+ | `WithTenantVerification(resource, routeTemplate)` or `(urlTemplate)` | Tenant verification, with `{tenantId}` in the template. |
99
+
100
+ - Prefer the overloads that take a resource: the endpoint address is resolved by Aspire, and a selectable-tenants endpoint on a paired backend is signed automatically.
101
+ - `WithSubHostTenantResolution()` adds the strategy without its `ParentHost` option, and without that option the strategy resolves nothing. Supply it as an environment variable, where the index is the strategy's position in the order added:
102
+
103
+ ```csharp
104
+ authproxy
105
+ .WithSubHostTenantResolution()
106
+ .WithEnvironment("Cratis__AuthProxy__TenantResolutions__0__Options__ParentHost", "example.com");
107
+ ```
108
+
109
+ - The tenant registry (`Tenants`) that `Host`, `Claim` and `Route` read has no method. Supply it as configuration.
110
+
111
+ See [tenant-resolution.md](tenant-resolution.md).
112
+
113
+ ## Services, hosts and paths
114
+
115
+ | Method | Effect |
116
+ |---|---|
117
+ | `WithHosts(serviceName, hosts...)` | Routes those hosts to the service. Calls append. |
118
+ | `WithPathPrefix(serviceName, pathPrefix, stripPathPrefix: false)` | Routes a path prefix to the service. |
119
+ | `WithSessionCookieDomain(domain)` | One sign-in for every host under the domain. |
120
+ | `WithSignInCallbackHost(host)` | Runs every sign-in handshake on one host. Requires the session cookie domain. |
121
+ | `WithActivityTimeout(timeout)`, `WithServiceActivityTimeout(serviceName, timeout)` | The idle limit for every service, or for one. The service value wins. |
122
+
123
+ See [services-and-routing.md](services-and-routing.md).
124
+
125
+ ## Sessions and operations
126
+
127
+ | Method | Effect |
128
+ |---|---|
129
+ | `WithFreshAuthentication(serviceName, path, maxAge?, prefix: false, methods...)` | Requires a recent sign-in for a path. |
130
+ | `WithoutIdentityDetailsCookie()` | Stops writing the readable `.cratis-identity` cookie. |
131
+ | `WithSessionTerminationOnIdentityDenial()` | A refusal from `/.cratis/me` also ends the proxy session. |
132
+ | `WithTrustedProxies(addressesOrCidrs...)`, `WithForwardLimit(hops)` | Declares the ingress in front of the proxy. |
133
+ | `WithManagementListener(port, ...)` | Enables the health endpoints on a private port. |
134
+ | `WithRequiredTlsOnIdentityHops()` | Requires HTTPS on every hop that carries identity. |
135
+
136
+ See [sessions-and-logout.md](sessions-and-logout.md) and [operations.md](operations.md).
137
+
138
+ ## Settings without a method
139
+
140
+ Any setting can be written directly with its environment-variable name, which is the configuration path with `__` between segments:
141
+
142
+ ```csharp
143
+ authproxy.WithEnvironment("Cratis__AuthProxy__Session__Lifetime", "08:00:00");
144
+ ```
145
+
146
+ Use this for the data protection store, `PagesPath`, `DeniedPaths`, `ForwardedPaths`, session lifetimes and anything else the tables above do not list.
147
+
148
+ ## Anti-patterns
149
+
150
+ - `WithBackend` without `WithSignedForwardingTo` for an Arc backend. The backend then cannot tell the proxy from any other caller on its network.
151
+ - Publishing with a signing key that is not a secret parameter, or reusing one key for several backends.
152
+ - `WithSubHostTenantResolution()` with no `ParentHost`.
153
+ - Hand-writing environment variables for something a method already covers.
154
+ - A literal client secret in the AppHost source.
@@ -0,0 +1,122 @@
1
+ # Running AuthProxy in production
2
+
3
+ ## Contents
4
+
5
+ - Production checklist
6
+ - Data protection key ring
7
+ - Behind an ingress or load balancer
8
+ - Health probes
9
+ - The hop to the backend
10
+ - Replace the built-in pages
11
+ - Telemetry
12
+ - Anti-patterns
13
+
14
+ ## Production checklist
15
+
16
+ 1. Run the `cratis/authproxy` image with a pinned version tag.
17
+ 2. Supply every secret (client secrets, signing keys, connection strings) from a secret store. Every setting has an environment-variable form: `Cratis:AuthProxy:Session:Lifetime` is `Cratis__AuthProxy__Session__Lifetime`.
18
+ 3. Persist and share the data protection key ring.
19
+ 4. Declare the ingress in front of the proxy as a trusted proxy.
20
+ 5. Enable the management listener and point liveness and readiness probes at it.
21
+ 6. Make the backend reachable only from the proxy, and sign the identity the proxy forwards.
22
+ 7. Leave `Cratis:AuthProxy:Profile` unset. `LocalDevelopment` is for a developer machine only.
23
+
24
+ ## Data protection key ring
25
+
26
+ The proxy encrypts its session cookie, its sign-in cookies and every token it issues with a key ring. Without a persisted, shared key ring:
27
+
28
+ - every restart signs everyone out, and
29
+ - with more than one replica, a request that lands on another replica cannot read the session, so people are signed out at random.
30
+
31
+ | Store | Use when | Setting |
32
+ |---|---|---|
33
+ | File system (default) | One instance, or replicas sharing a persistent volume. | `DataProtectionKeysPath`: a directory on a persistent volume, mounted at the same path in every replica. |
34
+ | Azure Blob Storage | The proxy runs on Azure and no volume should be managed. | `DataProtection:Store` = `AzureBlob`, `DataProtection:AzureBlob:BlobUri` |
35
+ | Redis | Redis is already running, or the proxy runs outside Azure. | `DataProtection:Store` = `Redis`, `DataProtection:Redis:ConnectionString` |
36
+
37
+ - With no path and no store, the key ring is neither persisted nor shared. That is acceptable only on a developer machine.
38
+ - Azure Blob Storage authenticates with the managed or workload identity of the proxy; there is no secret to configure. The container must exist, and the identity needs read and write access to the blob.
39
+
40
+ ## Behind an ingress or load balancer
41
+
42
+ The proxy learns the public scheme and the client address from `X-Forwarded-Proto` and `X-Forwarded-For`. It believes those headers only from peers declared in `Ingress:TrustedProxies`. With an empty list they are ignored from everyone.
43
+
44
+ ```json
45
+ "Ingress": {
46
+ "TrustedProxies": [ "10.0.0.0/8" ],
47
+ "ForwardLimit": 1
48
+ }
49
+ ```
50
+
51
+ - Each entry is an IP address or a CIDR range. Declare the addresses the proxy sees as its peer, not the addresses of users.
52
+ - `ForwardLimit` is the number of proxies a request passes through before it reaches the proxy. Set it when there is more than one.
53
+ - When TLS ends at the ingress and the ingress is not declared, the proxy sees plain HTTP: session cookies are written without `Secure`, the public origin used for sign-out is wrong, and bearer routes refuse every request.
54
+ - A sign-in callback sets several cookies in one response. Behind ingress-nginx, raise `proxy-buffer-size` to `16k`; the default of `4k` can answer `502` on the callback.
55
+
56
+ ## Health probes
57
+
58
+ The public port serves no health endpoint: a probe at a protected application path without a session gets `401`. Enable the management listener:
59
+
60
+ ```json
61
+ "Management": { "Port": 9110 }
62
+ ```
63
+
64
+ | Path | Answers |
65
+ |---|---|
66
+ | `/health/live` | `200` while the proxy is serving requests. Use for liveness. |
67
+ | `/health/ready` | `200` when this instance can serve traffic, `503` when it cannot. Use for readiness. |
68
+
69
+ - `Port` is required; there is no default port.
70
+ - The listener binds `127.0.0.1` by default, which only a process in the same pod or container reaches. A Kubernetes `httpGet` probe connects to the pod's IP, not to loopback: use an `exec` probe that runs inside the container, or set `BindAddress` to an address the kubelet reaches and restrict who else can reach the port.
71
+ - Readiness checks the key ring. It calls no backend, so a backend outage does not take the proxy out of rotation.
72
+ - The health paths exist only on the management port. With the listener enabled they answer `404` on the public port.
73
+
74
+ ## The hop to the backend
75
+
76
+ The backend trusts whatever arrives in the identity headers, so two things have to hold:
77
+
78
+ 1. **Nothing reaches the backend around the proxy.** Restrict the backend's listener to the proxy at the network level.
79
+ 2. **The backend can tell that the proxy wrote the headers.** Sign the forwarded identity: a `ForwardedIdentity` block on the service (`Audience`, `KeyId`, and `SecretBase64` from a secret store) and the matching verifier in the backend. See `cratis-arc-host-application` (identity reference) for the backend side and [aspire.md](aspire.md) for the one-call pairing.
80
+
81
+ Outside the `LocalDevelopment` profile a signed hop requires an HTTPS backend URL and a client certificate under `BackendTls`:
82
+
83
+ ```json
84
+ "BackendTls": {
85
+ "ClientCertificate": {
86
+ "CertificatePath": "/run/authproxy/backend/client.crt",
87
+ "KeyPath": "/run/authproxy/backend/client.key"
88
+ },
89
+ "TrustedCertificateAuthoritiesPath": "/run/authproxy/backend/ca-bundle.crt"
90
+ }
91
+ ```
92
+
93
+ - `TrustedCertificateAuthoritiesPath` is optional. When set, it replaces the system roots for backend hosts.
94
+ - `BackendTls:RequireTlsOnIdentityHops: true` requires HTTPS on every hop that carries identity, also without signing. It defaults to `false`.
95
+ - `Profile: LocalDevelopment` lets a signed hop use plain HTTP and no client certificate. It never belongs in a deployed environment.
96
+
97
+ ## Replace the built-in pages
98
+
99
+ The proxy ships pages for provider selection, tenant selection and errors. To replace them, mount a directory into the container and set `Cratis:AuthProxy:PagesPath` to the mount path. A file with the name of a built-in page replaces it:
100
+
101
+ | File | Shown when |
102
+ |---|---|
103
+ | `select-provider.html` | A person must choose a sign-in provider. |
104
+ | `select-tenant.html` | A person must choose a tenant. |
105
+ | `not-authorized.html` | A signed-in person lacks a required claim. |
106
+ | `403.html` | The application's identity verdict refused the person. |
107
+ | `no-organization.html` | A signed-in person belongs to no tenant. |
108
+ | `tenant-not-found.html` | Tenant verification did not confirm the tenant. |
109
+ | `service-unavailable.html` | The tenants endpoint could not answer. |
110
+
111
+ ## Telemetry
112
+
113
+ The proxy exports OpenTelemetry traces, metrics and logs over OTLP to the address in `OTEL_EXPORTER_OTLP_ENDPOINT`. A signal-specific variable such as `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` sets the address for that signal alone. Nothing is exported while none of them is set.
114
+
115
+ ## Anti-patterns
116
+
117
+ - More than one replica, or a platform without persistent disks, and no shared key ring.
118
+ - A liveness or readiness probe on the public port.
119
+ - An ingress that terminates TLS and is not declared in `TrustedProxies`.
120
+ - The `latest` image tag in a deployed environment.
121
+ - `Profile: LocalDevelopment` outside a developer machine.
122
+ - A backend that is reachable from the network without going through the proxy.
@@ -0,0 +1,114 @@
1
+ # Services and routing
2
+
3
+ ## Contents
4
+
5
+ - One service
6
+ - Several services behind one sign-in
7
+ - Limit which paths are forwarded
8
+ - What the backend receives
9
+ - The caller's Authorization header
10
+ - Machine callers
11
+ - Live connections, replicas and gRPC
12
+ - Anti-patterns
13
+
14
+ ## One service
15
+
16
+ A service is an entry under `Cratis:AuthProxy:Services` with a `Backend`, a `Frontend`, or both.
17
+
18
+ ```json
19
+ "Services": {
20
+ "main": {
21
+ "Backend": { "BaseUrl": "http://backend:8080/" },
22
+ "Frontend": { "BaseUrl": "http://frontend:3000/" }
23
+ }
24
+ }
25
+ ```
26
+
27
+ | Request | Goes to |
28
+ |---|---|
29
+ | `/api/...` | The backend |
30
+ | Everything else | The frontend |
31
+
32
+ - A single service that declares neither `Hosts` nor `PathPrefix` receives every request. No routing header is needed.
33
+ - A service with only a `Backend` receives every path on that route, so a backend that also serves the frontend's static files is declared with `Backend` alone.
34
+ - The proxy's own endpoints (`/.cratis/login`, `/.cratis/logout`, `/.cratis/select-tenant` and the others it answers itself) are never forwarded.
35
+
36
+ ## Several services behind one sign-in
37
+
38
+ With more than one service, each request has to name its service. Pick one way per service:
39
+
40
+ | Way | Declare | Use when |
41
+ |---|---|---|
42
+ | Host | `"Hosts": [ "portal.example.com" ]` | Each application has its own host. The default for separate applications. |
43
+ | Path prefix | `"PathPrefix": "/reporting"` | Several applications share a host. |
44
+ | Header or query parameter | Nothing in the proxy; the client sends `x-cratis-microservice: <service>` | Several Arc backends serve one frontend. |
45
+
46
+ - **Path prefix.** By default the service receives the path as requested and serves itself under the prefix. With `"StripPathPrefix": true` the prefix is removed and sent in `X-Forwarded-Prefix`. A `PathPrefix` cannot be `/api` or below it.
47
+ - **Header.** An Arc frontend sends `x-cratis-microservice` on HTTP requests, and as a query parameter on WebSocket and server-sent-event connections, when its `microservice` is set. See `cratis-arc-react-bind-slice` for the frontend setting. A service that has only a `Backend` and is selected this way receives `/api/...` only.
48
+ - A browser cannot put a header on a page navigation. A service whose pages a person opens directly needs a host or a path prefix.
49
+ - A sign-in on one host is not valid on another unless `Session:CookieDomain` is set. See [sessions-and-logout.md](sessions-and-logout.md).
50
+
51
+ ## Limit which paths are forwarded
52
+
53
+ Both lists belong to a service. Each entry is `{ "Path": "...", "Match": "Prefix" | "Exact", "Methods": [ ... ] }`; `Match` defaults to `Prefix` and an empty `Methods` matches every method.
54
+
55
+ | Setting | Effect | Use when |
56
+ |---|---|---|
57
+ | `DeniedPaths` | A matching path is never forwarded, also for a signed-in caller. It answers `404`. | The application has internal endpoints that must not be reachable from outside: diagnostics, an OpenAPI document. |
58
+ | `ForwardedPaths` | When the list has entries, only matching paths are forwarded. | Only a small surface of the service is exposed. |
59
+
60
+ - A matching deny rule always wins.
61
+ - Paths here are relative to the service, after `StripPathPrefix` has removed the prefix. `AnonymousPaths` entries are the public path, before stripping.
62
+ - `/` is valid only with `"Match": "Exact"`.
63
+ - `AnonymousPaths` opens paths to callers without a session. That decision, and bearer routes, are covered in `cratis-arc-authorize-request` (`references/authproxy.md`).
64
+
65
+ ## What the backend receives
66
+
67
+ | Header | Content |
68
+ |---|---|
69
+ | `x-ms-client-principal`, `x-ms-client-principal-id`, `x-ms-client-principal-name` | The authenticated caller. Arc reads these once it trusts forwarded identity. |
70
+ | `x-cratis-tenant-id` | The tenant the proxy resolved. |
71
+ | `x-cratis-microservice` | The service that routing selected as the destination. Not the value the caller sent. |
72
+
73
+ - The proxy removes every copy of these headers that the caller sent.
74
+ - `Tenant-ID` and `Service-ID` carry the same values and are deprecated. Read the `x-cratis-` names.
75
+ - On a bearer route the backend also receives `x-cratis-token-scope` (the granted scopes, space-separated) and `x-cratis-token-client-id` (the client the token was issued to). The client id is what the client asserts; a public client cannot prove which program uses it.
76
+ - On an anonymous path the proxy forwards no identity at all, also for a signed-in caller.
77
+
78
+ ## The caller's Authorization header
79
+
80
+ A request authenticated by the proxy session has the `Authorization` header the caller sent removed. A request with both a bearer token and the session cookie is refused: `401` on an ordinary protected path, `400` on a bearer route. A client sends one or the other.
81
+
82
+ | The backend needs | Set on the service |
83
+ |---|---|
84
+ | Only to know who the caller is | Nothing. The identity headers are enough. The default. |
85
+ | To call a downstream API as the signed-in person (Microsoft Graph, another API through the on-behalf-of flow) | `"AccessToken": { "Scopes": [ "api://reporting/access_as_user" ] }` |
86
+ | A non-bearer `Authorization` header the caller sent, unchanged | `"CallerAuthorizationHeader": "Forward"`. It never lets a bearer token through beside the session cookie. |
87
+
88
+ With `AccessToken` the proxy obtains a token for the backend's audience and forwards it as `Authorization: Bearer <token>`. It requires `Scopes` or `Resource`, a `Backend` on the service, and an OIDC provider that issues refresh tokens (request `offline_access`).
89
+
90
+ ## Machine callers
91
+
92
+ | Situation | Use |
93
+ |---|---|
94
+ | An authorization server already issues tokens for the callers | A bearer route on the service. The default. See `cratis-arc-authorize-request` (`references/authproxy.md`). |
95
+ | The application owns its client ids and secrets and there is no authorization server | `ClientCredentials` on the service. |
96
+
97
+ With `ClientCredentials` the proxy exposes `POST /.cratis/token` (`grant_type=client_credentials`, `client_id`, `client_secret`, and `service` when more than one service has client credentials). It sends the credentials to the service's `VerificationPath`; a `2xx` answer issues a bearer token valid on the service's `RoutePrefix` (default `/api`), together with a refresh token. The application stores and verifies the secrets; the proxy only issues and validates the tokens.
98
+
99
+ ## Live connections, replicas and gRPC
100
+
101
+ - **Idle limit.** `ActivityTimeout` is how long a request, WebSocket or server-sent-event stream may stay silent before the proxy cuts it. The default is five minutes. Set it at the root (`Cratis:AuthProxy:ActivityTimeout`), on a service, or on its `Backend` or `Frontend`; the most specific value wins.
102
+ - **Observable queries.** A live query that stays quiet longer than the limit is cut and the client reconnects. Raise the limit on that service when the reconnects are a problem, and raise the idle limit of whatever sits in front of the proxy as well: the shortest limit on the path wins.
103
+ - **A stream is authorized when it opens.** A person whose access is removed keeps an open stream until it closes.
104
+ - **Sticky routing.** `StickyRouting` on a `Backend` pins each browser to one replica. Use it only when the backend keeps per-replica caches. It is a cache hint, not a security boundary.
105
+ - **gRPC.** A gRPC backend needs `"Protocol": "Http2"` on its `Backend`. Behind an ingress that terminates TLS the proxy also needs its `GrpcListener`.
106
+
107
+ ## Anti-patterns
108
+
109
+ - Routing page navigations by `x-cratis-microservice`. A navigation carries no custom header; use `Hosts` or `PathPrefix`.
110
+ - Reading `Tenant-ID` or `Service-ID` in new backend code.
111
+ - Forwarding a token from the browser so the backend can call a downstream API. Use `AccessToken`.
112
+ - Hiding an internal endpoint by leaving it out of the frontend. Declare it in `DeniedPaths`.
113
+ - Sending a bearer token and the session cookie on the same request.
114
+ - Treating `x-cratis-token-client-id` as proof of which program is calling.