Skip to content

Commit 8564c2f

Browse files
Merge pull request #1648 from QueryaHub/issue/1586-macos-login-keychain
fix(macos): store secrets in the login keychain (#1586)
2 parents d79d09f + fa19a5f commit 8564c2f

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
### Fixed
2121

2222
- **Extension manifest `id` is checked before it becomes a folder** — a sideloaded `.qext` with `"id": "../some/dir"` made the installer recursively delete and overwrite a folder outside the extensions directory. The id must now be letters, digits, `.`, `_` or `-` (starting with a letter or digit, no `..`), and every install / uninstall refuses a folder that is not inside the extensions directory (#1560).
23+
24+
- **macOS: saved passwords use the login keychain** — the secure storage plugin defaults to the data protection keychain, which needs an entitlement no Querya build has, so saving or reading a connection password failed with "Could not read the saved credentials from the system keyring". macOS may ask once to allow Querya Desktop to use its keychain items, and again after an update of an unsigned build (#1586).
25+
=======
2326
- **Zip limits hold even when an archive lies about its sizes** — the per-entry, total and ratio limits for extension installs, sideloads and updates are checked against the sizes the zip headers declare; the app now requires `archive` 4.5+, which refuses to decode an entry past its declared size, and reports that as an error instead of inflating it (#1561).
27+
2428
- **`querya-ext-tester` sends a `--connect` password with `system.injectCredentials`, like the app** — a driver that reads its password only from the injected secret (the ClickHouse driver) failed authentication under the tester because the password was in the `db.connect` payload only.
2529
- **Demo Marketplace themes were named `${manifest.name}`** — the generated theme.json now carries the real name (the demo catalog is only used with `--dart-define=QUERYA_MARKETPLACE_MOCK=true`).
2630
- **In-app update of a package install (AUR, `.deb`, `.rpm`)** — the updater no longer downloads a zip and quits when the app lives in `/opt/querya-desktop` (owned by root): the update dialog says how to update it (`yay -Syu querya-desktop`, `apt`, `dnf`) with a *Copy update command* button, or offers the release page for any other folder the user cannot write. If an in-place replace fails anyway, the app is started again and the reason is logged to `~/.local/state/querya-update.log`, instead of staying closed.

‎lib/core/storage/connection_secrets_store.dart‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
23

34
/// Backend for reading/writing per-connection secrets (password, connection string).
@@ -9,8 +10,9 @@ abstract class SecretsStorageBackend {
910
}
1011

1112
class _FlutterSecureStorageBackend implements SecretsStorageBackend {
12-
/// Desktop targets use the default platform options from the plugin.
13-
final FlutterSecureStorage _storage = const FlutterSecureStorage();
13+
final FlutterSecureStorage _storage = const FlutterSecureStorage(
14+
mOptions: ConnectionSecretsStore.macOsOptions,
15+
);
1416

1517
@override
1618
Future<String?> read(String key) => _storage.read(key: key);
@@ -60,6 +62,15 @@ class ConnectionSecretsStore {
6062
/// Production uses OS-backed storage; tests override [backend] (see `test/flutter_test_config.dart`).
6163
static SecretsStorageBackend backend = _FlutterSecureStorageBackend();
6264

65+
/// macOS: the file-based login keychain. The plugin's default, the data
66+
/// protection keychain, needs the `keychain-access-groups` entitlement,
67+
/// which none of the builds carry (a restricted entitlement: a Developer ID
68+
/// build with it needs a provisioning profile or does not launch), so every
69+
/// read and write failed with errSecMissingEntitlement (#1586).
70+
@visibleForTesting
71+
static const MacOsOptions macOsOptions =
72+
MacOsOptions(usesDataProtectionKeychain: false);
73+
6374
/// Identifies the current profile's local database (installed / portable /
6475
/// migrated-legacy — see `AppDataRoot`), so that two independent profile
6576
/// databases never collide in the shared OS keyring even when they each
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
import 'package:querya_desktop/core/storage/connection_secrets_store.dart';
3+
4+
void main() {
5+
test('macOS secrets go to the login keychain, not the data protection one '
6+
'(#1586)', () {
7+
// What the native plugin reads: "true" (its default) needs the
8+
// keychain-access-groups entitlement, which the app does not have.
9+
expect(
10+
ConnectionSecretsStore.macOsOptions.toMap()['usesDataProtectionKeychain'],
11+
'false',
12+
);
13+
});
14+
}

0 commit comments

Comments
 (0)