diff --git a/README.de.md b/README.de.md index de2a00e..0c0142a 100644 --- a/README.de.md +++ b/README.de.md @@ -295,7 +295,7 @@ Verwaltete Einstellungen haben Vorrang vor Projekteinstellungen; KeyZapper brich |---|---|---| | `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 `, 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`). | +| `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 `, 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` (Buchstaben, Ziffern, `-`, `_`, `.`), `URL` deren https-Adresse mit demselben Schema, Host und Port wie `Endpoint`; sonst schreibt KeyZapper nichts, damit das Token an keinen anderen Dienst geht, auch nicht an einen anderen Port auf dem Gateway-Host. Ein gleichnamiger Eintrag in `.claude/settings.local.json`, den nicht KeyZapper geschrieben hat, wird als Konflikt gemeldet und muss von Hand entfernt werden. 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 | diff --git a/README.md b/README.md index f27bd98..726bfcb 100644 --- a/README.md +++ b/README.md @@ -291,7 +291,7 @@ outrank project settings; KeyZapper aborts binding on conflict. |---|---|---| | `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 `, 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`). | +| `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 `, 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` (letters, digits, `-`, `_`, `.`), `URL` its https address with the same scheme, host and port as `Endpoint`; otherwise KeyZapper writes nothing, so the token goes to no other service, not even another port on the gateway's host. An entry of the same name in `.claude/settings.local.json` that KeyZapper did not write is reported as a conflict and has to be removed by hand. 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 | diff --git a/desktop/Cargo.lock b/desktop/Cargo.lock index 9c01c27..75e9caa 100644 --- a/desktop/Cargo.lock +++ b/desktop/Cargo.lock @@ -10,37 +10,37 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "aead" -version = "0.5.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" dependencies = [ - "crypto-common", - "generic-array", + "crypto-common 0.2.2", + "inout", ] [[package]] name = "aes" -version = "0.8.4" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +checksum = "fc0fc36d7440d015b45468ba08a21e80e056ebbd014c611c6298bb7503e04bd1" dependencies = [ - "cfg-if", "cipher", - "cpufeatures", + "cpubits", + "cpufeatures 0.3.1", ] [[package]] name = "aes-gcm" -version = "0.10.3" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +checksum = "7f2b8006a0c83f52b62ba44a97b58bf76fe2f70a329e588f67f89691d93d498f" dependencies = [ "aead", "aes", "cipher", "ctr", + "ctutils", "ghash", - "subtle", ] [[package]] @@ -311,6 +311,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", +] + [[package]] name = "block2" version = "0.6.2" @@ -515,14 +524,21 @@ dependencies = [ [[package]] name = "cipher" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" dependencies = [ - "crypto-common", + "block-buffer 0.12.1", + "crypto-common 0.2.2", "inout", ] +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + [[package]] name = "combine" version = "4.6.8" @@ -542,11 +558,17 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "const-oid" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a" + [[package]] name = "cookie" -version = "0.18.2" +version = "0.18.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +checksum = "d55f2d6c30eeec7d5c6f98bd4395d4abb1895629eab97ee6522d340623615f8a" dependencies = [ "time", "version_check", @@ -592,6 +614,12 @@ dependencies = [ "libc", ] +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -601,6 +629,15 @@ dependencies = [ "libc", ] +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + [[package]] name = "crc32fast" version = "1.5.2" @@ -632,10 +669,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", - "rand_core", "typenum", ] +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "getrandom 0.4.3", + "hybrid-array", + "rand_core", +] + [[package]] name = "cssparser" version = "0.37.0" @@ -656,7 +703,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d045de693cb712d0b22c6a64be5b953f67b3ce00ab5ad3dd5d8b441886ab8e1a" dependencies = [ "quote", - "syn 3.0.6", + "syn 2.0.119", ] [[package]] @@ -667,13 +714,22 @@ checksum = "914a755b7c2d4af2bdcff7ce1739e2db9a1b81a9b07123d8015786ae03c0980d" [[package]] name = "ctr" -version = "0.9.2" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +checksum = "baaca1c4b237092596f64d571e9db6ce4109c4ef9742e27590f1709594461f21" dependencies = [ "cipher", ] +[[package]] +name = "ctutils" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "261af4dc7a06ea8a527a8717d8cbba3417530d6ea14e1edb3de6b67806be474f" +dependencies = [ + "cmov", +] + [[package]] name = "darling" version = "0.24.1" @@ -796,9 +852,20 @@ version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ - "block-buffer", - "crypto-common", - "subtle", + "block-buffer 0.10.4", + "crypto-common 0.1.7", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer 0.12.1", + "const-oid", + "crypto-common 0.2.2", + "ctutils", ] [[package]] @@ -1111,9 +1178,9 @@ checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -1311,17 +1378,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "getrandom" version = "0.3.4" @@ -1343,15 +1399,15 @@ dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", + "rand_core", ] [[package]] name = "ghash" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +checksum = "2eecf2d5dc9b66b732b97707a0210906b1d30523eb773193ab777c0c84b3e8d5" dependencies = [ - "opaque-debug", "polyval", ] @@ -1541,11 +1597,11 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" -version = "0.12.1" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" dependencies = [ - "digest", + "digest 0.11.3", ] [[package]] @@ -1597,6 +1653,15 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + [[package]] name = "hyper" version = "1.12.0" @@ -1818,11 +1883,11 @@ dependencies = [ [[package]] name = "inout" -version = "0.1.4" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +checksum = "3a580c13f0ffc335ef42dd3f6b1a41b726051c5e1656d9a3aa6fddb3c5dfbbf9" dependencies = [ - "generic-array", + "hybrid-array", ] [[package]] @@ -2049,7 +2114,7 @@ dependencies = [ "pbkdf2", "serde", "serde_json", - "sha2", + "sha2 0.11.1", "sys-locale", "unicode-normalization", "ureq", @@ -2527,12 +2592,6 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "opaque-debug" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" - [[package]] name = "open" version = "5.4.4" @@ -2659,11 +2718,11 @@ dependencies = [ [[package]] name = "pbkdf2" -version = "0.12.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +checksum = "112d82ceb8c5bf524d9af484d4e4970c9fd5a0cc15ba14ad93dccd28873b0629" dependencies = [ - "digest", + "digest 0.11.3", "hmac", ] @@ -2813,13 +2872,12 @@ dependencies = [ [[package]] name = "polyval" -version = "0.6.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +checksum = "f0fa31d631f2b2cb2a544d0aa321ce847a94764d701ca2becc411138b93d49cd" dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug", + "cpubits", + "cpufeatures 0.3.1", "universal-hash", ] @@ -2953,12 +3011,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand_core" -version = "0.6.4" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.17", -] +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" [[package]] name = "raw-window-handle" @@ -3428,8 +3483,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" dependencies = [ "cfg-if", - "cpufeatures", - "digest", + "cpufeatures 0.2.17", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest 0.11.3", ] [[package]] @@ -3566,12 +3632,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "swift-rs" version = "1.0.8" @@ -3803,7 +3863,7 @@ dependencies = [ "semver", "serde", "serde_json", - "sha2", + "sha2 0.10.9", "syn 2.0.119", "tauri-utils", "thiserror 2.0.21", @@ -4404,12 +4464,12 @@ checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "universal-hash" -version = "0.5.1" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" dependencies = [ - "crypto-common", - "subtle", + "crypto-common 0.2.2", + "ctutils", ] [[package]] @@ -4443,9 +4503,9 @@ dependencies = [ [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", @@ -5218,7 +5278,7 @@ dependencies = [ "once_cell", "percent-encoding", "raw-window-handle", - "sha2", + "sha2 0.10.9", "soup3", "tao-macros", "thiserror 2.0.21", diff --git a/desktop/core/Cargo.toml b/desktop/core/Cargo.toml index 74ef649..d6ef6d4 100644 --- a/desktop/core/Cargo.toml +++ b/desktop/core/Cargo.toml @@ -5,13 +5,13 @@ edition = "2021" license = "MIT" [dependencies] -aes-gcm = "0.10" +aes-gcm = "0.11" minisign-verify = "0.3" base64 = "0.22" -pbkdf2 = { version = "0.12", default-features = false, features = ["hmac"] } +pbkdf2 = { version = "0.13", default-features = false, features = ["hmac"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -sha2 = "0.10" +sha2 = "0.11" sys-locale = "0.3" unicode-normalization = "0.1" ureq = { version = "3", default-features = false, features = ["native-tls"] } diff --git a/desktop/core/src/backup.rs b/desktop/core/src/backup.rs index c8b37d8..484d71a 100644 --- a/desktop/core/src/backup.rs +++ b/desktop/core/src/backup.rs @@ -4,8 +4,7 @@ use crate::l; use crate::models::AppState; -use aes_gcm::aead::{Aead, AeadCore, KeyInit, OsRng, Payload}; -use aes_gcm::aead::rand_core::RngCore; +use aes_gcm::aead::{Aead, Generate, KeyInit, Payload}; use aes_gcm::{Aes256Gcm, Key, Nonce}; use base64::engine::general_purpose::STANDARD as B64; use base64::Engine; @@ -79,8 +78,7 @@ pub fn seal(payload: &BackupPayload, password: &str, iterations: u32) -> Result< if password.nfc().count() < MINIMUM_PASSWORD_LENGTH { return Err(BackupError::PasswordTooShort); } - let mut salt = [0u8; 16]; - OsRng.fill_bytes(&mut salt); + let salt = <[u8; 16]>::generate(); let mut envelope = Envelope { cipher: "aes-256-gcm".into(), format: FORMAT.into(), @@ -91,8 +89,8 @@ pub fn seal(payload: &BackupPayload, password: &str, iterations: u32) -> Result< version: 1, }; let key = derive_key(password, &salt, iterations); - let cipher = Aes256Gcm::new(Key::::from_slice(&key)); - let nonce = Aes256Gcm::generate_nonce(&mut OsRng); + let cipher = Aes256Gcm::new(&Key::::from(key)); + let nonce = Nonce::generate(); let plaintext = serde_json::to_vec(payload).map_err(|_| BackupError::Corrupt)?; let aad = envelope.associated_data(); let ciphertext = cipher.encrypt(&nonce, Payload { msg: &plaintext, aad: aad.as_bytes() }).map_err(|_| BackupError::Corrupt)?; @@ -119,11 +117,12 @@ pub fn open(data: &[u8], password: &str) -> Result { return Err(BackupError::WrongPasswordOrCorrupt); } let key = derive_key(password, &salt, envelope.iterations); - let cipher = Aes256Gcm::new(Key::::from_slice(&key)); + let cipher = Aes256Gcm::new(&Key::::from(key)); let (nonce, ciphertext) = sealed.split_at(12); + let nonce = Nonce::try_from(nonce).map_err(|_| BackupError::WrongPasswordOrCorrupt)?; let aad = envelope.associated_data(); let plaintext = cipher - .decrypt(Nonce::from_slice(nonce), Payload { msg: ciphertext, aad: aad.as_bytes() }) + .decrypt(&nonce, Payload { msg: ciphertext, aad: aad.as_bytes() }) .map_err(|_| BackupError::WrongPasswordOrCorrupt)?; let mut payload: BackupPayload = serde_json::from_slice(&plaintext).map_err(|_| BackupError::Corrupt)?; payload.state = payload.state.normalized(); diff --git a/desktop/core/src/oidc.rs b/desktop/core/src/oidc.rs index 5089147..c0b95a7 100644 --- a/desktop/core/src/oidc.rs +++ b/desktop/core/src/oidc.rs @@ -6,8 +6,7 @@ use crate::errors::{Error, Result}; use crate::models::{OidcTokenType, Profile}; use crate::tokens::{TokenSet, TokenStore}; use crate::{gateway, l}; -use aes_gcm::aead::rand_core::RngCore; -use aes_gcm::aead::OsRng; +use aes_gcm::aead::Generate; use base64::engine::general_purpose::URL_SAFE_NO_PAD as B64URL; use base64::Engine; use serde_json::Value; @@ -69,10 +68,9 @@ pub fn discover(issuer: &str) -> Result { Ok(Discovery { authorization_endpoint, token_endpoint }) } -fn random_b64(bytes: usize) -> String { - let mut buf = vec![0u8; bytes]; - OsRng.fill_bytes(&mut buf); - B64URL.encode(buf) +/// `N` random bytes from the system's CSPRNG, base64url-encoded. +fn random_b64() -> String { + B64URL.encode(<[u8; N]>::generate()) } /// S256 code challenge of a PKCE verifier. @@ -82,7 +80,7 @@ pub fn pkce_challenge(verifier: &str) -> String { /// (verifier, challenge) pub fn new_pkce() -> (String, String) { - let verifier = random_b64(32); + let verifier = random_b64::<32>(); let challenge = pkce_challenge(&verifier); (verifier, challenge) } @@ -210,7 +208,7 @@ pub fn login(profile: &Profile, store: &TokenStore, open_browser: impl FnOnce(&s listener.set_nonblocking(true)?; let redirect_uri = format!("http://127.0.0.1:{}/callback", listener.local_addr()?.port()); let (verifier, challenge) = new_pkce(); - let state = random_b64(16); + let state = random_b64::<16>(); let mut auth = validate_url(&discovery.authorization_endpoint)?; auth.query_pairs_mut() .append_pair("response_type", "code") diff --git a/desktop/src-tauri/src/main.rs b/desktop/src-tauri/src/main.rs index aa0e1a9..e9eb150 100644 --- a/desktop/src-tauri/src/main.rs +++ b/desktop/src-tauri/src/main.rs @@ -1011,10 +1011,18 @@ fn main() { let version = (!cfg!(debug_assertions)).then(|| app.package_info().version.to_string()); let mut model = Model::load(version); model.vibrancy = app.get_webview_window("main").is_some_and(|w| apply_window_material(&w, NSVisualEffectMaterial::Sidebar, None)); - if let Some(popover) = app.get_webview_window(tray::POPOVER) { - apply_window_material(&popover, NSVisualEffectMaterial::Popover, Some(12.0)); - } app.manage(Shared(Mutex::new(model))); + // The popover is created only now (`"create": false` in tauri.conf.json): on Windows, building a WebView2 + // window processes messages, so the main page's first commands would run before `manage` and panic. + match app.config().app.windows.iter().find(|w| w.label == tray::POPOVER) { + Some(config) => match tauri::WebviewWindowBuilder::from_config(app.handle(), config).and_then(|b| b.build()) { + Ok(popover) => { + apply_window_material(&popover, NSVisualEffectMaterial::Popover, Some(12.0)); + } + Err(e) => eprintln!("KeyZapper: usage popover unavailable: {e}"), + }, + None => eprintln!("KeyZapper: usage popover missing in tauri.conf.json"), + } if let Err(e) = tray::create(app.handle()) { eprintln!("KeyZapper: tray icon unavailable: {e}"); } diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index cdd19d8..a84970d 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -24,6 +24,7 @@ }, { "label": "usage", + "create": false, "url": "usage.html", "title": "KeyZapper", "width": 340, diff --git a/docs/intune/io.github.bl0rb.keyzapper.plist b/docs/intune/io.github.bl0rb.keyzapper.plist index 2a79c50..d60e9a7 100644 --- a/docs/intune/io.github.bl0rb.keyzapper.plist +++ b/docs/intune/io.github.bl0rb.keyzapper.plist @@ -41,6 +41,13 @@ CLAUDE_CODE_API_KEY_HELPER_TTL_MS 900000 + Marketplace + + Name + firma-plugins + URL + https://litellm.firma.example/claude-plugins/marketplace.json + ClaudeDesktop GatewayURL diff --git a/docs/intune/keyzapper-windows.reg b/docs/intune/keyzapper-windows.reg index 5b8207e..9099108 100644 --- a/docs/intune/keyzapper-windows.reg +++ b/docs/intune/keyzapper-windows.reg @@ -7,7 +7,9 @@ Windows Registry Editor Version 5.00 ; ; ManagedProfiles entry: Name, Endpoint, optional ID (UUID; otherwise derived from Name), ModelAlias, OpusModel, SonnetModel, ; HaikuModel, Environment (object), Type ("apiKey" default or "oidc"), OIDCIssuer, OIDCClientID, OIDCScope, -; OIDCTokenType ("access" default or "id"), ClaudeDesktop (object), Office (object). +; OIDCTokenType ("access" default or "id"), Marketplace (object), ClaudeDesktop (object), Office (object). +; Marketplace: Name (as in the marketplace.json; letters, digits, - _ .), URL (https address of the marketplace.json with the same +; scheme, host and port as Endpoint; otherwise nothing is written). Claude Code 2.1.238 or newer (headersHelper). ; ClaudeDesktop: OIDCIssuer, OIDCClientID, optional GatewayURL (default: Endpoint), Scopes, BearerTokenType ("id_token" default or ; "access_token"), CredentialKind ("external-idp" default for Claude Desktop 2.7032.0 or newer, "interactive" for older versions), ; AutoApply (set up without a click), Config (further Claude Desktop configuration keys, written as they are). @@ -18,7 +20,7 @@ Windows Registry Editor Version 5.00 ; IgnoreDownloadCertificateErrors: accept untrusted certificates for that traffic (proxy with TLS inspection); packages stay signed. [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\KeyZapper] -"ManagedProfiles"="[{\"ID\":\"7f3c2a10-5b4e-4d8a-9c1f-0e2b3a4c5d6e\",\"Name\":\"Projekt Alpha\",\"Endpoint\":\"https://litellm.firma.example\",\"ModelAlias\":\"claude-sonnet\",\"OpusModel\":\"eu.anthropic.claude-opus-5-team\",\"SonnetModel\":\"eu.anthropic.claude-sonnet-5-team\",\"HaikuModel\":\"eu.anthropic.claude-haiku-4-5\",\"Environment\":{\"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS\":\"1\"}},{\"Name\":\"SSO Projekt\",\"Type\":\"oidc\",\"Endpoint\":\"https://litellm.firma.example\",\"OIDCIssuer\":\"https://login.microsoftonline.com/00000000-0000-4000-8000-000000000000/v2.0\",\"OIDCClientID\":\"c1abe123-4567-4890-abcd-ef0123456789\",\"OIDCScope\":\"api://c1abe123-4567-4890-abcd-ef0123456789/.default offline_access\",\"OIDCTokenType\":\"access\",\"Environment\":{\"CLAUDE_CODE_API_KEY_HELPER_TTL_MS\":\"900000\"},\"ClaudeDesktop\":{\"GatewayURL\":\"https://litellm.firma.example/api/x/desktop-gateway/desktop\",\"OIDCIssuer\":\"https://login.microsoftonline.com/00000000-0000-4000-8000-000000000000/v2.0\",\"OIDCClientID\":\"22222222-3333-4444-8555-666666666666\",\"Scopes\":\"openid profile email offline_access\",\"BearerTokenType\":\"id_token\",\"CredentialKind\":\"external-idp\",\"AutoApply\":true,\"Config\":{\"disableDeploymentModeChooser\":true,\"chatTabEnabled\":true,\"desktopHome\":\"standard\",\"disableFeatureDiscovery\":true,\"disableEssentialTelemetry\":true,\"disableNonessentialTelemetry\":true,\"disabledBuiltinTools\":[\"WebSearch\"],\"coworkEgressAllowedHosts\":[\"*.firma.example\"],\"deploymentDisplayName\":\"Firma\",\"deploymentDisplaySubtitle\":\"0.1.0 (PoC)\",\"banner\":{\"enabled\":true,\"text\":\"Firma Claude Desktop PoC\",\"backgroundColor\":\"#005E52\",\"textColor\":\"#FFFFFF\",\"linkUrl\":\"https://wiki.firma.example/claude\"}}},\"Office\":{\"Enabled\":true,\"AddinID\":\"5c1d7e2a-8b3f-4e6d-9a0c-2f4b6d8e1a3c\",\"GatewayURL\":\"https://litellm.firma.example/api/x/desktop-gateway/office\",\"EntraClientID\":\"11111111-2222-4333-8444-555555555555\",\"EntraScope\":\"api://11111111-2222-4333-8444-555555555555/access_as_user\",\"DisabledFeatures\":[\"web_search\"]}}]" +"ManagedProfiles"="[{\"ID\":\"7f3c2a10-5b4e-4d8a-9c1f-0e2b3a4c5d6e\",\"Name\":\"Projekt Alpha\",\"Endpoint\":\"https://litellm.firma.example\",\"ModelAlias\":\"claude-sonnet\",\"OpusModel\":\"eu.anthropic.claude-opus-5-team\",\"SonnetModel\":\"eu.anthropic.claude-sonnet-5-team\",\"HaikuModel\":\"eu.anthropic.claude-haiku-4-5\",\"Environment\":{\"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS\":\"1\"}},{\"Name\":\"SSO Projekt\",\"Type\":\"oidc\",\"Endpoint\":\"https://litellm.firma.example\",\"OIDCIssuer\":\"https://login.microsoftonline.com/00000000-0000-4000-8000-000000000000/v2.0\",\"OIDCClientID\":\"c1abe123-4567-4890-abcd-ef0123456789\",\"OIDCScope\":\"api://c1abe123-4567-4890-abcd-ef0123456789/.default offline_access\",\"OIDCTokenType\":\"access\",\"Environment\":{\"CLAUDE_CODE_API_KEY_HELPER_TTL_MS\":\"900000\"},\"Marketplace\":{\"Name\":\"firma-plugins\",\"URL\":\"https://litellm.firma.example/claude-plugins/marketplace.json\"},\"ClaudeDesktop\":{\"GatewayURL\":\"https://litellm.firma.example/api/x/desktop-gateway/desktop\",\"OIDCIssuer\":\"https://login.microsoftonline.com/00000000-0000-4000-8000-000000000000/v2.0\",\"OIDCClientID\":\"22222222-3333-4444-8555-666666666666\",\"Scopes\":\"openid profile email offline_access\",\"BearerTokenType\":\"id_token\",\"CredentialKind\":\"external-idp\",\"AutoApply\":true,\"Config\":{\"disableDeploymentModeChooser\":true,\"chatTabEnabled\":true,\"desktopHome\":\"standard\",\"disableFeatureDiscovery\":true,\"disableEssentialTelemetry\":true,\"disableNonessentialTelemetry\":true,\"disabledBuiltinTools\":[\"WebSearch\"],\"coworkEgressAllowedHosts\":[\"*.firma.example\"],\"deploymentDisplayName\":\"Firma\",\"deploymentDisplaySubtitle\":\"0.1.0 (PoC)\",\"banner\":{\"enabled\":true,\"text\":\"Firma Claude Desktop PoC\",\"backgroundColor\":\"#005E52\",\"textColor\":\"#FFFFFF\",\"linkUrl\":\"https://wiki.firma.example/claude\"}}},\"Office\":{\"Enabled\":true,\"AddinID\":\"5c1d7e2a-8b3f-4e6d-9a0c-2f4b6d8e1a3c\",\"GatewayURL\":\"https://litellm.firma.example/api/x/desktop-gateway/office\",\"EntraClientID\":\"11111111-2222-4333-8444-555555555555\",\"EntraScope\":\"api://11111111-2222-4333-8444-555555555555/access_as_user\",\"DisabledFeatures\":[\"web_search\"]}}]" ; AllowedGatewayHosts as REG_MULTI_SZ: litellm.firma.example, *.litellm.firma.example "AllowedGatewayHosts"=hex(7):6c,00,69,00,74,00,65,00,6c,00,6c,00,6d,00,2e,00,66,00,69,00,72,00,6d,\ 00,61,00,2e,00,65,00,78,00,61,00,6d,00,70,00,6c,00,65,00,00,00,2a,00,2e,00,\