Repository navigation
feat(tokens): API keys that open one namespace alone - #415
Merged
Merged
Conversation
An API key can be made for one namespace (namespace on POST /api/v1/tokens, or Opens on the API tokens page, which Connect apps fills in). It authenticates only on that namespace's own MCP server and chat completions, with its maker's role there, and is refused (401) everywhere else in Lens. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LB2qrE7CENSd3G5h4FxFra
Merged
16 of 22 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Requested by Adeel · project thread
Description
Before: an app given a Lens API key to call one namespace's chat completions or MCP server could use that key anywhere in Lens, with every namespace its maker can read.
After: an API key can be made for one namespace. It opens that namespace's own MCP server (
/mcp/<namespace>) and chat completions (/api/v1/namespaces/<namespace>/chat/completionsand/models), with its maker's role there, and is refused (401) everywhere else, so an app given it can't read other namespaces or make keys. On the API tokens page it is the new Opens field (default: everything you can read, as before). Connect apps on the namespace page links to the form with the namespace filled in and the name suggested ("pods app key").How:
POST /api/v1/tokenstakes an optionalnamespace; the key stores the namespace's id. Token lists shownamespace(empty when that namespace is gone).deps._resolvesetsPrincipal.spacefrom the key. On any path other than that namespace's own servers (deps.serves), the key authenticates as no one, with the reason in the 401 (deps.signed_out). On those paths the person's roles are narrowed withdeps.within, so a lost role or a deleted namespace opens nothing.Acl.namespace), and it is audited with the namespace.This is PR 3 of 3 for the thread, after #401 (an MCP server for each namespace) and #413 (chat completions for one namespace).
Motivation and Context
Adeel asked for per-namespace scoped MCP servers and chat completions, so any general app can be integrated easily. A key that opens one namespace alone means the app is scoped too, not only the endpoint.
Types of changes
!in the title)Checklist:
make hookschecks it on commit).tests/api/test_namespace_keys.py,__tests__/tokens-page.test.tsx,__tests__/connect-apps.test.tsx).docs/accordingly (docs/authentication.md,docs/api.md,docs/mcp.md).## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
POST /api/v1/tokenswithnamespace./mcp/<namespace>row, P-ROLE).api_token(space). Its absence means every namespace, as before, so no upgrade step is needed.make openapiregenerated the client. The full backend suite (1108) and jest (892) pass locally.lo_) chosen for one namespace at sign-in, not only by its resource.🤖 Generated with Claude Code
https://claude.ai/code/session_01LB2qrE7CENSd3G5h4FxFra
Generated by Claude Code