Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ Verwaltete Einstellungen haben Vorrang vor Projekteinstellungen; KeyZapper brich

| Schlüssel | Typ | Wirkung |
|---|---|---|
| `ManagedProfiles` | Array von Dicts: `Name`, `Endpoint`, optional `OpusModel`, `SonnetModel`, `HaikuModel`, `ModelAlias`, `Environment` (Dict), `ID`, `Type` (`apiKey` Standard oder `oidc`), `OIDCIssuer`, `OIDCClientID`, `OIDCScope`, `OIDCTokenType`, `Office`, `ClaudeDesktop` (Dicts, siehe unten) | Profile werden automatisch angelegt und sind nicht editier- oder löschbar; Entwickler tragen nur den Key ein (oder melden sich für SSO an) und können *Claude in Office* und *Claude Desktop (SSO)* für das Profil selbst einschalten, wo die IT beides nicht setzt (siehe unten). Ohne `ID` wird die Profil-ID aus `Name` abgeleitet, eine Umbenennung erzeugt also ein neues Profil. Bei SSO (`oidc`) sind `OIDCIssuer` und `OIDCClientID` erforderlich; `OIDCScope` Standard `openid profile offline_access`; `OIDCTokenType` ist `access` (Standard) oder `id`, andere Werte verwerfen das Profil. |
| `ManagedProfiles` | Array von Dicts: `Name`, `Endpoint`, optional `OpusModel`, `SonnetModel`, `HaikuModel`, `ModelAlias`, `Environment` (Dict), `ID`, `Type` (`apiKey` Standard oder `oidc`), `OIDCIssuer`, `OIDCClientID`, `OIDCScope`, `OIDCTokenType`, `Office`, `ClaudeDesktop`, `Marketplace` (Dicts, siehe unten) | Profile werden automatisch angelegt und sind nicht editier- oder löschbar; Entwickler tragen nur den Key ein (oder melden sich für SSO an) und können *Claude in Office* und *Claude Desktop (SSO)* für das Profil selbst einschalten, wo die IT beides nicht setzt (siehe unten). Ohne `ID` wird die Profil-ID aus `Name` abgeleitet, eine Umbenennung erzeugt also ein neues Profil. Bei SSO (`oidc`) sind `OIDCIssuer` und `OIDCClientID` erforderlich; `OIDCScope` Standard `openid profile offline_access`; `OIDCTokenType` ist `access` (Standard) oder `id`, andere Werte verwerfen das Profil. |
| `ClaudeDesktop` (innerhalb eines `ManagedProfiles`-Eintrags) | Dict: `OIDCIssuer`, `OIDCClientID`, optional `GatewayURL` (Standard: `Endpoint` des Profils), `Scopes`, `BearerTokenType` (`id_token` Standard oder `access_token`), `CredentialKind` (`external-idp` Standard oder `interactive`), `Config` (Dict weiterer Claude-Desktop-Schlüssel), `AutoApply` (Bool, Standard `false`) | Claude Desktop meldet sich selbst mit dem OIDC-Client des Gateways an, wenn dieses Profil dafür gewählt ist (siehe [Claude-Tools](#claude-tools)). `external-idp` braucht Claude Desktop ab 2.7032.0; solange ältere Versionen im Einsatz sind, `interactive` setzen. Ein Block mit unbrauchbaren Werten (auch ein unbekanntes `CredentialKind`) bleibt erhalten; KeyZapper schreibt dann nichts für Claude Desktop. Die Schlüssel entsprechen der Claude-Desktop-Konfiguration: `GatewayURL` → `inferenceGatewayBaseUrl`, `OIDCIssuer`/`OIDCClientID`/`Scopes`/`BearerTokenType` → `issuer`, `clientId`, `scopes` und `bearerTokenType` des OIDC-Blocks, `CredentialKind` → `inferenceCredentialKind`; `inferenceProvider: gateway` und `appendOfflineAccess: true` werden immer geschrieben, alles Weitere (Telemetrie, Banner, erlaubte Hosts, …) gehört in `Config`. Ohne das Dict können Entwickler *Claude Desktop (SSO)* im Profil selbst ausfüllen; das Dict der IT ersetzt ihren Eintrag. |
| `Marketplace` (innerhalb eines `ManagedProfiles`-Eintrags) | Dict: `Name`, `URL` | Plugin-Marketplace für Claude Code, den das Gateway hinter derselben Anmeldung ausliefert. KeyZapper schreibt ihn mit dem Profil als `extraKnownMarketplaces`-Eintrag (Quelle `url`, `headersHelper` = `keyzapper-helper headers --profile <ID>`, der das Token des Profils als `Authorization`-Header liefert) und entfernt ihn mit der Zuordnung wieder; Claude Code braucht dafür `headersHelper` (ab 2.1.238). `Name` ist der Name aus der `marketplace.json`, `URL` deren https-Adresse auf dem Host von `Endpoint`; für einen anderen Host schreibt KeyZapper nichts, damit das Token das Gateway nicht verlässt. Für Claude Desktop gehört der Marketplace in `ClaudeDesktop` › `Config` (`allowedPluginMarketplaces`). |
| `Office` (innerhalb eines `ManagedProfiles`-Eintrags) | Dict: `Enabled` (Bool, Standard `true`), `AddinID`, `GatewayURL`, `EntraClientID`, `EntraScope`, `DisabledFeatures` (Array oder kommagetrennter String) | Richtet [Claude in Microsoft 365](#claude-in-microsoft-365-über-das-profil) aus diesem Profil ein. Werte werden getrimmt. Ein Block mit unbrauchbaren Werten bleibt erhalten und wird in der Profilkarte gemeldet; dann wird nichts geschrieben. Ohne das Dict können Entwickler *Claude in Office* im Profil selbst einschalten; das Dict der IT ersetzt ihren Eintrag. |
| `AllowedGatewayHosts` | Array von Strings (`host` oder `*.domain`) | Profile nur für diese Hosts. Der Helper gibt Keys für andere Hosts nicht heraus (Exit 78). Gilt nur für den Gateway-Host; der IdP-Host muss nicht gelistet sein. Leer bedeutet keine Einschränkung. |
| `DefaultEndpoint`, `DefaultModelAlias` | String | Vorbelegung beim Anlegen eigener Profile |
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ outrank project settings; KeyZapper aborts binding on conflict.

| Key | Type | Effect |
|---|---|---|
| `ManagedProfiles` | Array of dicts: `Name`, `Endpoint`, optional `OpusModel`, `SonnetModel`, `HaikuModel`, `ModelAlias`, `Environment` (dict), `ID`, `Type` (`apiKey` default or `oidc`), `OIDCIssuer`, `OIDCClientID`, `OIDCScope`, `OIDCTokenType`, `Office`, `ClaudeDesktop` (dicts, see below) | Profiles are created automatically and cannot be edited or deleted; developers only enter the key (or sign in for SSO) and may switch on *Claude in Office* and *Claude Desktop (SSO)* for the profile where IT sets neither (see below). Without `ID` the profile ID is derived from `Name`, so renaming creates a new profile. For SSO (`oidc` type), `OIDCIssuer` and `OIDCClientID` are required; `OIDCScope` defaults to `openid profile offline_access`; `OIDCTokenType` is `access` (default) or `id`, other values discard the profile. |
| `ManagedProfiles` | Array of dicts: `Name`, `Endpoint`, optional `OpusModel`, `SonnetModel`, `HaikuModel`, `ModelAlias`, `Environment` (dict), `ID`, `Type` (`apiKey` default or `oidc`), `OIDCIssuer`, `OIDCClientID`, `OIDCScope`, `OIDCTokenType`, `Office`, `ClaudeDesktop`, `Marketplace` (dicts, see below) | Profiles are created automatically and cannot be edited or deleted; developers only enter the key (or sign in for SSO) and may switch on *Claude in Office* and *Claude Desktop (SSO)* for the profile where IT sets neither (see below). Without `ID` the profile ID is derived from `Name`, so renaming creates a new profile. For SSO (`oidc` type), `OIDCIssuer` and `OIDCClientID` are required; `OIDCScope` defaults to `openid profile offline_access`; `OIDCTokenType` is `access` (default) or `id`, other values discard the profile. |
| `ClaudeDesktop` (inside a `ManagedProfiles` entry) | Dict: `OIDCIssuer`, `OIDCClientID`, optional `GatewayURL` (default: the profile's `Endpoint`), `Scopes`, `BearerTokenType` (`id_token` default or `access_token`), `CredentialKind` (`external-idp` default or `interactive`), `Config` (dict of further Claude Desktop keys), `AutoApply` (Bool, default `false`) | Claude Desktop signs in itself with the gateway's OIDC client when this profile is chosen for it (see [Claude tools](#claude-tools)). The keys map to Claude Desktop's configuration: `GatewayURL` → `inferenceGatewayBaseUrl`, `OIDCIssuer`/`OIDCClientID`/`Scopes`/`BearerTokenType` → the `issuer`, `clientId`, `scopes` and `bearerTokenType` of the OIDC block, `CredentialKind` → `inferenceCredentialKind`; `inferenceProvider: gateway` and `appendOfflineAccess: true` are always written, everything else (telemetry, banner, allowed hosts, …) goes into `Config`. Without the dict, developers may fill in *Claude Desktop (SSO)* in the profile themselves; the dict from IT replaces their entry. `external-idp` needs Claude Desktop 2.7032.0 or newer; set `interactive` while older versions are in use. A block with unusable values (also an unknown `CredentialKind`) is kept; KeyZapper then writes nothing for Claude Desktop. |
| `Marketplace` (inside a `ManagedProfiles` entry) | Dict: `Name`, `URL` | Plugin marketplace for Claude Code that the gateway serves behind the same sign-in. KeyZapper writes it with the profile as an `extraKnownMarketplaces` entry (source `url`, `headersHelper` = `keyzapper-helper headers --profile <ID>`, which prints the profile's token as an `Authorization` header) and removes it again with the assignment; Claude Code needs `headersHelper` for it (2.1.238 or newer). `Name` is the name in the `marketplace.json`, `URL` its https address on the host of `Endpoint`; for another host KeyZapper writes nothing, so the token never leaves the gateway. For Claude Desktop the marketplace belongs in `ClaudeDesktop` › `Config` (`allowedPluginMarketplaces`). |
| `Office` (inside a `ManagedProfiles` entry) | Dict: `Enabled` (Bool, default `true`), `AddinID`, `GatewayURL`, `EntraClientID`, `EntraScope`, `DisabledFeatures` (array or comma-separated string) | Sets up [Claude in Microsoft 365](#claude-in-microsoft-365-through-the-profile) from this profile. Without the dict, developers may switch on *Claude in Office* in the profile themselves; the dict from IT replaces their entry. Values are trimmed. A block with unusable values is kept and reported on the profile card; nothing is written then. |
| `AllowedGatewayHosts` | Array of strings (`host` or `*.domain`) | Profiles only for these hosts. The helper does not release keys for other hosts (exit 78). Applies to the gateway host only; the IdP host need not be listed. Empty means no restriction. |
| `DefaultEndpoint`, `DefaultModelAlias` | String | Prefill when creating your own profiles |
Expand Down
13 changes: 11 additions & 2 deletions desktop/core/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! ```text
//! keyzapper-helper credential --profile <UUID> # key on stdout (no newline), used as apiKeyHelper
//! keyzapper-helper headers --profile <UUID> # like credential, as {"Authorization":"Bearer <key>"}: the
//! # headersHelper of a plugin marketplace on the gateway
//! keyzapper-helper pool --profile <UUID> # like credential; once its budget is used up, the key with
//! # the most budget left on the same endpoint (hidden pool mode)
//! keyzapper-helper store --profile <UUID> # key on stdin (never as argument)
Expand Down Expand Up @@ -64,9 +66,16 @@ impl HelperCommand {
}

pub fn run(&self, args: &[String], stdin: impl FnOnce() -> String) -> Output {
let commands = ["credential", "pool", "store", "status", "delete"];
let commands = ["credential", "headers", "pool", "store", "status", "delete"];
if args.len() != 3 || args[1] != "--profile" || !commands.contains(&args[0].as_str()) {
return fail(ExitCode::Usage, l!("Aufruf: %@ credential|pool|store|status|delete --profile <UUID>", EXECUTABLE_NAME));
return fail(ExitCode::Usage, l!("Aufruf: %@ credential|headers|pool|store|status|delete --profile <UUID>", EXECUTABLE_NAME));
}
if args[0] == "headers" {
let mut output = self.run(&["credential".into(), args[1].clone(), args[2].clone()], stdin);
if output.exit_code == ExitCode::Ok {
output.stdout = serde_json::json!({ "Authorization": format!("Bearer {}", output.stdout) }).to_string();
}
return output;
}
let Some(id) = parse_id(&args[2]) else { return fail(ExitCode::UnknownProfile, l!("Ungültige Profil-ID: %@", args[2])) };
let state = match self.metadata.load() {
Expand Down
7 changes: 6 additions & 1 deletion desktop/core/src/managed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use crate::claude_desktop::{BearerTokenType, CredentialKind, DesktopSso};
use crate::claude_office::OfficeClient;
use crate::models::{AuthType, OidcTokenType};
use crate::models::{AuthType, OidcTokenType, PluginMarketplace};
use serde_json::{Map, Value};
use sha2::{Digest, Sha256};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -33,6 +33,7 @@ pub struct ManagedProfile {
pub oidc_token_type: OidcTokenType,
pub office: Option<OfficeClient>,
pub claude_desktop: Option<DesktopSso>,
pub marketplace: Option<PluginMarketplace>,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -209,6 +210,10 @@ fn managed_profile(dict: &Map<String, Value>) -> Option<ManagedProfile> {
oidc_token_type,
office: dict.get("Office").and_then(Value::as_object).map(office_client),
claude_desktop: dict.get("ClaudeDesktop").and_then(Value::as_object).map(desktop_sso),
marketplace: dict.get("Marketplace").and_then(Value::as_object).map(|m| {
let trimmed = |key: &str| as_string(m.get(key)).map(|v| v.trim().to_string()).unwrap_or_default();
PluginMarketplace { name: trimmed("Name"), url: trimmed("URL") }
}),
})
}

Expand Down
20 changes: 18 additions & 2 deletions desktop/core/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ impl OidcTokenType {
}
}

/// A Claude Code plugin marketplace the profile's gateway serves behind the same credential as the model calls.
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
pub struct PluginMarketplace {
/// Name as in the marketplace's `marketplace.json` (`/plugin install <plugin>@<name>`).
pub name: String,
/// https URL of the `marketplace.json`.
pub url: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Profile {
Expand Down Expand Up @@ -93,6 +103,9 @@ pub struct Profile {
/// Claude Desktop signs in itself with the gateway's OIDC client instead of using the helper; None = helper.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub claude_desktop: Option<DesktopSso>,
/// Plugin marketplace of the gateway, written to Claude Code's `extraKnownMarketplaces`; None = none.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub marketplace: Option<PluginMarketplace>,
}

fn placeholder_credential() -> CredentialReference {
Expand Down Expand Up @@ -134,7 +147,7 @@ impl Profile {
let credential = CredentialReference::for_id(&id);
Self { id, name, endpoint, model_alias, opus_model: None, sonnet_model: None, haiku_model: None, environment: None, credential,
auth_type: AuthType::ApiKey, oidc_issuer: None, oidc_client_id: None, oidc_scope: None,
oidc_token_type: OidcTokenType::Access, office: None, claude_desktop: None }
oidc_token_type: OidcTokenType::Access, office: None, claude_desktop: None, marketplace: None }
}

pub fn is_sso(&self) -> bool {
Expand Down Expand Up @@ -556,12 +569,15 @@ pub struct WorkspaceBinding {
/// Models of one tenant of a multi-tenant gateway instead of the profile's own; None = as in the profile.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub models: Option<ModelSelection>,
/// Exactly the `extraKnownMarketplaces` entries the app wrote, so only those are reverted.
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
pub marketplaces: BTreeMap<String, serde_json::Value>,
}

impl WorkspaceBinding {
pub fn new(path: String, profile_id: String) -> Self {
Self { id: new_id(), path, profile_id, managed_values: BTreeMap::new(), git_exclude_entry: None, pooled: None,
mcp_server_ids: vec![], mcp_managed: BTreeMap::new(), mcp_git_exclude_entry: None, models: None }
mcp_server_ids: vec![], mcp_managed: BTreeMap::new(), mcp_git_exclude_entry: None, models: None, marketplaces: BTreeMap::new() }
}

pub fn is_pooled(&self) -> bool {
Expand Down
Loading
Loading