-
Notifications
You must be signed in to change notification settings - Fork 8
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
Open
rgarcia
wants to merge
12
commits into
main
Choose a base branch
from
rgarcia/managed-auth-mcp-app
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 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 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,89 @@ | ||
| // 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 Bun version pinned in | ||
| // .github/workflows/ci.yml (currently 1.3.3). Regenerate the bundle with that | ||
| // exact version: 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 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%;background:var(--color-background-primary,transparent)} | ||
| .kernel-app-loading,.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 class="kernel-app-loading">Preparing secure login…</div></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 }); | ||
| } |
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
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.