Skip to content

Feature: TouchID [macOS] - #3762

Merged
infeo merged 7 commits into
developfrom
feature/touch-id
Mar 17, 2025
Merged

infeo merged 7 commits into
developfrom
feature/touch-id

Conversation

@infeo

@infeo infeo commented Feb 25, 2025 •

Copy link
Copy Markdown
Member

This PR is a follow up of #3311 and based on work done by @purejava

It only integrates the TouchID feature for macOS, leaving out any other OS.

The PR adds a new KeychainAccessProvider to securly store passwords in the system by securing the created macOS keychain with addtionaly TouchID query.

The new keychain provider is selected by default on new setups. Existing setups are not migrated. But if the user switches the keychain provider in the preferences, all entries of the old provider are migrated to the new one. The migration is done inside a background thread.

The keychain changes are synchronized on a primitive level, ensuring that only one thread at a time can change entries for a specific keychain and preventing data loss. Quickly changing between the keychain providers creates a queue of migrations, which are done one after another.

For more technical infos regarding touch ID UX, see #3311 (comment)

@infeo infeo added this to the next milestone Feb 25, 2025
@infeo infeo self-assigned this Feb 25, 2025
@coderabbitai

coderabbitai Bot commented Feb 25, 2025 •

Copy link
Copy Markdown

Walkthrough

The pull request introduces several updates across the codebase. In the build configuration, the macOS integration version in the project file was incremented. A new utility class, JavaFXUtil, was added to consistently initialize the JavaFX platform, and the test classes were updated to use this utility method for platform startup. The KeychainManager class was enhanced with a reentrant read-write lock to ensure thread safety and included new methods for exposing the keychain implementation and handling migration between keychain providers. User interface components, such as the vault detail and preferences controllers, were refactored to simplify logic by replacing explicit conditionals with property bindings and integrating asynchronous migration operations. Overall, the changes streamline platform initialization, enhance thread safety, and improve the clarity and robustness of keychain operations.

Possibly related PRs

  • Add Touch ID and Windows Hello support #3311: The changes in the main PR, specifically the update to the KeychainManager class, are related to the modifications in the retrieved PR, which also involve updates to the KeychainManager class, including method signature changes and the introduction of new methods. Both PRs focus on enhancing the functionality of the keychain management system.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)

60-61: Keychain migration completion stage is a good design choice.
Chaining CompletableFuture tasks ensures queued migrations. Consider capturing and handling exceptions at the completion stage level (e.g., using .exceptionally(...)) to cover unanticipated errors outside the loop.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3073a3 and 0bcbf9a.

📒 Files selected for processing (8)
  • pom.xml (1 hunks)
  • src/main/java/org/cryptomator/JavaFXUtil.java (1 hunks)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (4 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1 hunks)
  • src/main/java/org/cryptomator/ui/mainwindow/VaultDetailLockedController.java (2 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (7 hunks)
  • src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (3 hunks)
  • src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)
Learnt from: infeo
PR: cryptomator/cryptomator#3311
File: src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java:114-115
Timestamp: 2025-01-14T16:30:33.762Z
Learning: When migrating keychain entries in macOS, the order of operations must be: 1) load passphrase, 2) delete old entry, 3) store new entry. Attempting to store the new entry before deleting the old one would be counterproductive as the delete operation would remove the newly stored entry since they target the same keychain entry.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Compile and Test
🔇 Additional comments (26)
pom.xml (1)

39-39: Version bump for macOS integration aligns with TouchID feature addition.

The version update from 1.2.4 to 1.3.0 for the macOS integration dependency is necessary to support the new TouchID functionality described in the PR objectives.

src/main/java/org/cryptomator/JavaFXUtil.java (1)

7-18: Well-designed utility for JavaFX platform initialization.

This utility class centralizes JavaFX platform initialization logic with proper synchronization using a CountDownLatch. The implementation correctly handles cases where the platform is already running and provides a reasonable timeout.

Key benefits:

  • Prevents code duplication across test classes
  • Handles platform already running scenario gracefully
  • 5-second timeout prevents tests from hanging indefinitely
src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java (2)

3-3: LGTM: Importing newly created utility class.

The import of JavaFXUtil is appropriate for using the centralized platform initialization.


22-23: Good refactoring to use centralized JavaFX initialization.

