mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-18 09:45:23 +00:00
feat(proxy): general_settings.claude_code_marketplace_auth_required requires a LiteLLM key for the Claude Code marketplace
When true, GET /claude-code/marketplace.json answers 401 without a key in Authorization, x-litellm-api-key, the litellm_key_header_name header, or ?key=, and GET /public/skill_hub returns an empty list. Both routes' 500 bodies carry a fixed message instead of the exception text.
This commit is contained in:
parent
7053226795
commit
ec13e2821f
5 changed files with 53 additions and 12 deletions
|
|
@ -7741,7 +7741,7 @@
|
|||
"paths": {
|
||||
"/claude-code/marketplace.json": {
|
||||
"get": {
|
||||
"description": "Serve marketplace.json for Claude Code plugin discovery.\n\nThis endpoint is accessed by Claude Code CLI when users run:\n- claude plugin marketplace add <url>\n- claude plugin install <name>@<marketplace>\n\nWithout `key` the catalog holds the enabled (public) plugins. With `?key=sk-...`\nthe key is authenticated and the catalog also holds the disabled plugins granted\nto it through `object_permission.skills` or an access group on the key or its team.\n\nReturns:\n Marketplace catalog with list of available plugins and their git sources.\n\nExample:\n ```bash\n claude plugin marketplace add http://localhost:4000/claude-code/marketplace.json\n claude plugin marketplace add \"http://localhost:4000/claude-code/marketplace.json?key=sk-...\"\n claude plugin install my-plugin@litellm\n ```",
|
||||
"description": "Serve marketplace.json for Claude Code plugin discovery.\n\nThis endpoint is accessed by Claude Code CLI when users run:\n- claude plugin marketplace add <url>\n- claude plugin install <name>@<marketplace>\n\nWithout a key the catalog holds the enabled (public) plugins. With `?key=sk-...`\nthe key is authenticated and the catalog also holds the disabled plugins granted\nto it through `object_permission.skills` or an access group on the key or its team.\n\nWith `general_settings.claude_code_marketplace_auth_required: true` a caller with\nno key gets a 401, and the key may also come in the `Authorization` or\n`x-litellm-api-key` header (Claude Code sends them from the marketplace's `headers`).\n\nReturns:\n Marketplace catalog with list of available plugins and their git sources.\n\nExample:\n ```bash\n claude plugin marketplace add http://localhost:4000/claude-code/marketplace.json\n claude plugin marketplace add \"http://localhost:4000/claude-code/marketplace.json?key=sk-...\"\n claude plugin install my-plugin@litellm\n ```",
|
||||
"operationId": "get_marketplace_claude_code_marketplace_json_get",
|
||||
"parameters": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2822,6 +2822,10 @@ class ConfigGeneralSettings(LiteLLMPydanticObjectBase):
|
|||
None,
|
||||
description="If True, stores request messages and responses in spend logs. Default is False.",
|
||||
)
|
||||
claude_code_marketplace_auth_required: bool = Field(
|
||||
False,
|
||||
description="If True, GET /claude-code/marketplace.json requires a LiteLLM key (Authorization or x-litellm-api-key header, the litellm_key_header_name header, or ?key=) and answers 401 without one, and GET /public/skill_hub returns an empty list. Default is False, which serves the enabled plugins to anyone.",
|
||||
)
|
||||
disable_requester_ip_address_logging: bool | None = Field(
|
||||
None,
|
||||
description="If True, new spend log rows store requester_ip_address as null in the column, the metadata and the stored request. The stored request also drops client-IP forwarding headers such as x-forwarded-for, and IP addresses in its other header values and in stored error messages are masked. Guardrails, metrics and callbacks that read the standard logging payload still receive the IP. Default is False.",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ Actual plugin files are hosted on GitHub/GitLab/Bitbucket or as a zip archive on
|
|||
any HTTPS host (S3, Artifactory, a static file server).
|
||||
|
||||
Endpoints:
|
||||
/claude-code/marketplace.json - GET - List plugins for Claude Code discovery (unauthenticated; `?key=` adds the key's granted skills)
|
||||
/claude-code/marketplace.json - GET - List plugins for Claude Code discovery (anonymous unless
|
||||
general_settings.claude_code_marketplace_auth_required; a key adds its granted skills)
|
||||
/claude-code/plugins - POST - Register a new plugin (create-only, proxy admin only)
|
||||
/claude-code/plugins - GET - List plugins visible to the key (enabled, plus granted disabled ones)
|
||||
/claude-code/plugins/{name} - GET - Get plugin details (403 on a disabled plugin the key is not granted)
|
||||
|
|
@ -38,6 +39,7 @@ from litellm.proxy.anthropic_endpoints.claude_code_endpoints.claude_code_skill_a
|
|||
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
|
||||
from litellm.proxy.common_utils.resource_ownership import is_proxy_admin
|
||||
from litellm.repositories.table_repositories import ClaudeCodePluginRepository
|
||||
from litellm.types.proxy.auth.special_headers import SpecialHeaders
|
||||
from litellm.types.proxy.claude_code_endpoints import (
|
||||
InstallationPreference,
|
||||
ListPluginsResponse,
|
||||
|
|
@ -108,6 +110,24 @@ async def get_prisma_client() -> object:
|
|||
_get_prisma_client: Final = get_prisma_client
|
||||
|
||||
|
||||
def marketplace_auth_required() -> bool:
|
||||
from litellm.proxy.proxy_server import general_settings_view
|
||||
|
||||
return general_settings_view().get("claude_code_marketplace_auth_required") is True
|
||||
|
||||
|
||||
async def _marketplace_caller(request: Request, key: str | None) -> UserAPIKeyAuth | None:
|
||||
if key:
|
||||
return await user_api_key_auth(request=request, api_key=f"Bearer {key}")
|
||||
if not marketplace_auth_required():
|
||||
return None
|
||||
return await user_api_key_auth(
|
||||
request=request,
|
||||
api_key=request.headers.get(SpecialHeaders.openai_authorization.value) or "",
|
||||
custom_litellm_key_header=request.headers.get(SpecialHeaders.custom_litellm_api_key.value),
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/claude-code/marketplace.json",
|
||||
tags=["Claude Code Marketplace"],
|
||||
|
|
@ -120,10 +140,14 @@ async def get_marketplace(request: Request, key: str | None = None):
|
|||
- claude plugin marketplace add <url>
|
||||
- claude plugin install <name>@<marketplace>
|
||||
|
||||
Without `key` the catalog holds the enabled (public) plugins. With `?key=sk-...`
|
||||
Without a key the catalog holds the enabled (public) plugins. With `?key=sk-...`
|
||||
the key is authenticated and the catalog also holds the disabled plugins granted
|
||||
to it through `object_permission.skills` or an access group on the key or its team.
|
||||
|
||||
With `general_settings.claude_code_marketplace_auth_required: true` a caller with
|
||||
no key gets a 401, and the key may also come in the `Authorization` or
|
||||
`x-litellm-api-key` header (Claude Code sends them from the marketplace's `headers`).
|
||||
|
||||
Returns:
|
||||
Marketplace catalog with list of available plugins and their git sources.
|
||||
|
||||
|
|
@ -135,11 +159,8 @@ async def get_marketplace(request: Request, key: str | None = None):
|
|||
```
|
||||
"""
|
||||
try:
|
||||
caller: Final = await _marketplace_caller(request, key)
|
||||
prisma_client: Final = await get_prisma_client()
|
||||
|
||||
caller: Final[UserAPIKeyAuth | None] = (
|
||||
await user_api_key_auth(request=request, api_key=f"Bearer {key}") if key else None
|
||||
)
|
||||
visibility: Final[SkillVisibility] = await resolve_skill_visibility(caller)
|
||||
plugins: Final[Sequence[_PluginRecord]] = await ClaudeCodePluginRepository(prisma_client).table.find_many(
|
||||
where=visibility.where()
|
||||
|
|
@ -200,7 +221,7 @@ async def get_marketplace(request: Request, key: str | None = None):
|
|||
verbose_proxy_logger.exception("Error generating marketplace: %s", e)
|
||||
raise HTTPException(
|
||||
status_code=500,
|
||||
detail={"error": f"Failed to generate marketplace: {e}"},
|
||||
detail={"error": "Failed to generate marketplace"},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -366,17 +366,20 @@ async def get_mcp_servers():
|
|||
tags=["public", "Claude Code Marketplace"],
|
||||
)
|
||||
async def public_skill_hub():
|
||||
"""Return enabled (public) Claude Code skills — no auth required."""
|
||||
"""Return enabled (public) Claude Code skills, or none when the marketplace requires a key."""
|
||||
from litellm.proxy.anthropic_endpoints.claude_code_endpoints.claude_code_marketplace import (
|
||||
MANIFEST_FIELDS,
|
||||
get_installation_preference,
|
||||
get_prisma_client,
|
||||
marketplace_auth_required,
|
||||
)
|
||||
from litellm.types.proxy.claude_code_endpoints import (
|
||||
ListPluginsResponse,
|
||||
PluginListItem,
|
||||
)
|
||||
|
||||
if marketplace_auth_required():
|
||||
return ListPluginsResponse(plugins=[], count=0)
|
||||
try:
|
||||
prisma_client: Final = await get_prisma_client()
|
||||
plugins: Final = await _plugin_table(prisma_client).find_many(where={"enabled": True})
|
||||
|
|
@ -404,8 +407,11 @@ async def public_skill_hub():
|
|||
)
|
||||
)
|
||||
return ListPluginsResponse(plugins=items, count=len(items))
|
||||
except HTTPException:
|
||||
raise
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
verbose_logger.exception("Error listing public skills: %s", e)
|
||||
raise HTTPException(status_code=500, detail="Failed to list skills")
|
||||
|
||||
|
||||
@router.get(
|
||||
|
|
|
|||
14
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
14
ui/litellm-dashboard/src/lib/http/schema.d.ts
generated
vendored
|
|
@ -2384,10 +2384,14 @@ export interface paths {
|
|||
* - claude plugin marketplace add <url>
|
||||
* - claude plugin install <name>@<marketplace>
|
||||
*
|
||||
* Without `key` the catalog holds the enabled (public) plugins. With `?key=sk-...`
|
||||
* Without a key the catalog holds the enabled (public) plugins. With `?key=sk-...`
|
||||
* the key is authenticated and the catalog also holds the disabled plugins granted
|
||||
* to it through `object_permission.skills` or an access group on the key or its team.
|
||||
*
|
||||
* With `general_settings.claude_code_marketplace_auth_required: true` a caller with
|
||||
* no key gets a 401, and the key may also come in the `Authorization` or
|
||||
* `x-litellm-api-key` header (Claude Code sends them from the marketplace's `headers`).
|
||||
*
|
||||
* Returns:
|
||||
* Marketplace catalog with list of available plugins and their git sources.
|
||||
*
|
||||
|
|
@ -13754,7 +13758,7 @@ export interface paths {
|
|||
};
|
||||
/**
|
||||
* Public Skill Hub
|
||||
* @description Return enabled (public) Claude Code skills — no auth required.
|
||||
* @description Return enabled (public) Claude Code skills, or none when the marketplace requires a key.
|
||||
*/
|
||||
get: operations["public_skill_hub_public_skill_hub_get"];
|
||||
put?: never;
|
||||
|
|
@ -29852,6 +29856,12 @@ export interface components {
|
|||
claude_code_gateway_managed_settings?: {
|
||||
[key: string]: unknown;
|
||||
} | null;
|
||||
/**
|
||||
* Claude Code Marketplace Auth Required
|
||||
* @description If True, GET /claude-code/marketplace.json requires a LiteLLM key (Authorization or x-litellm-api-key header, the litellm_key_header_name header, or ?key=) and answers 401 without one, and GET /public/skill_hub returns an empty list. Default is False, which serves the enabled plugins to anyone.
|
||||
* @default false
|
||||
*/
|
||||
claude_code_marketplace_auth_required: boolean;
|
||||
/**
|
||||
* Completion Model
|
||||
* @description proxy level default model for all chat completion calls
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue