Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(control-ui): surface remote oauth immutables in the edit form (R3-H9)
Diego Zacariasa9001bfd29c0
diff --git a/control-ui/app/constants/oauthProviders.ts b/control-ui/app/constants/oauthProviders.tsindex ca7fc7346..3bf398bf6 100644--- a/control-ui/app/constants/oauthProviders.ts+++ b/control-ui/app/constants/oauthProviders.ts@@ -15,6 +15,7 @@ export const OAUTH_PROVIDER_LABELS: Record<string, string> = {clickup: 'ClickUp',vercel: 'Vercel',generic: 'Custom OAuth 2.0 provider',+ remote: 'Remote MCP server (auto-discovered)',}// Where the operator registers the OAuth app + redirect URI for each provider.diff --git a/control-ui/components/OAuthImmutableFields/index.tsx b/control-ui/components/OAuthImmutableFields/index.tsxindex f4623f261..0d914fa22 100644--- a/control-ui/components/OAuthImmutableFields/index.tsx+++ b/control-ui/components/OAuthImmutableFields/index.tsx@@ -4,6 +4,7 @@ import React from 'react'import { Field, TextInput } from '@components/ui'import { oauthProviderLabel } from '@constants/oauthProviders'import type { GenericImmutableView } from '@lib/oauthGeneric.types'+import type { RemoteImmutableView, RemoteSecretPosture } from '@lib/oauthRemote.types'import type { OAuthImmutableFieldsProps } from './types'const GRANT_SCOPE_LABELS: Record<string, string> = {@@ -11,6 +12,12 @@ const GRANT_SCOPE_LABELS: Record<string, string> = {context: 'Shared (context)',}+const REMOTE_SECRET_POSTURE_LABELS: Record<RemoteSecretPosture, string> = {+ referenced: 'Confidential (referenced Secret)',+ dynamic: 'Confidential (dynamic registration)',+ public: 'Public (no client secret)',+}+/*** Read-only display of an OAuth connector's immutable fields (D-B7). `id`,* `provider`, and `grantScope` are CEL-immutable on the mcpserver CRD — changing@@ -65,6 +72,7 @@ export function OAuthImmutableFields({ oauth, credentialSecretName }: OAuthImmut</Field>{oauth.generic ? <GenericImmutableFields generic={oauth.generic} /> : null}+ {oauth.remote ? <RemoteImmutableFields remote={oauth.remote} /> : null}</section>)}@@ -191,3 +199,105 @@ function GenericImmutableFields({ generic }: { generic: GenericImmutableView })</>)}++/**+ * The remote carril's discovered endpoints and wire knobs, read-only. Every field is+ * create-only (IMM-6): changing one means delete + recreate. `scopes` is editable (D-B6)+ * and lives elsewhere, so it is absent here.+ */+function RemoteImmutableFields({ remote }: { remote: RemoteImmutableView }) {+ return (+ <>+ <Field htmlFor="oauth-immutable-remote-client-mode" label="Client type">+ <TextInput+ id="oauth-immutable-remote-client-mode"+ value={REMOTE_SECRET_POSTURE_LABELS[remote.secretPosture]}+ readOnly+ disabled+ />+ </Field>++ <Field htmlFor="oauth-immutable-remote-issuer" label="Issuer">+ <TextInput+ id="oauth-immutable-remote-issuer"+ value={remote.issuer || '-'}+ readOnly+ disabled+ monospace+ />+ </Field>++ <Field htmlFor="oauth-immutable-remote-auth-endpoint" label="Authorization endpoint">+ <TextInput+ id="oauth-immutable-remote-auth-endpoint"+ value={remote.authorizationEndpoint || '-'}+ readOnly+ disabled+ monospace+ />+ </Field>++ <Field htmlFor="oauth-immutable-remote-token-endpoint" label="Token endpoint">+ <TextInput+ id="oauth-immutable-remote-token-endpoint"+ value={remote.tokenEndpoint || '-'}+ readOnly+ disabled+ monospace+ />+ </Field>++ {remote.registrationEndpoint ? (+ <Field htmlFor="oauth-immutable-remote-registration-endpoint" label="Registration endpoint">+ <TextInput+ id="oauth-immutable-remote-registration-endpoint"+ value={remote.registrationEndpoint}+ readOnly+ disabled+ monospace+ />+ </Field>+ ) : null}++ <Field htmlFor="oauth-immutable-remote-resource" label="Resource">+ <TextInput+ id="oauth-immutable-remote-resource"+ value={remote.resource || '-'}+ readOnly+ disabled+ monospace+ />+ </Field>++ {remote.issForCallback ? (+ <Field htmlFor="oauth-immutable-remote-iss-callback" label="Callback issuer (iss)">+ <TextInput+ id="oauth-immutable-remote-iss-callback"+ value={remote.issForCallback}+ readOnly+ disabled+ monospace+ />+ </Field>+ ) : null}++ <Field htmlFor="oauth-immutable-remote-bearer-in-body" label="Bearer token in body">+ <TextInput+ id="oauth-immutable-remote-bearer-in-body"+ value={YES_NO(remote.bearerInBody)}+ readOnly+ disabled+ />+ </Field>++ <Field htmlFor="oauth-immutable-remote-supports-refresh" label="Issues refresh tokens">+ <TextInput+ id="oauth-immutable-remote-supports-refresh"+ value={YES_NO(remote.supportsRefresh)}+ readOnly+ disabled+ />+ </Field>+ </>+ )+}diff --git a/control-ui/components/__tests__/OAuthImmutableFields.test.tsx b/control-ui/components/__tests__/OAuthImmutableFields.test.tsxindex f223ae0d7..46e4ebd31 100644--- a/control-ui/components/__tests__/OAuthImmutableFields.test.tsx+++ b/control-ui/components/__tests__/OAuthImmutableFields.test.tsx@@ -91,4 +91,81 @@ describe('OAuthImmutableFields — immutables read-only in edit (D-B7)', () => {expect(screen.queryByLabelText('Refresh endpoint')).toBeNull()expect(screen.queryByLabelText('Resource')).toBeNull()})++ it('renders the remote carril fields read-only with the confidential-referenced posture (IMM-6)', () => {+ render(+ <OAuthImmutableFields+ oauth={{+ id: 'client-conf',+ provider: 'remote',+ grantScope: 'user',+ remote: {+ clientMode: 'confidential',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ registrationEndpoint: 'https://as.example.com/register',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ issForCallback: 'https://as.example.com',+ bearerInBody: true,+ supportsRefresh: false,+ secretPosture: 'referenced',+ },+ }}+ />+ )+ // The synthetic remote provider label plus the discovered endpoints/knobs are shown…+ expect((screen.getByLabelText('Provider') as HTMLInputElement).value).toBe(+ 'Remote MCP server (auto-discovered)'+ )+ const issuer = screen.getByLabelText('Issuer') as HTMLInputElement+ const authEndpoint = screen.getByLabelText('Authorization endpoint') as HTMLInputElement+ const registration = screen.getByLabelText('Registration endpoint') as HTMLInputElement+ const clientType = screen.getByLabelText('Client type') as HTMLInputElement+ const bearer = screen.getByLabelText('Bearer token in body') as HTMLInputElement+ expect(issuer.value).toBe('https://as.example.com')+ expect(authEndpoint.value).toBe('https://as.example.com/authorize')+ expect(registration.value).toBe('https://as.example.com/register')+ expect(clientType.value).toBe('Confidential (referenced Secret)')+ expect(bearer.value).toBe('Yes')++ // …and every one is read-only + disabled (a change means delete + recreate).+ for (const input of [issuer, authEndpoint, registration, clientType, bearer]) {+ expect(input).toHaveAttribute('readonly')+ expect(input).toBeDisabled()+ }++ // scopes stays editable (D-B6), so no scopes control appears here.+ expect(screen.queryByLabelText('Scopes')).toBeNull()+ })++ it('labels a public remote client and omits absent optional endpoints', () => {+ render(+ <OAuthImmutableFields+ oauth={{+ id: 'client-pub',+ provider: 'remote',+ grantScope: 'user',+ remote: {+ clientMode: 'public',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ registrationEndpoint: '',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ issForCallback: '',+ bearerInBody: false,+ supportsRefresh: true,+ secretPosture: 'public',+ },+ }}+ />+ )+ expect((screen.getByLabelText('Client type') as HTMLInputElement).value).toBe(+ 'Public (no client secret)'+ )+ // Optional endpoints that the connector did not carry are not rendered as fields.+ expect(screen.queryByLabelText('Registration endpoint')).toBeNull()+ expect(screen.queryByLabelText('Callback issuer (iss)')).toBeNull()+ })})diff --git a/control-ui/lib/__tests__/oauthInstall.test.ts b/control-ui/lib/__tests__/oauthInstall.test.tsindex fea2da815..bd4109f6d 100644--- a/control-ui/lib/__tests__/oauthInstall.test.ts+++ b/control-ui/lib/__tests__/oauthInstall.test.ts@@ -265,4 +265,90 @@ describe('extractOAuthImmutables', () => {})expect(result?.generic?.clientMode).toBe('confidential')})++ // The `spec.oauth` fixtures below are a PROJECTION of control-api's remote producer+ // `buildRemoteOAuthSpec` (control-api/src/routes/admin/remoteMcp.ts) — control-ui cannot+ // import that module across services, so field names/types are derived from that producer,+ // not from a re-imagined contract. This is a projection test, not a cross-service+ // contract test (same limitation recorded when the discovery tests were renamed, R1-M4).+ it('surfaces a remote connector (source:remote, no provider) as non-null with remote fields', () => {+ // T3: before this fix extractOAuthImmutables returned null for a remote CR (it required+ // a `provider`, which the remote producer omits by REMOTE-FORBID-PROVIDER), so the edit+ // view rendered a remote connector in the non-OAuth credentials panel. It now returns a+ // synthetic `provider:'remote'` plus the read-only remote fields (D-B7).+ const result = extractOAuthImmutables({+ oauth: {+ source: 'remote',+ id: 'client-abc',+ clientMode: 'public',+ grantScope: 'user',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ scopes: ['mcp.read'],+ bearerInBody: false,+ supportsRefresh: true,+ },+ })+ expect(result).not.toBeNull()+ expect(result?.provider).toBe('remote')+ expect(result?.id).toBe('client-abc')+ expect(result?.grantScope).toBe('user')+ expect(result?.remote).toEqual({+ clientMode: 'public',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ registrationEndpoint: '',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ issForCallback: '',+ bearerInBody: false,+ supportsRefresh: true,+ secretPosture: 'public',+ })+ })++ it('reads the remote pre-registered confidential posture and optional endpoints', () => {+ // Pre-registered confidential: paired client refs present ⇒ 'referenced'. Optional+ // registrationEndpoint/issForCallback are surfaced when the producer wrote them.+ const result = extractOAuthImmutables({+ oauth: {+ source: 'remote',+ id: 'client-conf',+ clientMode: 'confidential',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ registrationEndpoint: 'https://as.example.com/register',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ issForCallback: 'https://as.example.com',+ bearerInBody: true,+ supportsRefresh: false,+ clientIdRef: { name: 'client-conf-oauth-client', key: 'client_id' },+ clientSecretRef: { name: 'client-conf-oauth-client', key: 'client_secret' },+ },+ })+ expect(result?.remote?.secretPosture).toBe('referenced')+ expect(result?.remote?.registrationEndpoint).toBe('https://as.example.com/register')+ expect(result?.remote?.issForCallback).toBe('https://as.example.com')+ expect(result?.remote?.bearerInBody).toBe(true)+ })++ it('reads the remote DCR posture (confidential, no refs) as dynamic', () => {+ const result = extractOAuthImmutables({+ oauth: {+ source: 'remote',+ id: 'client-dcr',+ clientMode: 'confidential',+ authorizationEndpoint: 'https://as.example.com/authorize',+ tokenEndpoint: 'https://as.example.com/token',+ issuer: 'https://as.example.com',+ resource: 'https://mcp.example.com',+ bearerInBody: false,+ supportsRefresh: true,+ },+ })+ expect(result?.remote?.secretPosture).toBe('dynamic')+ })})diff --git a/control-ui/lib/oauthInstall.ts b/control-ui/lib/oauthInstall.tsindex 984487f5e..4031267f1 100644--- a/control-ui/lib/oauthInstall.ts+++ b/control-ui/lib/oauthInstall.ts@@ -8,6 +8,8 @@ import type {OAuthInstallSubmit,OAuthReferenceSecretInput,} from './oauthInstall.types'+import { readRemoteImmutables } from './oauthRemote'+import type { RemoteImmutableView } from './oauthRemote.types'// Public callback base URL for the exact redirect URI (D-B4). It is a control-api// server env (CONTROL_API_OAUTH_CALLBACK_BASE_URL) and is NOT reachable from the@@ -171,13 +173,15 @@ export function scopesAreSatisfied(scopes: readonly string[]): boolean {// The OAuth fields that are CEL-immutable on the mcpserver CRD (D-B7): a change// means delete + recreate, so the edit form shows them read-only. `scopes` is// deliberately absent — it is editable (D-B6). `generic` is present only for the-// `source:'generic'` carril: its endpoints and wire knobs are all create-only-// (GENERIC-IMM / GENERIC-SECRET-IMM) and shown read-only alongside the base fields.+// `source:'generic'` carril and `remote` only for `source:'remote'`: each carril's+// endpoints and wire knobs are create-only (GENERIC-IMM / IMM-6) and shown read-only+// alongside the base fields.export type OAuthImmutableFields = {id: stringprovider: stringgrantScope: OAuthGrantScope | ''generic?: GenericImmutableView+ remote?: RemoteImmutableView}/**@@ -185,7 +189,9 @@ export type OAuthImmutableFields = {* read-only display in the edit form (D-B7). Returns null when the server carries* no OAuth block. A generic connector has no `provider` (it is discriminated by* `source:'generic'`, DEC-28); it is surfaced with a synthetic `provider:'generic'`- * label plus its read-only endpoints/knobs.+ * label plus its read-only endpoints/knobs. A remote connector likewise carries no+ * `provider` (REMOTE-FORBID-PROVIDER) and is discriminated by `source:'remote'`; it is+ * surfaced with a synthetic `provider:'remote'` label plus its read-only remote fields.*/export function extractOAuthImmutables(spec: Record<string, unknown> | null | undefined@@ -206,6 +212,15 @@ export function extractOAuthImmutables(}}+ if (oauth.source === 'remote') {+ return {+ id,+ provider: 'remote',+ grantScope,+ remote: readRemoteImmutables(oauth),+ }+ }+const provider = typeof oauth.provider === 'string' ? oauth.provider : ''if (!provider) return nullreturn { id, provider, grantScope }diff --git a/control-ui/lib/oauthRemote.ts b/control-ui/lib/oauthRemote.tsnew file mode 100644index 000000000..c570881c9--- /dev/null+++ b/control-ui/lib/oauthRemote.ts@@ -0,0 +1,51 @@+// Read the immutable fields of a `source:'remote'` connector for the read-only edit+// view (D-B7). The producer is control-api's `buildRemoteOAuthSpec`+// (src/routes/admin/remoteMcp.ts); this module mirrors the generic carril's+// `readGenericImmutables`. It owns no network and no React — each field is a direct,+// tolerant read off `spec.oauth`, never a decision.+import type {+ RemoteClientMode,+ RemoteImmutableView,+ RemoteSecretPosture,+} from './oauthRemote.types'++function asString(value: unknown): string {+ return typeof value === 'string' ? value : ''+}+function asBool(value: unknown): boolean {+ return value === true+}+function hasRef(value: unknown): boolean {+ return value !== undefined && value !== null+}++/**+ * Read the immutable remote knobs off an installed connector's `spec.oauth`. `clientMode`+ * comes straight from the CR (the remote flow writes it explicitly, unlike generic which+ * infers it). `secretPosture` is derived directly from the CR: paired client refs ⇒+ * pre-registered `'referenced'`; confidential with no refs ⇒ `'dynamic'` (DCR); otherwise+ * `'public'`. Tolerant of a malformed CR (missing/extra fields) — the edit view must never+ * crash on unexpected data.+ */+export function readRemoteImmutables(oauth: Record<string, unknown>): RemoteImmutableView {+ const clientMode: RemoteClientMode =+ oauth.clientMode === 'confidential' ? 'confidential' : 'public'+ const referenced = hasRef(oauth.clientSecretRef) || hasRef(oauth.clientIdRef)+ const secretPosture: RemoteSecretPosture = referenced+ ? 'referenced'+ : clientMode === 'confidential'+ ? 'dynamic'+ : 'public'+ return {+ clientMode,+ authorizationEndpoint: asString(oauth.authorizationEndpoint),+ tokenEndpoint: asString(oauth.tokenEndpoint),+ registrationEndpoint: asString(oauth.registrationEndpoint),+ issuer: asString(oauth.issuer),+ resource: asString(oauth.resource),+ issForCallback: asString(oauth.issForCallback),+ bearerInBody: asBool(oauth.bearerInBody),+ supportsRefresh: asBool(oauth.supportsRefresh),+ secretPosture,+ }+}diff --git a/control-ui/lib/oauthRemote.types.ts b/control-ui/lib/oauthRemote.types.tsnew file mode 100644index 000000000..abfa3ffa7--- /dev/null+++ b/control-ui/lib/oauthRemote.types.ts@@ -0,0 +1,34 @@+// Read-only projection types for the `source:'remote'` OAuth carril (DEC-28 / REMOTE-*).+// A remote connector is discovered against a live MCP server; control-api's+// `buildRemoteOAuthSpec` (src/routes/admin/remoteMcp.ts) writes `spec.oauth.source:'remote'`+// with NO `provider` (REMOTE-FORBID-PROVIDER) — the carril is discriminated by `source`.+// Nothing here is a decision module: each field is a direct read off the CR, mirroring+// how the generic carril projects its immutables.++// The confidential/public client selector, as written by the remote install flow.+export type RemoteClientMode = 'public' | 'confidential'++// The secret posture of a remote connector, read directly off the CR:+// - 'referenced': paired client refs present ⇒ pre-registered confidential; the client+// secret lives in the named K8s Secret.+// - 'dynamic': confidential with no refs ⇒ DCR; the secret lives in the encrypted+// `dynamic_clients` store, keyed by `oauth.id`.+// - 'public': a public client ⇒ no client secret at all (CIMD-public or DCR-public).+export type RemoteSecretPosture = 'referenced' | 'dynamic' | 'public'++// Read-only projection of an installed remote connector's `spec.oauth` for the edit view+// (D-B7). These are the fields IMM-6 marks create-only: a change means delete + recreate.+// `scopes` is deliberately absent — it is editable (D-B6). `id` (the client_id / callback+// coordinate) is surfaced by the shared base fields, not repeated here.+export type RemoteImmutableView = {+ clientMode: RemoteClientMode+ authorizationEndpoint: string+ tokenEndpoint: string+ registrationEndpoint: string+ issuer: string+ resource: string+ issForCallback: string+ bearerInBody: boolean+ supportsRefresh: boolean+ secretPosture: RemoteSecretPosture+}diff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex a640c8a4e..71a88bf82 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.659",+ "version": "0.1.660","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.659",+ "version": "0.1.660","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/frontend-components": "file:../packages/frontend-components",diff --git a/control-ui/package.json b/control-ui/package.jsonindex f0767b038..3aeb2ef84 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.659",+ "version": "0.1.660","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",