Replacing the custom CountDownLatch implementation with the new utility method reduces code duplication while maintaining the same functionality.

src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (4)

4-4: LGTM: Importing newly created utility class.

The import of JavaFXUtil is appropriate for using the centralized platform initialization.


23-27: Improved test setup with class-level JavaFX initialization.

Moving the JavaFX platform initialization to a class-level @BeforeAll method ensures the platform is initialized only once before all tests, improving efficiency.


37-37: Appropriate update to non-static nested test class.

Changing the nested class from static to non-static is consistent with the class-level JavaFX initialization approach.


45-45: LGTM: Minor formatting improvement.

Small formatting change adding a space before the parameter improves code readability.

src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1)

115-120: Consider verifying if the keychain is unlocked before storing.

Currently, the condition only checks isSupported() and whether the passphrase is already stored. It may be helpful to guard against a locked keychain by additionally checking !keychain.isLocked() to avoid potential failures or prompts when the keychain is not accessible at this moment.

Would you like to confirm keychain lock status usage across the codebase with a quick script or verification?

src/main/java/org/cryptomator/common/keychain/KeychainManager.java (8)

16-16: ReentrantReadWriteLock usage looks appropriate.

Using a non-fair ReentrantReadWriteLock(false) generally offers better performance. The use of .softValues() in the cache appears valid, as it only stores boolean properties rather than sensitive data. This design effectively balances concurrency needs with memory efficiency.

Also applies to: 23-23, 29-29, 32-32


48-51: Updated signature for storePassphrase to throw KeychainAccessException is consistent.

Exposing the exception encourages consistent handling throughout the codebase. Ensure all call sites properly catch or propagate this exception to maintain robust error management.


55-64: Storing passphrase under write lock ensures thread safety.

The lock usage is correct, and calling setPassphraseStored(key, true) outside the try block is a good approach to avoid partial updates. This looks well-structured.


70-76: Loading passphrase under read lock is properly implemented.

Lock-based synchronization around the keychain eliminates the risk of intermediate concurrency issues. Logging or additional error checks may be added if needed, but the current approach is sufficient.


83-86: Deleting passphrase under write lock is correct.

This ensures atomic operations and consistent state of the keychain. No improvements needed here.


95-100: Changing passphrase using a write lock is consistent with the overall locking strategy.

This approach is aligned with preventing race conditions, and the logic to recheck storage ensures accuracy.


137-142: Conditional UI thread update is a sensible approach.

Updating JavaFX properties only on the UI thread is crucial to avoid runtime exceptions. The runLater fallback is correct and ensures concurrency safety.


168-170: Exposing keychainImplementation fosters a clean separation of concerns.

Returning an ObjectExpression<KeychainAccessProvider> is a flexible design that prevents direct coupling to implementation details while still offering dynamic binding.

src/main/java/org/cryptomator/ui/mainwindow/VaultDetailLockedController.java (2)

11-11: No issues found.


33-36: Bindings-based approach is elegant and reactive.

This simplification avoids manual synchronization and toggles passwordSaved consistently based on the vault and the active keychain. The solution is clean and maintainable.

src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (7)

3-6: Imports look fine for new dependencies.
No immediate issues here. The addition of SystemUtils, Passphrase, and KeychainManager are relevant for macOS detection and passphrase handling.


21-21: Observable import is aligned with JavaFX usage.
This import is necessary for the new listener method signature. No concerns here.


31-33: Concurrency imports are appropriate.
Using CompletableFuture, CompletionStage, and ExecutorService is suitable for handling asynchronous migrations without blocking the UI.


47-48: Solid approach to store keychain and executor as final fields.
Marking them as final is a good practice for thread safety and clarity in constructor-based dependency injection.


63-65: Constructor updated to support keychain injection.
Dependency-injecting KeychainManager and ExecutorService here is sensible and improves testability and modularity.


70-71: Assignments of new constructor parameters are correct.
These straightforward assignments ensure the injected objects are available throughout the controller.


92-92: Listener registration for keychain backend choice box.
Registering the new migration method is appropriate. However, verify that the ChangeListener signature (Observable, oldVal, newVal) matches the method signature. Some JavaFX listeners expect (ObservableValue<? extends T>, T, T) strictly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/org/cryptomator/common/keychain/KeychainManager.java (1)

