R21.3: delete the unreachable registered-app resolution path
The runtime app-registration writer (POST /v1/apps) was deleted in an earlier pass because it minted a client_secret nobody verified. This pass kept resolveAppProfile's registered-app fallback and listAppProfiles on the theory that AppSlug is an open string and dynamic registration was a live extension point. Soul falsified that: every HTTP route enumerates the four built-in slugs in its own JSON schema (app.ts's `enum: [...appSlugs]` at every appSlug param/body field), so a registered row could never be resolved from a request. With the writer already gone, this was unreachable code behind a dead writer -- delete it rather than keep authenticating a door nobody can open. Deleted: src/app-registry.ts entirely (resolveAppProfile, listAppProfiles, isBuiltInApp, registeredAppToProfile, returnOriginsFromRedirectUris); StoredRegisteredApp and the findRegisteredApp/listRegisteredApps HeimdallStore methods (store/types.ts); their InMemoryStore and PostgresStore implementations, including seedRegisteredApp and mapRegisteredApp; the registered_apps table (store/schema.ts now drops it on any store built before this schema); tests/app-registry.test.ts. Every call site (app.ts x5, claims.ts, private-command-plane.ts) now calls the existing built-in-only getAppProfile (app-profiles.ts) directly -- sync, no store needed. If dynamic app registration is wanted later it returns as a designed, authenticated feature, not by resurrecting this vestige. Net -305 lines against the prior commit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
3427bdda1e
commit
e21659cd31
11 changed files with 33 additions and 338 deletions
15
src/app.ts
15
src/app.ts
|
|
@ -24,7 +24,6 @@ import {
|
|||
} from "./contracts.js";
|
||||
import { issueAccessClaim, type IssueAccessClaimInput } from "./claims.js";
|
||||
import { builtInAppProfiles, getAppProfile, isAllowedReturnOrigin, serializeAppProfile, supportsProvider } from "./app-profiles.js";
|
||||
import { listAppProfiles, resolveAppProfile } from "./app-registry.js";
|
||||
import { renderBrowserHandoffPage } from "./browser-handoff.js";
|
||||
import { type HeimdallConfig, loadConfig } from "./config.js";
|
||||
import { createTokenCustody, type TokenCustody } from "./custody.js";
|
||||
|
|
@ -429,7 +428,7 @@ async function evaluateStoredEntitlements(options: {
|
|||
entitlementPolicies: OAuthEntitlementPolicy[];
|
||||
now: string;
|
||||
}): Promise<string[]> {
|
||||
const profile = await resolveAppProfile(options.store, options.appSlug);
|
||||
const profile = getAppProfile(options.appSlug);
|
||||
if (!profile) {
|
||||
throw new Error(`Unknown app '${options.appSlug}'.`);
|
||||
}
|
||||
|
|
@ -530,8 +529,8 @@ export async function startOAuthFlow(
|
|||
trustedBrowserAttemptId?: string;
|
||||
}
|
||||
): Promise<HandlerResult> {
|
||||
const { config, keys, store } = ctx;
|
||||
const profile = await resolveAppProfile(store, input.appSlug);
|
||||
const { config, keys } = ctx;
|
||||
const profile = getAppProfile(input.appSlug);
|
||||
if (!profile) {
|
||||
return { statusCode: 404, body: { error: "unknown_app", detail: `No app '${input.appSlug}' is registered.` } };
|
||||
}
|
||||
|
|
@ -768,7 +767,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
app.get("/.well-known/heimdall-configuration", async () => buildDiscovery(config));
|
||||
|
||||
app.get("/v1/apps", async () => ({
|
||||
apps: (await listAppProfiles(store)).map(serializeAppProfile),
|
||||
apps: Object.values(builtInAppProfiles).map(serializeAppProfile),
|
||||
}));
|
||||
|
||||
app.get<{ Params: { appSlug: AppSlug } }>(
|
||||
|
|
@ -786,7 +785,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
},
|
||||
},
|
||||
async (request, reply) => {
|
||||
const profile = await resolveAppProfile(store, request.params.appSlug);
|
||||
const profile = getAppProfile(request.params.appSlug);
|
||||
if (!profile) {
|
||||
reply.code(404);
|
||||
return { error: "unknown_app", detail: `No app '${request.params.appSlug}' is registered.` };
|
||||
|
|
@ -1539,7 +1538,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
},
|
||||
},
|
||||
async (request, reply) => {
|
||||
const profile = await resolveAppProfile(store, request.params.appSlug);
|
||||
const profile = getAppProfile(request.params.appSlug);
|
||||
if (!profile) {
|
||||
reply.code(404);
|
||||
return { error: "unknown_app", detail: `No app '${request.params.appSlug}' is registered.` };
|
||||
|
|
@ -1690,7 +1689,7 @@ export async function buildApp(options: BuildAppOptions = {}): Promise<FastifyIn
|
|||
},
|
||||
},
|
||||
async (request, reply) => {
|
||||
const profile = await resolveAppProfile(store, request.params.appSlug);
|
||||
const profile = getAppProfile(request.params.appSlug);
|
||||
if (!profile) {
|
||||
reply.code(404);
|
||||
return { error: "unknown_app", detail: `No app '${request.params.appSlug}' is registered.` };
|
||||
|
|
|
|||
Loading…
Reference in a new issue