-
Notifications
You must be signed in to change notification settings - Fork 9
Add secure Managed Auth MCP App #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
6d1ab5d
feat: add managed auth MCP app
rgarcia d9f78be
feat: automatically resume agent after managed auth
rgarcia 8602a92
feat: add managed auth panel close control
rgarcia 116200a
feat: await managed auth without prompt injection
rgarcia 47e0830
fix: fail closed on non-Apps hosts, Bun-pinned CI, reauth wait guards
rgarcia 55b2569
fix: close Bugbot round-2 findings on managed-auth MCP app
rgarcia 7f5c6d2
fix: close Bugbot round-3 findings on managed-auth MCP app
rgarcia 0df1c59
fix: close Bugbot round-4 findings on managed-auth waits
rgarcia 2a40830
fix: close Bugbot round-5 findings on marker identity and relay JWTs
rgarcia b67c105
chore: scope PR to managed auth MCP app
rgarcia 1dec6d2
fix: close scoped managed-auth Bugbot findings
rgarcia 855a54e
fix: align managed auth app with guarded wait state
rgarcia f2a173b
fix: preserve non-app managed auth workflows
rgarcia 67d1758
fix: make managed auth app strictly additive
rgarcia e7753cd
Merge remote-tracking branch 'origin/main' into rgarcia/managed-auth-…
rgarcia eef1837
refactor: strictly additive manage_auth_connections and faithful App …
rgarcia cc5e74b
fix: harden managed auth capability and relay boundaries
rgarcia eb84e39
refactor: remove managed auth text-only launcher
rgarcia 53c01fa
fix: remove managed auth loading flash
rgarcia 9f8e329
fix: focus managed auth form fields
rgarcia 970d142
chore: version managed auth app resource
rgarcia f113e5a
feat: configure managed auth observability
rgarcia 20e1b36
Merge remote-tracking branch 'origin/main' into rgarcia/managed-auth-…
rgarcia 40a6b98
fix: harden managed auth app boundaries
rgarcia 0baec2a
Merge remote-tracking branch 'origin/main' into rgarcia/managed-auth-…
rgarcia d786e5d
fix: pin managed auth bundler for deploys
rgarcia f3f70ed
fix: order managed auth checkpoint events
rgarcia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| src/lib/mcp/apps/generated/managed-auth-app.ts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Builds the managed-auth MCP App into a single self-contained HTML bundle. | ||
| // The --check mode is byte-exact, and Bun's minifier output can change between | ||
| // releases, so the bundle is only reproducible with the exact Bun dependency | ||
| // pinned in package.json and matched by CI (currently 1.3.3). Production build | ||
| // checks the committed artifact; regeneration remains an explicit command: | ||
| // bun run build:managed-auth-app | ||
| import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; | ||
| import { tmpdir } from "node:os"; | ||
| import { join, resolve } from "node:path"; | ||
|
|
||
| const EXPECTED_BUN_VERSION = "1.3.3"; | ||
| if (Bun.version !== EXPECTED_BUN_VERSION) { | ||
| throw new Error( | ||
| `Managed-auth App bundling requires Bun ${EXPECTED_BUN_VERSION}; got ${Bun.version}. Run bun install and use the project-local bun binary.`, | ||
| ); | ||
| } | ||
|
|
||
| const root = resolve(import.meta.dirname, ".."); | ||
| const entrypoint = join(root, "src/lib/mcp/apps/managed-auth-entry.tsx"); | ||
| const generatedPath = join( | ||
| root, | ||
| "src/lib/mcp/apps/generated/managed-auth-app.ts", | ||
| ); | ||
| const check = process.argv.includes("--check"); | ||
| const temp = await mkdtemp(join(tmpdir(), "kernel-managed-auth-app-")); | ||
|
|
||
| try { | ||
| const build = await Bun.build({ | ||
| entrypoints: [entrypoint], | ||
| outdir: temp, | ||
| target: "browser", | ||
| format: "esm", | ||
| minify: true, | ||
| splitting: false, | ||
| sourcemap: "none", | ||
| define: { | ||
| "process.env.NODE_ENV": JSON.stringify("production"), | ||
| }, | ||
| }); | ||
|
|
||
| if (!build.success) { | ||
| for (const log of build.logs) console.error(log); | ||
| process.exitCode = 1; | ||
| } else { | ||
| let javascript = ""; | ||
| let css = ""; | ||
| for (const output of build.outputs) { | ||
| if (output.path.endsWith(".js")) javascript += await output.text(); | ||
| if (output.path.endsWith(".css")) css += await output.text(); | ||
| } | ||
| if (!javascript) | ||
| throw new Error("Bun did not emit managed-auth JavaScript"); | ||
|
|
||
| const escapeScript = (value) => value.replaceAll("</script", "<\\/script"); | ||
| const escapeStyle = (value) => value.replaceAll("</style", "<\\/style"); | ||
| const html = `<!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>Kernel Managed Authentication</title> | ||
| <style>${escapeStyle(css)} | ||
| html,body,#root{margin:0;min-height:100%} | ||
| html,body{background:transparent} | ||
| .kernel-app-status,.kernel-app-fallback{font-family:ui-sans-serif,system-ui,sans-serif;padding:16px;text-align:center} | ||
| .kernel-app-actions{display:flex;flex-direction:column;align-items:center;gap:8px;padding:0 16px 16px} | ||
| .kernel-app-button{appearance:none;border:0;border-radius:8px;background:#81b300;color:#fff;cursor:pointer;font:600 14px ui-sans-serif,system-ui,sans-serif;padding:10px 16px} | ||
| .kernel-app-button:hover{background:#709c00} | ||
| </style> | ||
| </head> | ||
| <body><div id="root"></div> | ||
| <script type="module">${escapeScript(javascript)}</script> | ||
| </body> | ||
| </html>`; | ||
| const generated = `// Generated by scripts/build-managed-auth-app.mjs. Do not edit.\nexport const MANAGED_AUTH_APP_HTML = ${JSON.stringify(html)};\n`; | ||
|
|
||
| if (check) { | ||
| let current = ""; | ||
| try { | ||
| current = await readFile(generatedPath, "utf8"); | ||
| } catch { | ||
| // Report the same actionable stale-bundle error below. | ||
| } | ||
| if (current !== generated) { | ||
| console.error( | ||
| "Managed-auth App bundle is stale. Run: bun run build:managed-auth-app", | ||
| ); | ||
| process.exitCode = 1; | ||
| } | ||
| } else { | ||
| await mkdir(resolve(generatedPath, ".."), { recursive: true }); | ||
| await writeFile(generatedPath, generated); | ||
| console.log(`Generated ${generatedPath}`); | ||
| } | ||
| } | ||
| } finally { | ||
| await rm(temp, { recursive: true, force: true }); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.