60-70: Consider a more robust way to identify TouchID-compatible providers.

The implementation checks the class name to determine if the keychain supports OS authentication. This approach is fragile and could break if the class name changes in the future.

-			//this is the only keychain actually using the parameter
-			var usesOSAuth = (kc.getClass().getName().equals("org.cryptomator.macos.keychain.TouchIdKeychainAccess"));
+			// Look for a more robust way to determine OS auth support
+			var usesOSAuth = kc instanceof OSAuthSupportingKeychain || 
+			               kc.getClass().getName().equals("org.cryptomator.macos.keychain.TouchIdKeychainAccess");

Where OSAuthSupportingKeychain would be a new interface that TouchID-compatible providers could implement.

src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)

102-110: Migration implementation follows best practices.

The implementation:

  1. Correctly limits migrations to macOS (where TouchID is relevant)
  2. Collects vault IDs and names from settings
  3. Chains migration operations using CompletionStage to ensure sequential execution
  4. Executes migrations in a background thread to avoid blocking the UI

One potential enhancement would be to provide feedback to the user during migration.

Consider adding UI feedback during migration, especially for larger vaults:

 private void migrateKeychainEntries(Observable observable, KeychainAccessProvider oldProvider, KeychainAccessProvider newProvider) {
     //currently, we only migrate on macOS (touchID vs regular keychain)
     if (SystemUtils.IS_OS_MAC) {
         var idsAndNames = settings.directories.stream().collect(Collectors.toMap(vs -> vs.id, vs -> vs.displayName.getValue()));
         if (!idsAndNames.isEmpty()) {
+            // Show migration in progress indicator
+            Platform.runLater(() -> showMigrationStatus(true));
-            keychainMigrations = keychainMigrations.thenRunAsync(() -> KeychainManager.migrate(oldProvider, newProvider, idsAndNames), backgroundExecutor);
+            keychainMigrations = keychainMigrations.thenRunAsync(() -> KeychainManager.migrate(oldProvider, newProvider, idsAndNames), backgroundExecutor)
+                .whenComplete((result, ex) -> Platform.runLater(() -> showMigrationStatus(false)));
         }
     }
 }
 
+private void showMigrationStatus(boolean inProgress) {
+    // Display migration status in UI (e.g., progress indicator)
+}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0bcbf9a and eb0e630.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (5 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)
Learnt from: infeo
PR: cryptomator/cryptomator#3311
File: src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java:114-115
Timestamp: 2025-01-14T16:30:33.762Z
Learning: When migrating keychain entries in macOS, the order of operations must be: 1) load passphrase, 2) delete old entry, 3) store new entry. Attempting to store the new entry before deleting the old one would be counterproductive as the delete operation would remove the newly stored entry since they target the same keychain entry.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Compile and Test
🔇 Additional comments (8)
src/main/java/org/cryptomator/common/keychain/KeychainManager.java (5)

29-38: Thread safety enhancements look good.

Adding the ReentrantReadWriteLock and initializing it in the constructor provides proper thread safety for concurrent keychain operations. Additionally, the change from weakValues() to softValues() for the cache enhances performance by retaining values longer while still allowing them to be collected when memory is tight.


54-57: Method overload ensures backward compatibility.

This overload maintains compatibility with the original interface while directing calls to the enhanced implementation with TouchID support.


76-82: Lock usage pattern is consistent and correct.

The implementation consistently uses read locks for operations that don't modify the keychain (loadPassphrase) and write locks for operations that do (storePassphrase, deletePassphrase, changePassphrase). All locks are properly released in finally blocks, ensuring they don't remain held in case of exceptions.

Also applies to: 88-94, 99-107


174-176: Useful accessor for integration purposes.

This getter provides access to the underlying keychain implementation, which is necessary for the migration functionality in GeneralPreferencesController.


178-197: Migration logic handles keychain entries safely.

The migration method safely transfers entries between keychain providers with proper error handling and resource cleanup. It correctly avoids self-migration by checking if either provider is a KeychainManager.

The order of operations (load → store → delete) follows best practices to ensure data isn't lost during migration.

src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (3)

59-60: Good approach for tracking asynchronous migrations.

Initializing the keychainMigrations CompletionStage with a completed future provides a clean starting point for chaining migration operations.


62-71: Constructor updated to support keychain migrations.

