@fabrika/installation-init 0.9.0-dev.33 → 0.9.0-dev.35
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.
- package/package.json +6 -6
- package/src/index.ts +6 -1
- package/src/mcp.ts +47 -22
- package/src/proxy-manifest.ts +77 -22
- package/src/service-environment.ts +18 -9
- package/types/src/index.d.ts +3 -3
- package/types/src/mcp.d.ts +7 -1
- package/types/src/proxy-manifest.d.ts +48 -11
- package/types/src/service-environment.d.ts +9 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/installation-init",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^3.25.76",
|
|
31
|
-
"@fabrika/app": "0.9.0-dev.
|
|
32
|
-
"@fabrika/auth-core": "0.9.0-dev.
|
|
33
|
-
"@fabrika/email": "0.9.0-dev.
|
|
34
|
-
"@fabrika/iam-contract": "0.9.0-dev.
|
|
35
|
-
"@fabrika/proxy-core": "0.9.0-dev.
|
|
31
|
+
"@fabrika/app": "0.9.0-dev.35",
|
|
32
|
+
"@fabrika/auth-core": "0.9.0-dev.35",
|
|
33
|
+
"@fabrika/email": "0.9.0-dev.35",
|
|
34
|
+
"@fabrika/iam-contract": "0.9.0-dev.35",
|
|
35
|
+
"@fabrika/proxy-core": "0.9.0-dev.35"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,7 @@ export {
|
|
|
36
36
|
} from './environment'
|
|
37
37
|
export { ghRepoExists, hasGhCli } from './gh'
|
|
38
38
|
export { action, detail, fail, info, ok, step, url, warn } from './log'
|
|
39
|
-
export { type IamOAuthConfig, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp'
|
|
39
|
+
export { type IamOAuthConfig, mcpAuthoringOn, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp'
|
|
40
40
|
export { type CommandEnv, describeArgument, readEnv, readFlag, requiredSetting, setting, shellWord } from './options'
|
|
41
41
|
export { assertPinnedTag } from './pin'
|
|
42
42
|
export { confirm } from './prompt'
|
|
@@ -54,8 +54,12 @@ export {
|
|
|
54
54
|
} from './protection'
|
|
55
55
|
export {
|
|
56
56
|
type PlatformHosts,
|
|
57
|
+
type PlatformOAuthApp,
|
|
57
58
|
type PlatformOAuthResourceTemplate,
|
|
59
|
+
platformOAuthResourceVerifiedBy,
|
|
58
60
|
type PlatformOAuthScopeGrant,
|
|
61
|
+
platformOAuthServed,
|
|
62
|
+
type PlatformOAuthServedResource,
|
|
59
63
|
platformOrigin,
|
|
60
64
|
type PlatformProxyApp,
|
|
61
65
|
platformProxyAppFor,
|
|
@@ -87,6 +91,7 @@ export {
|
|
|
87
91
|
type InstallationAuthentication,
|
|
88
92
|
installationServiceEnvironment,
|
|
89
93
|
type InstallationServiceInput,
|
|
94
|
+
OPERATIONS_OAUTH_RESOURCE_VARIABLE,
|
|
90
95
|
type PlatformData,
|
|
91
96
|
type PlatformPlacementInput,
|
|
92
97
|
type PlatformService,
|
package/src/mcp.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
//
|
|
1
|
+
// IAM's OAuth configuration for an installation (ADR-0049): the command-line client's resources on every composition
|
|
2
|
+
// with an authorization server, and MCP authoring, opt-in, on top.
|
|
2
3
|
//
|
|
3
|
-
// The operator names the MCP clients it trusts; everything else is derived
|
|
4
|
-
//
|
|
5
|
-
//
|
|
4
|
+
// The operator names the MCP clients it trusts; everything else is derived from the same template the proxy manifest
|
|
5
|
+
// is resolved from, so the two cannot disagree: each `oauth` row's registered resource in the manifest, and IAM's
|
|
6
|
+
// `FABRIKA_IAM_OAUTH_CONFIG`, which issues tokens for exactly those resources.
|
|
6
7
|
|
|
7
|
-
import { type OAuthManagedClient, type OAuthResourceDto, parseOAuthManagedClient } from '@fabrika/iam-contract'
|
|
8
|
-
import { platformOAuthResourceUris, type PlatformProxyComposition, type PlatformProxyManifestTemplate } from './proxy-manifest'
|
|
8
|
+
import { OAUTH_CLIENT_PROVIDERS, type OAuthManagedClient, type OAuthResourceDto, parseOAuthManagedClient } from '@fabrika/iam-contract'
|
|
9
|
+
import { platformOAuthResourceUris, platformOAuthServed, type PlatformProxyComposition, type PlatformProxyManifestTemplate } from './proxy-manifest'
|
|
9
10
|
|
|
10
11
|
/** One operator-registered MCP client: its CIMD identity, plus where IAM fetches it when that differs. */
|
|
11
12
|
export interface McpClient extends OAuthManagedClient {
|
|
@@ -18,10 +19,12 @@ export interface IamOAuthConfig {
|
|
|
18
19
|
readonly resources: readonly OAuthResourceDto[]
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const CLIENT_KEYS = ['provider', 'clientId', 'redirectUris', 'metadataUrl']
|
|
22
|
+
const CLIENT_KEYS = ['provider', 'clientId', 'redirectUris', 'metadataUrl', 'identity']
|
|
22
23
|
/** IAM's own ceiling: it refuses to boot with more. */
|
|
23
24
|
const MAX_CLIENTS = 16
|
|
24
25
|
|
|
26
|
+
const PROVIDERS = OAUTH_CLIENT_PROVIDERS.map((provider) => `'${provider}'`).join(' | ')
|
|
27
|
+
|
|
25
28
|
const isObject = (value: unknown): value is Record<string, unknown> => typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
26
29
|
|
|
27
30
|
const isHttpsUrl = (value: string): boolean => {
|
|
@@ -36,7 +39,10 @@ const isHttpsUrl = (value: string): boolean => {
|
|
|
36
39
|
const parseClient = (value: unknown, index: number): McpClient => {
|
|
37
40
|
const client = parseOAuthManagedClient(value)
|
|
38
41
|
if (client === null || !isObject(value) || !Object.keys(value).every((key) => CLIENT_KEYS.includes(key))) {
|
|
39
|
-
throw new Error(
|
|
42
|
+
throw new Error(
|
|
43
|
+
`MCP client ${index} must be { provider: ${PROVIDERS}, clientId: <https URL>, redirectUris: [...], metadataUrl?, identity? }; `
|
|
44
|
+
+ 'identity is { app: <app id>, resource: <https URL> } and only on an external client',
|
|
45
|
+
)
|
|
40
46
|
}
|
|
41
47
|
const metadataUrl = value['metadataUrl']
|
|
42
48
|
if (metadataUrl === undefined) {
|
|
@@ -73,7 +79,15 @@ export const parseMcpClientsJson = (raw: string): readonly McpClient[] => {
|
|
|
73
79
|
return clients
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
/**
|
|
82
|
+
/** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
|
|
83
|
+
export const mcpAuthoringOn = (clients: readonly McpClient[] | undefined): boolean =>
|
|
84
|
+
clients?.some((client) => client.identity === undefined) ?? false
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* IAM's OAuth configuration for one placed installation: the MCP clients (none when MCP authoring is off; the
|
|
88
|
+
* command-line client is IAM's own and is never listed), and every resource the composition registers, each marked
|
|
89
|
+
* for the one kind of client it is served to.
|
|
90
|
+
*/
|
|
77
91
|
export const platformIamOAuthConfig = (
|
|
78
92
|
template: PlatformProxyManifestTemplate,
|
|
79
93
|
composition: PlatformProxyComposition,
|
|
@@ -81,22 +95,33 @@ export const platformIamOAuthConfig = (
|
|
|
81
95
|
): IamOAuthConfig => {
|
|
82
96
|
const resources: OAuthResourceDto[] = []
|
|
83
97
|
for (const app of template.apps) {
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
const served = platformOAuthServed(app, composition)
|
|
99
|
+
for (const { template: entry, cli } of served?.resources ?? []) {
|
|
100
|
+
const { resource } = platformOAuthResourceUris(composition, composition.placement[app.service].hosts, entry)
|
|
101
|
+
resources.push({
|
|
102
|
+
app: app.id,
|
|
103
|
+
resource,
|
|
104
|
+
...(entry.defaultScopes === undefined ? {} : { defaultScopes: [...entry.defaultScopes] }),
|
|
105
|
+
scopeGrants: entry.scopeGrants.map((grant) => ({
|
|
106
|
+
scope: grant.scope,
|
|
107
|
+
...(grant.parameter === undefined ? {} : { parameter: grant.parameter }),
|
|
108
|
+
permissions: grant.actions.map((action) => ({ action })),
|
|
109
|
+
})),
|
|
110
|
+
// IAM serves a resource to one kind of client: the command-line client's never reach an MCP client, nor MCP's it.
|
|
111
|
+
...(cli ? { client: 'cli' } : {}),
|
|
112
|
+
})
|
|
86
113
|
}
|
|
87
|
-
const { resource } = platformOAuthResourceUris(composition, composition.placement[app.service].hosts, app.oauthResource)
|
|
88
|
-
resources.push({
|
|
89
|
-
app: app.id,
|
|
90
|
-
resource,
|
|
91
|
-
defaultScopes: [...app.oauthResource.scopes],
|
|
92
|
-
scopeGrants: app.oauthResource.scopeGrants.map((grant) => ({
|
|
93
|
-
scope: grant.scope,
|
|
94
|
-
permissions: grant.actions.map((action) => ({ action })),
|
|
95
|
-
})),
|
|
96
|
-
})
|
|
97
114
|
}
|
|
98
115
|
if (resources.length === 0) {
|
|
99
|
-
throw new Error('the platform proxy manifest template declares no OAuth resource
|
|
116
|
+
throw new Error('the platform proxy manifest template declares no OAuth resource on this composition')
|
|
117
|
+
}
|
|
118
|
+
// An identity token must never be one a platform service accepts: not its app id, not a resource on its hosts.
|
|
119
|
+
const platformHosts = Object.values(composition.placement).flatMap((placement) => placement.hosts)
|
|
120
|
+
for (const { clientId, identity } of clients) {
|
|
121
|
+
if (identity === undefined) continue
|
|
122
|
+
if (template.apps.some((app) => app.id === identity.app) || platformHosts.includes(new URL(identity.resource).hostname)) {
|
|
123
|
+
throw new Error(`MCP client ${clientId}: its identity resource names a platform service's app id or host`)
|
|
124
|
+
}
|
|
100
125
|
}
|
|
101
126
|
return { clients, resources }
|
|
102
127
|
}
|
package/src/proxy-manifest.ts
CHANGED
|
@@ -40,22 +40,44 @@ export type PlatformHosts = Readonly<Record<PlatformProxyService, string>>
|
|
|
40
40
|
/** `https://<host>` — the origin a browser, a token's `iss` and a return-origin registry all use. */
|
|
41
41
|
export const platformOrigin = (scheme: 'http' | 'https', host: string): string => `${scheme}://${host}`
|
|
42
42
|
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* What one OAuth scope lets a token do: the owning app's actions, resolved by IAM at the token endpoint. With a
|
|
45
|
+
* `parameter` (a scope dimension), the scope is requested as `<scope>:<value>` and holds its actions at that value only.
|
|
46
|
+
*/
|
|
44
47
|
export interface PlatformOAuthScopeGrant {
|
|
45
48
|
readonly scope: string
|
|
49
|
+
readonly parameter?: string
|
|
46
50
|
readonly actions: readonly string[]
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
|
-
* A path an app serves to OAuth clients, protected only on
|
|
54
|
+
* A path an app serves to OAuth clients, protected only on a composition with an authorization server.
|
|
51
55
|
*
|
|
52
56
|
* The resource URI is the app's public origin plus `path`, so the template holds the path and a deploy
|
|
53
57
|
* binds the origin. Copied from the owning service module by the generator, like `table`.
|
|
54
58
|
*/
|
|
55
59
|
export interface PlatformOAuthResourceTemplate {
|
|
56
60
|
readonly path: string
|
|
61
|
+
/** The scopes the resource advertises (RFC 9728 `scopes_supported`). */
|
|
57
62
|
readonly scopes: readonly string[]
|
|
63
|
+
/** IAM's default scopes for a client that names none; never a parameterized one. */
|
|
64
|
+
readonly defaultScopes?: readonly string[]
|
|
58
65
|
readonly scopeGrants: readonly PlatformOAuthScopeGrant[]
|
|
66
|
+
/**
|
|
67
|
+
* The service the app forwards this path to, which verifies the token itself and so must be told the resource URI
|
|
68
|
+
* (`FABRIKA_OPERATIONS_OAUTH_RESOURCE`). Absent: the app's own service verifies it.
|
|
69
|
+
*/
|
|
70
|
+
readonly verifiedBy?: 'operations'
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** An app's OAuth half: what a composition with an authorization server publishes, and MCP authoring on top. */
|
|
74
|
+
export interface PlatformOAuthApp {
|
|
75
|
+
/** The command-line client's resources, registered on every composition with an authorization server. */
|
|
76
|
+
readonly resources: readonly PlatformOAuthResourceTemplate[]
|
|
77
|
+
/** The service's table then, without MCP. */
|
|
78
|
+
readonly table: InstallationEndpointTable
|
|
79
|
+
/** MCP authoring (ADR-0049), on a composition that enables it: its resource, and the service's table then. */
|
|
80
|
+
readonly mcp?: { readonly resource: PlatformOAuthResourceTemplate; readonly table: InstallationEndpointTable }
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
/**
|
|
@@ -77,15 +99,13 @@ export interface PlatformProxyApp {
|
|
|
77
99
|
readonly port: number
|
|
78
100
|
/** Where the proxy dials it over the project's private network. */
|
|
79
101
|
readonly upstream: string
|
|
80
|
-
/** The service's rows; with an `oauthResource`, the table served when the composition names an authorization server. */
|
|
81
|
-
readonly table: InstallationEndpointTable
|
|
82
|
-
/** Present only on an app that can serve OAuth clients; off unless the composition names an authorization server. */
|
|
83
|
-
readonly oauthResource?: PlatformOAuthResourceTemplate
|
|
84
102
|
/**
|
|
85
|
-
*
|
|
86
|
-
* same one, by the digest the deploy writes beside it (`platformServiceTableDigest`).
|
|
103
|
+
* The service's rows on a composition without an authorization server. Whichever table a composition publishes, the
|
|
104
|
+
* service picks the same one, by the digest the deploy writes beside it (`platformServiceTableDigest`).
|
|
87
105
|
*/
|
|
88
|
-
readonly
|
|
106
|
+
readonly table: InstallationEndpointTable
|
|
107
|
+
/** Present only on an app that can serve OAuth clients. */
|
|
108
|
+
readonly oauth?: PlatformOAuthApp
|
|
89
109
|
}
|
|
90
110
|
|
|
91
111
|
/** Everything about an installation's manifest that does not depend on WHICH installation it is. */
|
|
@@ -125,10 +145,12 @@ export interface PlatformProxyComposition {
|
|
|
125
145
|
readonly scheme: 'http' | 'https'
|
|
126
146
|
readonly placement: Readonly<Record<PlatformProxyService, PlatformProxyPlacement>>
|
|
127
147
|
/**
|
|
128
|
-
* The public IAM origin that issues OAuth tokens.
|
|
129
|
-
*
|
|
148
|
+
* The public IAM origin that issues OAuth tokens. Absent leaves every OAuth resource unregistered and serves each
|
|
149
|
+
* service's table without OAuth.
|
|
130
150
|
*/
|
|
131
151
|
readonly authorizationServer?: string
|
|
152
|
+
/** Whether MCP authoring is on (ADR-0049); it needs an authorization server. */
|
|
153
|
+
readonly mcp: boolean
|
|
132
154
|
/** The port browsers reach every app on, when it is not the scheme's default. The local composition's is 18080. */
|
|
133
155
|
readonly publicPort?: number
|
|
134
156
|
}
|
|
@@ -166,21 +188,51 @@ const registeredResource = (
|
|
|
166
188
|
scopesSupported: [...template.scopes],
|
|
167
189
|
})
|
|
168
190
|
|
|
169
|
-
/**
|
|
191
|
+
/** One resource an app serves on a composition, and whether only the command-line client is served it. */
|
|
192
|
+
export interface PlatformOAuthServedResource {
|
|
193
|
+
readonly template: PlatformOAuthResourceTemplate
|
|
194
|
+
/** True for the command-line client's resources, false for MCP's, which only the managed clients are served. */
|
|
195
|
+
readonly cli: boolean
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** An app's OAuth table and resources on this composition, or null when it serves no OAuth client. */
|
|
199
|
+
export const platformOAuthServed = (
|
|
200
|
+
app: PlatformProxyApp,
|
|
201
|
+
composition: Pick<PlatformProxyComposition, 'authorizationServer' | 'mcp'>,
|
|
202
|
+
): { readonly table: InstallationEndpointTable; readonly resources: readonly PlatformOAuthServedResource[] } | null => {
|
|
203
|
+
if (app.oauth === undefined || composition.authorizationServer === undefined) return null
|
|
204
|
+
const cli = app.oauth.resources.map((template) => ({ template, cli: true }))
|
|
205
|
+
const mcp = composition.mcp ? app.oauth.mcp : undefined
|
|
206
|
+
return mcp === undefined
|
|
207
|
+
? { table: app.oauth.table, resources: cli }
|
|
208
|
+
: { table: mcp.table, resources: [...cli, { template: mcp.resource, cli: false }] }
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The URI of the served resource `service` verifies the tokens of, or undefined when the composition serves none. */
|
|
212
|
+
export const platformOAuthResourceVerifiedBy = (
|
|
213
|
+
template: PlatformProxyManifestTemplate,
|
|
214
|
+
composition: PlatformProxyComposition,
|
|
215
|
+
service: 'operations',
|
|
216
|
+
): string | undefined => {
|
|
217
|
+
for (const app of template.apps) {
|
|
218
|
+
const entry = platformOAuthServed(app, composition)?.resources.find(({ template }) => template.verifiedBy === service)
|
|
219
|
+
if (entry !== undefined) return platformOAuthResourceUris(composition, composition.placement[app.service].hosts, entry.template).resource
|
|
220
|
+
}
|
|
221
|
+
return undefined
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Only a composition that names an authorization server registers an app's resources and serves its OAuth rows. */
|
|
170
225
|
const resolvedApp = (app: PlatformProxyApp, composition: PlatformProxyComposition): InstallationProxyApp => {
|
|
171
226
|
const placement = composition.placement[app.service]
|
|
172
227
|
const hosts = [...placement.hosts]
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const
|
|
228
|
+
const served = platformOAuthServed(app, composition)
|
|
229
|
+
const base = { id: app.id, hosts, upstream: placement.upstream ?? app.upstream, scheme: composition.scheme }
|
|
230
|
+
if (served === null || composition.authorizationServer === undefined) return { ...base, ...serviceProxyTable(app.table, { oauth: false }) }
|
|
231
|
+
const server = composition.authorizationServer
|
|
177
232
|
return {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
scheme: composition.scheme,
|
|
182
|
-
...serviceProxyTable(table, { oauth: registered !== undefined }),
|
|
183
|
-
...(registered === undefined ? {} : { oauthResources: [registered] }),
|
|
233
|
+
...base,
|
|
234
|
+
...serviceProxyTable(served.table, { oauth: true }),
|
|
235
|
+
oauthResources: served.resources.map(({ template }) => registeredResource(hosts, template, composition, server)),
|
|
184
236
|
}
|
|
185
237
|
}
|
|
186
238
|
|
|
@@ -194,6 +246,9 @@ export const resolvePlatformProxyManifest = (
|
|
|
194
246
|
template: PlatformProxyManifestTemplate,
|
|
195
247
|
composition: PlatformProxyComposition,
|
|
196
248
|
): PlatformProxyManifest => {
|
|
249
|
+
if (composition.mcp && composition.authorizationServer === undefined) {
|
|
250
|
+
throw new Error('MCP authoring needs an authorization server')
|
|
251
|
+
}
|
|
197
252
|
const manifest = parseProxyManifest({ apps: template.apps.map((app) => resolvedApp(app, composition)) })
|
|
198
253
|
// Every platform service is an installation entry, never an application.
|
|
199
254
|
const services = manifest?.apps.flatMap((app) => isApplicationEntry(app) ? [] : [app]) ?? []
|
|
@@ -22,8 +22,10 @@ export type PlatformService = 'iam' | 'operations' | 'control' | 'proxy'
|
|
|
22
22
|
/** Each service's variables, in the order they are written. */
|
|
23
23
|
export type PlatformServiceEnvironment = Readonly<Record<PlatformService, ReadonlyMap<string, string>>>
|
|
24
24
|
|
|
25
|
-
/** IAM's OAuth configuration
|
|
25
|
+
/** IAM's OAuth configuration (ADR-0049): written by every deploy of an installation that serves OAuth over https. */
|
|
26
26
|
export const IAM_OAUTH_CONFIG_VARIABLE = 'FABRIKA_IAM_OAUTH_CONFIG'
|
|
27
|
+
/** The console's Operations RPC as an OAuth resource, whose tokens Operations verifies (`platformOAuthResourceVerifiedBy`). */
|
|
28
|
+
export const OPERATIONS_OAUTH_RESOURCE_VARIABLE = 'FABRIKA_OPERATIONS_OAUTH_RESOURCE'
|
|
27
29
|
|
|
28
30
|
/** IAM's OIDC client secret, as IAM's Bun runtime reads it. The operator's credential: written sensitive, never generated. */
|
|
29
31
|
export const IAM_OIDC_CLIENT_SECRET_VARIABLE = 'OIDC_CLIENT_SECRET'
|
|
@@ -182,15 +184,18 @@ export interface DeployedServiceInput extends PlatformPlacementInput {
|
|
|
182
184
|
readonly provisioningKey: string
|
|
183
185
|
/** The digest of the console table the deploy's manifest publishes (`platformServiceTableDigest`). */
|
|
184
186
|
readonly controlTableDigest: string
|
|
185
|
-
/** Present
|
|
187
|
+
/** Present when the installation serves OAuth: the command-line client's resources, and MCP's when it is on. */
|
|
186
188
|
readonly oauthConfig?: IamOAuthConfig
|
|
189
|
+
/** Present with `oauthConfig`: the resource URI Operations accepts tokens for. */
|
|
190
|
+
readonly operationsOAuthResource?: string
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
/**
|
|
190
194
|
* The per-installation configuration a deploy writes, derived from where the installation answers.
|
|
191
195
|
*
|
|
192
|
-
* IAM's OAuth configuration is present
|
|
193
|
-
*
|
|
196
|
+
* IAM's OAuth configuration is present when the installation serves OAuth, and then rewritten by every deploy, so
|
|
197
|
+
* turning MCP off removes its resource and clients. Without it the variable is left as it is, and the manifest, whose
|
|
198
|
+
* rows then admit no OAuth token, is what turns OAuth off.
|
|
194
199
|
*/
|
|
195
200
|
export const deployedServiceEnvironment = (input: DeployedServiceInput): PlatformServiceEnvironment => {
|
|
196
201
|
const iamOrigin = platformOrigin(input.scheme, input.hosts.iam)
|
|
@@ -205,13 +210,17 @@ export const deployedServiceEnvironment = (input: DeployedServiceInput): Platfor
|
|
|
205
210
|
if (input.oauthConfig !== undefined) {
|
|
206
211
|
iam.set(IAM_OAUTH_CONFIG_VARIABLE, JSON.stringify(input.oauthConfig))
|
|
207
212
|
}
|
|
213
|
+
const operations = new Map([
|
|
214
|
+
['ENVIRONMENT', input.environment],
|
|
215
|
+
['FABRIKA_IAM_ISSUER', iamOrigin],
|
|
216
|
+
['FABRIKA_OPERATIONS_PUBLIC_HOST', input.hosts.operations],
|
|
217
|
+
])
|
|
218
|
+
if (input.operationsOAuthResource !== undefined) {
|
|
219
|
+
operations.set(OPERATIONS_OAUTH_RESOURCE_VARIABLE, input.operationsOAuthResource)
|
|
220
|
+
}
|
|
208
221
|
return {
|
|
209
222
|
iam,
|
|
210
|
-
operations
|
|
211
|
-
['ENVIRONMENT', input.environment],
|
|
212
|
-
['FABRIKA_IAM_ISSUER', iamOrigin],
|
|
213
|
-
['FABRIKA_OPERATIONS_PUBLIC_HOST', input.hosts.operations],
|
|
214
|
-
]),
|
|
223
|
+
operations,
|
|
215
224
|
proxy: new Map([
|
|
216
225
|
['ENVIRONMENT', input.environment],
|
|
217
226
|
['FABRIKA_IAM_ISSUER', iamOrigin],
|
package/types/src/index.d.ts
CHANGED
|
@@ -6,14 +6,14 @@ export { EMAIL_FLAGS, type InstallationEmail, readInstallationEmail } from './em
|
|
|
6
6
|
export { configureEnvironment, type EnvironmentConfig, type EnvironmentEffects, environmentVariables, type ExistingEnvironmentProtection, existingEnvironmentProtection, triggerPlatformWorkflow, } from './environment';
|
|
7
7
|
export { ghRepoExists, hasGhCli } from './gh';
|
|
8
8
|
export { action, detail, fail, info, ok, step, url, warn } from './log';
|
|
9
|
-
export { type IamOAuthConfig, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp';
|
|
9
|
+
export { type IamOAuthConfig, mcpAuthoringOn, type McpClient, parseMcpClientsJson, platformIamOAuthConfig } from './mcp';
|
|
10
10
|
export { type CommandEnv, describeArgument, readEnv, readFlag, requiredSetting, setting, shellWord } from './options';
|
|
11
11
|
export { assertPinnedTag } from './pin';
|
|
12
12
|
export { confirm } from './prompt';
|
|
13
13
|
export { branchProtectionCommand, DEPLOYMENT_BRANCH_POLICY, environmentPolicyCommand, environmentReviewerCommand, type GhAttempt, isPlanLimited, PLAN_LIMITED, probeSidecarBranchProtection, type ProtectionOutcome, protectSidecarBranch, } from './protection';
|
|
14
|
-
export { type PlatformHosts, type PlatformOAuthResourceTemplate, type PlatformOAuthScopeGrant, platformOrigin, type PlatformProxyApp, platformProxyAppFor, type PlatformProxyComposition, type PlatformProxyManifest, type PlatformProxyManifestTemplate, type PlatformProxyPlacement, type PlatformProxyService, platformServiceTableDigest, resolvePlatformProxyManifest, } from './proxy-manifest';
|
|
14
|
+
export { type PlatformHosts, type PlatformOAuthApp, type PlatformOAuthResourceTemplate, platformOAuthResourceVerifiedBy, type PlatformOAuthScopeGrant, platformOAuthServed, type PlatformOAuthServedResource, platformOrigin, type PlatformProxyApp, platformProxyAppFor, type PlatformProxyComposition, type PlatformProxyManifest, type PlatformProxyManifestTemplate, type PlatformProxyPlacement, type PlatformProxyService, platformServiceTableDigest, resolvePlatformProxyManifest, } from './proxy-manifest';
|
|
15
15
|
export { INITIAL_SCAFFOLD_COMMIT_MESSAGE, REFRESH_SCAFFOLD_COMMIT_MESSAGE, scaffoldSidecarRepository, type SidecarScaffoldEffects, type SidecarScaffoldInput, type SidecarScaffoldResult, } from './scaffold';
|
|
16
16
|
export { generateInstallationSecrets, generateSigningKeys, generateVaultKey, type InstallationSecrets, randomPxKey, randomSecret } from './secrets';
|
|
17
17
|
export { checkedSecretsFilePath, renderSecretsFile, SECRETS_FILE_FLAG, SECRETS_FILE_VARIABLE, writeSecretsFile } from './secrets-file';
|
|
18
|
-
export { deployedServiceEnvironment, type DeployedServiceInput, deriveIamProxySecret, IAM_OAUTH_CONFIG_VARIABLE, IAM_OIDC_CLIENT_SECRET_VARIABLE, INSTALLATION_SECRET_VARIABLES, type InstallationAuthentication, installationServiceEnvironment, type InstallationServiceInput, type PlatformData, type PlatformPlacementInput, type PlatformService, type PlatformServiceEnvironment, type PlatformStorage, } from './service-environment';
|
|
18
|
+
export { deployedServiceEnvironment, type DeployedServiceInput, deriveIamProxySecret, IAM_OAUTH_CONFIG_VARIABLE, IAM_OIDC_CLIENT_SECRET_VARIABLE, INSTALLATION_SECRET_VARIABLES, type InstallationAuthentication, installationServiceEnvironment, type InstallationServiceInput, OPERATIONS_OAUTH_RESOURCE_VARIABLE, type PlatformData, type PlatformPlacementInput, type PlatformService, type PlatformServiceEnvironment, type PlatformStorage, } from './service-environment';
|
|
19
19
|
export { attempt, capture, probe, run, type ShellAttempt, type ShellStep } from './shell';
|
package/types/src/mcp.d.ts
CHANGED
|
@@ -14,5 +14,11 @@ export interface IamOAuthConfig {
|
|
|
14
14
|
* client id is refused here, before a deploy writes a value IAM would refuse to boot with.
|
|
15
15
|
*/
|
|
16
16
|
export declare const parseMcpClientsJson: (raw: string) => readonly McpClient[];
|
|
17
|
-
/**
|
|
17
|
+
/** MCP authoring is on when the operator registers a client that is not identity-only: those sign people in, nothing more. */
|
|
18
|
+
export declare const mcpAuthoringOn: (clients: readonly McpClient[] | undefined) => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* IAM's OAuth configuration for one placed installation: the MCP clients (none when MCP authoring is off; the
|
|
21
|
+
* command-line client is IAM's own and is never listed), and every resource the composition registers, each marked
|
|
22
|
+
* for the one kind of client it is served to.
|
|
23
|
+
*/
|
|
18
24
|
export declare const platformIamOAuthConfig: (template: PlatformProxyManifestTemplate, composition: PlatformProxyComposition, clients: readonly McpClient[]) => IamOAuthConfig;
|
|
@@ -6,21 +6,45 @@ export type PlatformProxyService = 'iam' | 'control' | 'operations';
|
|
|
6
6
|
export type PlatformHosts = Readonly<Record<PlatformProxyService, string>>;
|
|
7
7
|
/** `https://<host>` — the origin a browser, a token's `iss` and a return-origin registry all use. */
|
|
8
8
|
export declare const platformOrigin: (scheme: "http" | "https", host: string) => string;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* What one OAuth scope lets a token do: the owning app's actions, resolved by IAM at the token endpoint. With a
|
|
11
|
+
* `parameter` (a scope dimension), the scope is requested as `<scope>:<value>` and holds its actions at that value only.
|
|
12
|
+
*/
|
|
10
13
|
export interface PlatformOAuthScopeGrant {
|
|
11
14
|
readonly scope: string;
|
|
15
|
+
readonly parameter?: string;
|
|
12
16
|
readonly actions: readonly string[];
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
|
-
* A path an app serves to OAuth clients, protected only on
|
|
19
|
+
* A path an app serves to OAuth clients, protected only on a composition with an authorization server.
|
|
16
20
|
*
|
|
17
21
|
* The resource URI is the app's public origin plus `path`, so the template holds the path and a deploy
|
|
18
22
|
* binds the origin. Copied from the owning service module by the generator, like `table`.
|
|
19
23
|
*/
|
|
20
24
|
export interface PlatformOAuthResourceTemplate {
|
|
21
25
|
readonly path: string;
|
|
26
|
+
/** The scopes the resource advertises (RFC 9728 `scopes_supported`). */
|
|
22
27
|
readonly scopes: readonly string[];
|
|
28
|
+
/** IAM's default scopes for a client that names none; never a parameterized one. */
|
|
29
|
+
readonly defaultScopes?: readonly string[];
|
|
23
30
|
readonly scopeGrants: readonly PlatformOAuthScopeGrant[];
|
|
31
|
+
/**
|
|
32
|
+
* The service the app forwards this path to, which verifies the token itself and so must be told the resource URI
|
|
33
|
+
* (`FABRIKA_OPERATIONS_OAUTH_RESOURCE`). Absent: the app's own service verifies it.
|
|
34
|
+
*/
|
|
35
|
+
readonly verifiedBy?: 'operations';
|
|
36
|
+
}
|
|
37
|
+
/** An app's OAuth half: what a composition with an authorization server publishes, and MCP authoring on top. */
|
|
38
|
+
export interface PlatformOAuthApp {
|
|
39
|
+
/** The command-line client's resources, registered on every composition with an authorization server. */
|
|
40
|
+
readonly resources: readonly PlatformOAuthResourceTemplate[];
|
|
41
|
+
/** The service's table then, without MCP. */
|
|
42
|
+
readonly table: InstallationEndpointTable;
|
|
43
|
+
/** MCP authoring (ADR-0049), on a composition that enables it: its resource, and the service's table then. */
|
|
44
|
+
readonly mcp?: {
|
|
45
|
+
readonly resource: PlatformOAuthResourceTemplate;
|
|
46
|
+
readonly table: InstallationEndpointTable;
|
|
47
|
+
};
|
|
24
48
|
}
|
|
25
49
|
/**
|
|
26
50
|
* One fronted app, in the form that is the same on every installation: protected by its service contract (ADR-0022
|
|
@@ -41,15 +65,13 @@ export interface PlatformProxyApp {
|
|
|
41
65
|
readonly port: number;
|
|
42
66
|
/** Where the proxy dials it over the project's private network. */
|
|
43
67
|
readonly upstream: string;
|
|
44
|
-
/** The service's rows; with an `oauthResource`, the table served when the composition names an authorization server. */
|
|
45
|
-
readonly table: InstallationEndpointTable;
|
|
46
|
-
/** Present only on an app that can serve OAuth clients; off unless the composition names an authorization server. */
|
|
47
|
-
readonly oauthResource?: PlatformOAuthResourceTemplate;
|
|
48
68
|
/**
|
|
49
|
-
*
|
|
50
|
-
* same one, by the digest the deploy writes beside it (`platformServiceTableDigest`).
|
|
69
|
+
* The service's rows on a composition without an authorization server. Whichever table a composition publishes, the
|
|
70
|
+
* service picks the same one, by the digest the deploy writes beside it (`platformServiceTableDigest`).
|
|
51
71
|
*/
|
|
52
|
-
readonly
|
|
72
|
+
readonly table: InstallationEndpointTable;
|
|
73
|
+
/** Present only on an app that can serve OAuth clients. */
|
|
74
|
+
readonly oauth?: PlatformOAuthApp;
|
|
53
75
|
}
|
|
54
76
|
/** Everything about an installation's manifest that does not depend on WHICH installation it is. */
|
|
55
77
|
export interface PlatformProxyManifestTemplate {
|
|
@@ -76,10 +98,12 @@ export interface PlatformProxyComposition {
|
|
|
76
98
|
readonly scheme: 'http' | 'https';
|
|
77
99
|
readonly placement: Readonly<Record<PlatformProxyService, PlatformProxyPlacement>>;
|
|
78
100
|
/**
|
|
79
|
-
* The public IAM origin that issues OAuth tokens.
|
|
80
|
-
*
|
|
101
|
+
* The public IAM origin that issues OAuth tokens. Absent leaves every OAuth resource unregistered and serves each
|
|
102
|
+
* service's table without OAuth.
|
|
81
103
|
*/
|
|
82
104
|
readonly authorizationServer?: string;
|
|
105
|
+
/** Whether MCP authoring is on (ADR-0049); it needs an authorization server. */
|
|
106
|
+
readonly mcp: boolean;
|
|
83
107
|
/** The port browsers reach every app on, when it is not the scheme's default. The local composition's is 18080. */
|
|
84
108
|
readonly publicPort?: number;
|
|
85
109
|
}
|
|
@@ -91,6 +115,19 @@ export declare const platformOAuthResourceUris: (composition: Pick<PlatformProxy
|
|
|
91
115
|
readonly resource: string;
|
|
92
116
|
readonly resourceMetadata: string;
|
|
93
117
|
};
|
|
118
|
+
/** One resource an app serves on a composition, and whether only the command-line client is served it. */
|
|
119
|
+
export interface PlatformOAuthServedResource {
|
|
120
|
+
readonly template: PlatformOAuthResourceTemplate;
|
|
121
|
+
/** True for the command-line client's resources, false for MCP's, which only the managed clients are served. */
|
|
122
|
+
readonly cli: boolean;
|
|
123
|
+
}
|
|
124
|
+
/** An app's OAuth table and resources on this composition, or null when it serves no OAuth client. */
|
|
125
|
+
export declare const platformOAuthServed: (app: PlatformProxyApp, composition: Pick<PlatformProxyComposition, "authorizationServer" | "mcp">) => {
|
|
126
|
+
readonly table: InstallationEndpointTable;
|
|
127
|
+
readonly resources: readonly PlatformOAuthServedResource[];
|
|
128
|
+
} | null;
|
|
129
|
+
/** The URI of the served resource `service` verifies the tokens of, or undefined when the composition serves none. */
|
|
130
|
+
export declare const platformOAuthResourceVerifiedBy: (template: PlatformProxyManifestTemplate, composition: PlatformProxyComposition, service: "operations") => string | undefined;
|
|
94
131
|
/**
|
|
95
132
|
* Bind a template to one composition and get the document the proxy actually parses.
|
|
96
133
|
*
|
|
@@ -7,8 +7,10 @@ import type { InstallationSecrets } from './secrets';
|
|
|
7
7
|
export type PlatformService = 'iam' | 'operations' | 'control' | 'proxy';
|
|
8
8
|
/** Each service's variables, in the order they are written. */
|
|
9
9
|
export type PlatformServiceEnvironment = Readonly<Record<PlatformService, ReadonlyMap<string, string>>>;
|
|
10
|
-
/** IAM's OAuth configuration
|
|
10
|
+
/** IAM's OAuth configuration (ADR-0049): written by every deploy of an installation that serves OAuth over https. */
|
|
11
11
|
export declare const IAM_OAUTH_CONFIG_VARIABLE = "FABRIKA_IAM_OAUTH_CONFIG";
|
|
12
|
+
/** The console's Operations RPC as an OAuth resource, whose tokens Operations verifies (`platformOAuthResourceVerifiedBy`). */
|
|
13
|
+
export declare const OPERATIONS_OAUTH_RESOURCE_VARIABLE = "FABRIKA_OPERATIONS_OAUTH_RESOURCE";
|
|
12
14
|
/** IAM's OIDC client secret, as IAM's Bun runtime reads it. The operator's credential: written sensitive, never generated. */
|
|
13
15
|
export declare const IAM_OIDC_CLIENT_SECRET_VARIABLE = "OIDC_CLIENT_SECRET";
|
|
14
16
|
/**
|
|
@@ -81,13 +83,16 @@ export interface DeployedServiceInput extends PlatformPlacementInput {
|
|
|
81
83
|
readonly provisioningKey: string;
|
|
82
84
|
/** The digest of the console table the deploy's manifest publishes (`platformServiceTableDigest`). */
|
|
83
85
|
readonly controlTableDigest: string;
|
|
84
|
-
/** Present
|
|
86
|
+
/** Present when the installation serves OAuth: the command-line client's resources, and MCP's when it is on. */
|
|
85
87
|
readonly oauthConfig?: IamOAuthConfig;
|
|
88
|
+
/** Present with `oauthConfig`: the resource URI Operations accepts tokens for. */
|
|
89
|
+
readonly operationsOAuthResource?: string;
|
|
86
90
|
}
|
|
87
91
|
/**
|
|
88
92
|
* The per-installation configuration a deploy writes, derived from where the installation answers.
|
|
89
93
|
*
|
|
90
|
-
* IAM's OAuth configuration is present
|
|
91
|
-
*
|
|
94
|
+
* IAM's OAuth configuration is present when the installation serves OAuth, and then rewritten by every deploy, so
|
|
95
|
+
* turning MCP off removes its resource and clients. Without it the variable is left as it is, and the manifest, whose
|
|
96
|
+
* rows then admit no OAuth token, is what turns OAuth off.
|
|
92
97
|
*/
|
|
93
98
|
export declare const deployedServiceEnvironment: (input: DeployedServiceInput) => PlatformServiceEnvironment;
|