The constructor now properly accepts and initializes the KeychainManager and ExecutorService needed for background migration operations.


91-91: Event listener correctly triggers migration.

Adding a listener to the keychain backend choice box ensures migrations are triggered when the user switches between providers.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)

117-122: ⚠️ Potential issue

Correct the migration order to avoid deleting newly stored entries.

Per the retrieved learnings, the correct sequence on macOS must be:

  1. Load old entry
  2. Delete old entry
  3. Store new entry

Currently, the code stores the new entry before deleting the old one, risking removal of the new entry.

-						newProvider.storePassphrase(v.id, v.name, wrapper);
-						oldProvider.deletePassphrase(v.id);
+						oldProvider.deletePassphrase(v.id);
+						newProvider.storePassphrase(v.id, v.name, wrapper);
🧹 Nitpick comments (5)
src/main/resources/css/light_theme.css (1)

361-366: Review: Verify Underline CSS Property Usage

The new hover selectors for notification labels are a nice touch to enhance visual feedback. However, the property -fx-underline: true; is raising a static analysis error ("Unknown property is not allowed"). Please verify that this property is valid in your JavaFX CSS context. If it is indeed supported by JavaFX but not recognized by the linter, consider adding an inline comment or linter directive (if available) to suppress this false positive. Alternatively, if -fx-underline is not valid, you may need to replace it with a correct property (e.g. using a different mechanism to underline text).

-	-fx-underline:true;
+	-fx-underline:true; /* NOSONAR: Valid JavaFX CSS property – suppress linter if false positive */
🧰 Tools
🪛 Biome (1.9.4)

[error] 364-364: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

src/main/resources/css/dark_theme.css (1)

362-366: Review: Validate Underline Effect in Dark Theme

Similar to the light theme, the dark theme now applies an underline effect on hover for notification labels via -fx-underline: true;. A static analysis hint flags this as an unknown property. Please confirm that this property is recognized in your JavaFX environment. If it is a false positive by the linter, a comment or linter suppression might be helpful. Otherwise, adjust the property to a valid alternative if necessary.

-	-fx-underline:true;
+	-fx-underline:true; /* NOSONAR: Valid in JavaFX CSS context – suppress linter warning */
🧰 Tools
🪛 Biome (1.9.4)

[error] 365-365: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

.github/ISSUE_TEMPLATE/bug.yml (1)

100-100: Ensure Newline at End of File

Static analysis reported a missing newline character at the end of the file. Adding a newline helps maintain consistency and avoids potential issues with some tools.

Please add a newline at the end of this file.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 100-100: no new line character at the end of file

(new-line-at-end-of-file)

src/main/resources/i18n/strings.properties (2)

107-110: Removed Key for Confirmation Button

The key for the vault removal confirmation—previously defined as removeVault.confirmBtn=Remove Vault—has been removed. This change standardizes the confirmation button behavior by relying on the generic button label (e.g. using generic.button.remove).


286-286: Updated Auto-Close Vault Text

The string for preferences.general.autoCloseVaults has been updated to:
Lock vaults without asking when quitting application
This wording more explicitly conveys that vaults will be automatically locked at application quit without prompting the user. Please verify that the phrasing aligns with the intended user experience and that any related UI components or localized overrides have been updated accordingly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb0e630 and fb56b61.

📒 Files selected for processing (18)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (4 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (5 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (3 hunks)
  • .github/ISSUE_TEMPLATE/bug.yml (2 hunks)
  • .github/ISSUE_TEMPLATE/feature.yml (1 hunks)
  • .github/workflows/debian.yml (1 hunks)
  • src/main/java/org/cryptomator/ui/addvaultwizard/ReadmeGenerator.java (1 hunks)
  • src/main/java/org/cryptomator/ui/dialogs/Dialogs.java (2 hunks)
  • src/main/java/org/cryptomator/ui/dialogs/SimpleDialog.java (1 hunks)
  • src/main/java/org/cryptomator/ui/dialogs/SimpleDialogController.java (2 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java (1 hunks)
  • src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java (3 hunks)
  • src/main/resources/css/dark_theme.css (1 hunks)
  • src/main/resources/css/light_theme.css (1 hunks)
  • src/main/resources/fxml/simple_dialog.fxml (2 hunks)
  • src/main/resources/i18n/strings.properties (1 hunks)
  • src/test/java/org/cryptomator/ui/addvaultwizard/ReadMeGeneratorTest.java (2 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)
Learnt from: infeo
PR: cryptomator/cryptomator#3311
File: src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java:114-115
Timestamp: 2025-01-14T16:30:33.762Z
Learning: When migrating keychain entries in macOS, the order of operations must be: 1) load passphrase, 2) delete old entry, 3) store new entry. Attempting to store the new entry before deleting the old one would be counterproductive as the delete operation would remove the newly stored entry since they target the same keychain entry.
🪛 YAMLlint (1.35.1)
.github/ISSUE_TEMPLATE/bug.yml

[error] 100-100: no new line character at the end of file

(new-line-at-end-of-file)

🪛 Biome (1.9.4)
src/main/resources/css/light_theme.css

[error] 364-364: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

src/main/resources/css/dark_theme.css

[error] 365-365: Unknown property is not allowed.

See CSS Specifications and browser specific properties for more details.
To resolve this issue, replace the unknown property with a valid CSS property.

(lint/correctness/noUnknownProperty)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Compile and Test
🔇 Additional comments (27)
src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java (1)

168-168:

Details

✅ Verification successful

Updated HTTP header name to follow convention

The header name has been changed from "deviceId" to "Hub-Device-ID", which follows a more standard naming convention for HTTP headers with the "Hub-" prefix. This ensures consistency in the API communication between the client and server.


🏁 Script executed:

#!/bin/bash
# Check if there are any other instances of "deviceId" as HTTP headers that should be updated
rg -i "header\(.*deviceId" --type java

Length of output: 156


HTTP header naming convention update verified

  • The updated header .header("Hub-Device-ID", deviceId) in src/main/java/org/cryptomator/ui/keyloading/hub/ReceiveKeyController.java at line 168 has been successfully verified.
  • The search confirms that this is the only instance where the header is set, ensuring consistency in API communication.
src/main/java/org/cryptomator/ui/addvaultwizard/ReadmeGenerator.java (2)

79-80: Enhanced handling of extended ASCII characters.

The addition of specific handling for characters with values between 128 and 255 (extended ASCII) improves the RTF document generation. These characters are now properly escaped with the \'XX format, where XX is the hexadecimal representation of the character value.


82-82: Modified Unicode character escaping for better RTF compatibility.

The change from directly escaping Unicode characters to using the \uc1\u prefix improves compatibility with RTF readers. The \uc1 control word in RTF indicates that one character follows each Unicode escape sequence, ensuring proper interpretation by RTF consumers.

src/test/java/org/cryptomator/ui/addvaultwizard/ReadMeGeneratorTest.java (2)

18-19: Updated test cases to match new character escaping implementation.

The test cases have been properly updated to match the changes in the ReadmeGenerator.appendEscaped() method:

  • Line 18: Updated expected output for 'ä' to use the new \'E4 format
  • Line 19: Updated expected output for the emoji to include the \uc1 prefix

This ensures the tests correctly validate the new behavior.


43-43: Updated assertion to match new Unicode escaping format.

The assertion has been updated to expect the new format with the \uc1 prefix for Unicode characters, maintaining consistency with the implementation changes in the ReadmeGenerator class.

src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java (3)

73-78: Simplified window positioning logic.

The window positioning logic has been streamlined to directly set position and size when saved values are available. The code now properly uses Math.clamp() to ensure the size stays within min/max bounds, improving the user experience by preventing windows from being too small or too large.


80-81: Added window showing event handler for display bounds checking.

Setting an event handler to check display bounds when the window is showing helps ensure the window is always visible to the user, even after application restarts or screen configuration changes.


92-123: Comprehensive display bounds checking to handle edge cases.

The new checkDisplayBounds method resolves two important issues:

  1. Windows-specific bug where minimized windows can get positioned at (-32000, -32000)
  2. Off-screen window positioning which can happen with multi-monitor setups or changed display configurations

The method intelligently:

  • Restores window position if it detects the Windows-specific bug
  • Centers the window on the primary display if it's off-screen
  • Attempts to preserve window size when repositioning if possible

This improves overall user experience by preventing windows from becoming unreachable.

src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (5)

31-33: Well-implemented asynchronous support for keychain migrations.

The addition of the ExecutorService and CompletionStage support is a good approach for handling potentially time-consuming keychain operations in the background. This prevents blocking the UI thread during migrations.

Also applies to: 48-48, 60-60, 65-65, 71-71


92-92: Good implementation of keychain migration trigger.

Adding a listener to the keychain backend choice box property is an effective way to trigger migrations when the user switches providers.


103-109: Clean implementation of MacOS-specific keychain migration.

The method correctly checks for MacOS and efficiently uses a record for vault ID and name combinations. This makes the code more readable and maintainable.


111-113: Well-designed sequential migration approach.

Chaining migrations with thenRunAsync ensures they execute sequentially, preventing potential conflicts and race conditions. The logging before migration begins provides useful operational visibility.


124-128: Good error handling for migration exceptions.

The code appropriately catches and logs exceptions during the migration process, ensuring that failures for one vault don't prevent migration of other vaults.

.github/workflows/debian.yml (1)

31-31: Update Environment Version: Confirm Ubuntu 22.04 Compatibility

The runs-on directive has been updated to use ubuntu-22.04, which should provide more up-to-date packages and security improvements. Please verify that all build dependencies (e.g., the OpenJDK PPA installation and related package commands) work as expected on this newer image.

.github/ISSUE_TEMPLATE/feature.yml (2)

3-3: Update "type" Field Definition

Changing the field from a list (e.g., labels: ["type:feature-request"]) to a simple string (type: "Feature") improves clarity and standardizes the template consistently with the bug report template.


5-11: Add Summary Input Field

The newly added summary input field (with id "summary") effectively captures a concise overview of the feature request. The placeholder and the required validation improve the user experience and data quality.

.github/ISSUE_TEMPLATE/bug.yml (2)

3-3: Update "type" Field Definition

The change from a list of labels to a simple string (type: "Bug") refines the interface and aligns it with the feature template, ensuring consistency across issue templates.


5-11: Add Summary Input Field

The addition of the summary field (id "summary") with clear attributes and required validation makes the bug report template more informative and user-friendly.

src/main/java/org/cryptomator/ui/dialogs/Dialogs.java (2)

41-41: Good standardization of button keys for consistency

Changing to the generic button key "generic.button.remove" improves UI consistency across different dialog types. This change aligns with best practices for UI localization by using shared resources for common actions.


57-57: Consistent use of generic button key

This change matches the earlier modification, standardizing both removal confirmation dialogs to use the same "generic.button.remove" key. This consistency enhances the user experience and simplifies localization maintenance.

src/main/java/org/cryptomator/ui/dialogs/SimpleDialogController.java (3)

17-17: Good addition of cancel button visibility control

Adding this field allows for conditional display of the cancel button, enhancing the flexibility of dialog presentations.


27-28: Clear initialization of cancel button visibility

The implementation correctly determines visibility based on whether cancelButtonText has content, which is a clean approach.


30-32: Well-implemented accessor for the new property

This getter method properly exposes the cancelButtonVisible state for binding in FXML, completing the implementation of the conditional cancel button feature.

src/main/resources/fxml/simple_dialog.fxml (2)

3-14: Reordered imports for better organization

The import statements have been reordered in a more logical manner, grouping related UI components together. While this doesn't affect functionality, it improves code readability.


44-44: Effective implementation of dynamic cancel button visibility

The cancel button now properly binds both its visibility and management to the controller property, ensuring it's completely removed from the layout when not needed. This is the correct approach as it affects both rendering and layout calculations.

src/main/java/org/cryptomator/ui/dialogs/SimpleDialog.java (2)

34-36: Robust handling of optional cancel button

The implementation now correctly handles the case when cancelButtonKey is null, which supports the new feature of making the cancel button optional. This approach prevents null pointer exceptions while maintaining backward compatibility.


126-131: Appropriately relaxed validation requirements

The removal of the cancelButtonKey null check is consistent with making the cancel button optional. This change properly complements the other modifications in this PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)

103-118: Optional user feedback for migration failures.

The logic correctly chains background migrations for macOS with thenRunAsync and logs warnings on failure. Consider optionally displaying an error dialog if migration fails, to inform users of partial or failed migration.

Here’s a sample snippet that shows how you might prompt users when an exception occurs:

+                } catch (KeychainAccessException e) {
+                    LOG.warn("Failed to migrate all entries...", e);
+                    Platform.runLater(() -> {
+                        // Pseudocode for user dialog
+                        showErrorDialog("Keychain migration error", e.getMessage());
+                    });
+                }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fb56b61 and 7ec3c5d.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (5 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (7 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)
Learnt from: infeo
PR: cryptomator/cryptomator#3311
File: src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java:114-115
Timestamp: 2025-01-14T16:30:33.762Z
Learning: When migrating keychain entries in macOS, the order of operations must be: 1) load passphrase, 2) delete old entry, 3) store new entry. Attempting to store the new entry before deleting the old one would be counterproductive as the delete operation would remove the newly stored entry since they target the same keychain entry.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build Cryptomator.app for arm64
  • GitHub Check: Compile and Test
🔇 Additional comments (16)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (6)

3-33: Imports look good.

The newly introduced imports (e.g., SystemUtils, KeychainManager, etc.) are relevant to macOS checks, keychain integration, concurrency, and remain consistent with the classes used in this file.


47-48: Field injection for KeychainManager and ExecutorService is valid.

Storing these instances at the class level is appropriate for background keychain operations.


60-60: Asynchronous tracking of keychain migrations.

Initializing keychainMigrations with a completed future is a neat approach for queuing tasks without special checks.


63-65: Constructor changes for additional dependencies.

Injecting KeychainManager and ExecutorService here cleanly enables background migration logic.


70-71: Assigning injected fields.

Storing keychain and backgroundExecutor in class fields ensures they remain accessible for asynchronous code.


92-92: Listener to trigger keychain migration on provider change.

Attaching this via addListener is a straightforward way to handle migrations dynamically.

src/main/java/org/cryptomator/common/keychain/KeychainManager.java (10)

5-18: New imports for Passphrase, Map, and ReentrantReadWriteLock.

These imports align with the addition of the passphrase wrapper and locking mechanism in this class.


25-25: Introduction of ReentrantReadWriteLock for concurrency.

Using a read-write lock is an appropriate choice to protect keychain operations, allowing concurrent reads and exclusive writes.


31-31: Soft reference cache.

Switching to softValues() can help keep passphrases in memory while still allowing garbage collection under memory pressure.


50-54: Refined storePassphrase signature.

The overload throwing KeychainAccessException and the interim ignored parameter approach appear consistent with evolving API needs.


58-66: Thread-safe store operation.

Acquiring the write lock around the underlying keychain call is correct. The final setPassphraseStored(key, true); outside the lock should not introduce issues, though keep in mind that concurrent write operations might overwrite the stored state if triggered repeatedly.


72-79: Thread-safe load operation.

Acquiring the read lock ensures consistent passphrase retrieval.


83-92: Thread-safe delete operation.

Similarly correct use of the write lock for deletions.


139-145: UI thread updates for stored passphrase properties.

Updating UI-bound properties within Platform.runLater is a proper JavaFX practice to avoid threading issues.


170-172: Exposing the underlying keychain provider.

Providing getKeychainImplementation() can be valuable for advanced UI or debugging needs.


174-187: Migration order is correct.

The static migrate() method properly (1) loads the passphrase, (2) deletes the old entry, and (3) stores the new entry, which aligns with the retrieved learnings and avoids accidental deletion of newly stored entries.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/main/java/org/cryptomator/JavaFXUtil.java (1)

11-20: Consider adding documentation for this utility method.

Since this is a utility method that will likely be used across multiple test classes, adding javadoc comments would improve maintainability. Include information about the return value meaning, potential exceptions, and the timeout behavior.

+/**
+ * Initializes the JavaFX platform if it's not already running.
+ * 
+ * @return true if the platform was successfully started within the timeout period, false otherwise
+ * @throws InterruptedException if the thread is interrupted while waiting for platform initialization
+ */
 public static boolean startPlatform() throws InterruptedException {
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)

111-117: Verify thread-safety in the migration implementation

The code correctly queues migrations using CompletionStage to prevent concurrent execution. However, verify that the KeychainManager.migrate implementation properly handles thread safety internally, especially around keychain access.

Also, consider adding user feedback during migration to indicate that an operation is in progress, as the migration could take time for users with many vaults.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ec3c5d and 42ec41b.

📒 Files selected for processing (6)
  • src/main/java/org/cryptomator/JavaFXUtil.java (1 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1 hunks)
  • src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java (1 hunks)
  • src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (7 hunks)
  • src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (3 hunks)
  • src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/main/java/org/cryptomator/ui/mainwindow/MainWindowController.java
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java
🧰 Additional context used
🧠 Learnings (1)
src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (1)
Learnt from: infeo
PR: cryptomator/cryptomator#3311
File: src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java:114-115
Timestamp: 2025-01-14T16:30:33.762Z
Learning: When migrating keychain entries in macOS, the order of operations must be: 1) load passphrase, 2) delete old entry, 3) store new entry. Attempting to store the new entry before deleting the old one would be counterproductive as the delete operation would remove the newly stored entry since they target the same keychain entry.
🔇 Additional comments (10)
src/main/java/org/cryptomator/JavaFXUtil.java (1)

7-21: Well-structured utility class for JavaFX platform initialization.

This utility class properly encapsulates JavaFX platform initialization with appropriate timeout handling and synchronization. The implementation effectively prevents application hangs by using a CountDownLatch with a timeout.

A few observations:

  • The private constructor prevents instantiation, which is appropriate for a utility class
  • Exception handling gracefully handles the case when the platform is already running
  • The 5-second timeout is reasonable for platform initialization
src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (4)

4-4: Good import of the new utility class.

Appropriate import of the newly created JavaFXUtil class.


22-26: Well-designed platform initialization using BeforeAll.

Good implementation of JavaFX platform initialization at the class level using @BeforeAll. The use of Assumptions.assumeTrue() ensures tests are skipped gracefully if the platform fails to start.


36-36: Appropriate change from static to non-static nested class.

Removing the static modifier from the WhenObservingProperties nested class is appropriate since the platform initialization has been moved to the class level.


44-44: Minor formatting improvement.

The addition of a space before the "bar" parameter improves code readability.

src/main/java/org/cryptomator/ui/preferences/GeneralPreferencesController.java (5)

3-5: Appropriate import additions for new functionality

The new imports support the macOS TouchID integration by adding necessary dependencies for system detection, keychain management, concurrency handling, and exception management. This aligns well with the PR objectives.

Also applies to: 10-11, 20-21, 30-33


47-48: Proper implementation of field injection for dependency management

The new fields for KeychainManager and ExecutorService are appropriately defined as final fields, promoting immutability. The CompletionStage for tracking migrations is well-initialized to a completed future, ensuring proper chaining of async operations.

Also applies to: 60-60


63-65: Constructor updated correctly to support new dependencies

The constructor properly initializes the newly added fields. Parameters are aligned with dependency injection best practices, maintaining the class's modularity.

Also applies to: 70-71


92-92: Listener setup for keychain provider changes

The listener properly connects UI changes to backend functionality, triggering migration when the user selects a different keychain provider.


103-120:

Details

✅ Verification successful

Well-implemented asynchronous keychain migration with OS-specific handling

The migration method is well-structured:

  • Correctly checks for macOS environment
  • Properly collects required vault information
  • Uses async execution to prevent blocking the UI thread
  • Appropriately chains migrations using CompletionStage
  • Includes good error handling and logging

However, ensure the KeychainManager.migrate implementation follows the correct order of operations.


🏁 Script executed:

#!/bin/bash
# Find and inspect the KeychainManager.migrate implementation
rg -A 15 "static.*migrate" --type java

Length of output: 1910


Async keychain migration verified – No further changes needed

The keychain migration in GeneralPreferencesController is implemented correctly:

  • It correctly checks for a macOS environment.
  • Vault information is properly collected and logged.
  • Asynchronous execution via chaining with CompletionStage prevents UI blocking.
  • Error handling is robust.

Verification of KeychainManager.migrate confirms that the operations execute in the correct order: it loads the passphrase, deletes it from the old provider, and then stores it in the new provider—this ordering is intentional to handle cases where both providers might target the same underlying store.

@infeo infeo linked an issue Mar 12, 2025 that may be closed by this pull request
2 tasks done
@infeo infeo added the os:mac label Mar 12, 2025
@infeo
infeo merged commit 2d33d02 into develop Mar 17, 2025
@infeo
infeo deleted the feature/touch-id branch March 17, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adding Support for Touch ID on MacBooks

2 participants