Skip to content

Add Touch ID and Windows Hello support - #3311

Closed
purejava wants to merge 53 commits into
cryptomator:developfrom
purejava:2ndfactor
Closed

purejava wants to merge 53 commits into
cryptomator:developfrom
purejava:2ndfactor

Conversation

@purejava

@purejava purejava commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor

Depends on cryptomator/integrations-mac#36. Obsolete.

Depends on cryptomator/integrations-api#41.
Depends on cryptomator/integrations-mac#58.
Depends on cryptomator/integrations-win#83.

This PR war started as a base to make Touch ID on Mac available. Meanwhile, Windows Hello support was realized by another PR and this PR is the base for both, Touch ID on Mac and Windows Hello.

@coderabbitai

coderabbitai Bot commented Feb 4, 2024 •

Copy link
Copy Markdown

Walkthrough

The pull request introduces significant updates to the Cryptomator application's keychain management, focusing on integrating Windows Hello and enhancing macOS keychain migration functionalities. Key changes include:

  • The KeychainManager class has been updated to replace the Guava caching library with Caffeine, modifying method signatures to accommodate new parameters and functionality.
  • The .github/workflows/win-exe.yml file has been enhanced to include a Java option for specifying Windows Hello keychain paths.
  • The Environment class has been extended with a new constant and method to handle Windows Hello keychain paths.
  • The GeneralPreferencesController has been modified to include a method for migrating keychain entries on macOS, triggered by user interface changes.
  • The MasterkeyFileLoadingStrategy class has improved error handling and logic flow for saving passwords to the system keychain.

These changes collectively introduce a new system property, cryptomator.integrationsWin.windowsHelloKeychainPaths, for specifying Windows Hello keychain JSON file locations, while maintaining the existing architectural structure.

Possibly related PRs

  • Feature: Use system certificate stores/custom pkcs12 file #3675: The changes in this PR involve the introduction of the SSLContextProvider interface and its implementations for different operating systems, which relates to the overall keychain management and security context in the application, similar to the updates made in the KeychainManager class in the main PR.

Suggested reviewers

  • overheadhunter
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @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.

@purejava

purejava commented Feb 4, 2024

Copy link
Copy Markdown
Contributor Author

Adresses #2180.

@purejava

purejava commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor Author

I wonder whether this implementation does suffice from the security point of view. You can enable Touch ID on capable devices, which unlocks vaults only after the fingerprint was provided, but this feature can be disabled in the prefs.

Maybe only allow to disable Touch ID via a successful Touch ID authentication?

Discussion welcome!

Edit: added some more thoughts.

@tobihagemann

Copy link
Copy Markdown
Member

I'm wondering if we should "just" refactor org_cryptomator_macos_keychain_MacKeychain_Native.m from the deprecated SecKeychain API to the "new" SecItem API.

With SecItemAdd(), we could optionally set access control via SecAccessControlCreateWithFlags() and use the flag kSecAccessControlUserPresence (macOS 10.10+) or even kSecAccessControlBiometryCurrentSet (macOS 10.13.4+).

With that, I don't think we even need a new "two-factor" API because these APIs will take care of the Touch ID prompts. And also make sure that the password is only accessible via Touch ID. I believe this is the "most secure" way instead of splitting up saving the password and prompting for Touch ID.

What do you think?

@overheadhunter

Copy link
Copy Markdown
Member

refactor [...] from the deprecated SecKeychain API to the "new" SecItem API

I would support this, however I am wondering if items stores with the old API are accessible from the new one.

It is certainly more secure to let the OS combine authentication and secret storage instead of triggering biometric authentication ourselves without it being really required in order to access stored secrets.

@tobihagemann

Copy link
Copy Markdown
Member

I would support this, however I am wondering if items stores with the old API are accessible from the new one.

It could be possible. If I'm understanding TN3137 correctly, all these different keychain APIs target the same file-based keychain. The new API can also target the data protection keychain (which is recommended but not the default yet).

If it doesn't work, we could migrate the keychain entries. All in all, this would require some experimentation.

@purejava

purejava commented Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

I'm wondering if we should "just" refactor org_cryptomator_macos_keychain_MacKeychain_Native.m from the deprecated SecKeychain API to the "new" SecItem API.

@tobihagemann @overheadhunter I raise my hand and take care of it. I already started implementing the Objective-C code.

@tobihagemann

Copy link
Copy Markdown
Member

Thank you! 🙇‍♂️ Just a quick tip: I'm willing to raise the minimum version to 10.13.4 (currently, it's 10.13), so that you don't have to do if/else logic for this feature.

@purejava

purejava commented Feb 9, 2024

Copy link
Copy Markdown
Contributor Author

Thank you @tobihagemann, that's a good advice!

@overheadhunter

Copy link
Copy Markdown
Member

Despite the impl being in ObjC, if the API is C compatible, we could use Panama :)

@purejava

This comment was marked as outdated.

@purejava

purejava commented Feb 11, 2024 •

Copy link
Copy Markdown
Contributor Author

Writing the code was no problem, but I got stuck with configuring Xcode the right way. Googling for hours did not help.

What's the problem? The code seems to work. Reading "old" keychain items that were created before without SecAccessControlCreateWithFlags() does work. They can be read, a pop-up is shown before you are allowed to do so:
Access old entry with SecItemAPI
But writing causes trouble.

10:16:55.905 [App Background Thread 002] ERROR o.c.ui.keyloading.KeyLoadingStrategy - Failed to store passphrase in system keychain.
org.cryptomator.integrations.keychain.KeychainAccessException: Failed to store password. Error code -34018
	at org.cryptomator.integrations.mac@1.3.0-SNAPSHOT/org.cryptomator.macos.keychain.MacSystemKeychainAccess.storePassphrase(MacSystemKeychainAccess.java:43)
	at org.cryptomator.desktop/org.cryptomator.common.keychain.KeychainManager.storePassphrase(KeychainManager.java:48)
	at org.cryptomator.desktop/org.cryptomator.ui.keyloading.masterkeyfile.MasterkeyFileLoadingStrategy.savePasswordToSystemkeychain(MasterkeyFileLoadingStrategy.java:117)
	at org.cryptomator.desktop/org.cryptomator.ui.keyloading.masterkeyfile.MasterkeyFileLoadingStrategy.cleanup(MasterkeyFileLoadingStrategy.java:107)
	at org.cryptomator.desktop/org.cryptomator.ui.keyloading.KeyLoadingStrategy.use(KeyLoadingStrategy.java:89)
	at org.cryptomator.desktop/org.cryptomator.ui.unlock.UnlockWorkflow.call(UnlockWorkflow.java:70)
	at org.cryptomator.desktop/org.cryptomator.ui.unlock.UnlockWorkflow.call(UnlockWorkflow.java:31)
	at javafx.graphics/javafx.concurrent.Task$TaskCallable.call(Task.java:1399)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
	at java.base/java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java:718)
	at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
10:16:55.906 [JavaFX Application Thread] INFO  o.c.ui.unlock.UnlockWorkflow - Unlock of 'Test' succeeded.

Error code 34018 means errSecMissingEntitlement. Apple has the restriction, that keychain sharing needs to be configured for your library. Without it, writing to the keychain gets refused. I verified that by creating a macOS > App project, that has the "Signing & Capabilities" tab. Once the Keychain Group is configured, writing works.

But: where to configure this for a library? The Xcode library code project does not have the "Signing & Capabilities" tab (picture). Are there Xcode cracks around, @tobihagemann maybe? 😄

EDIT: configuring this for a library is the wrong approach, see #3311 (comment) below.

@purejava

This comment was marked as outdated.

@tobihagemann

Copy link
Copy Markdown
Member

Yeah, code signing is no fun. 😅 We are enrolled in the Apple Developer program, but we can't share the certificate publicly. To be honest, I don't even know what we should do exactly. Cryptomator, the main app, doesn't have any code signing set up for development. It will only be code signed during distribution. I have the feeling, even with the certificate installed, I have to build the app and can't test this by running it in the IDE.

Apart from that: Total Java noob here, but I've looked through your commits and the native integration seems totally different from the rest. Did we use JNI in the past and you're now using JNA? I'm just wondering if this is necessary. It seems like that we would then distribute two .dylibs.

@purejava

Copy link
Copy Markdown
Contributor Author

Yeah, code signing is no fun. 😅 We are enrolled in the Apple Developer program, but we can't share the certificate publicly. To be honest, I don't even know what we should do exactly. Cryptomator, the main app, doesn't have any code signing set up for development. It will only be code signed during distribution. I have the feeling, even with the certificate installed, I have to build the app and can't test this by running it in the IDE.

Yeah, nobody should share her certificate, that's for sure and that wasn't my intention, of course.

I know, that Cryptomator uses the certificate for signing for distribution, not before. Unfortunately, if we want to use the new SecItem API as discussed before, this requires an entitlement. AFAIK this is bound to code signing in the Apple universe, but I could be wrong on this point.

What I asked for is to take the ready to compile code from this branch and use it as a dependency for Cryptomator run in an IDE on Mac. As the code contains me as the "Development team" (DEVELOPMENT_TEAM = AC7BAYY98P;), this needs to be changed to "Cryptomator", before the Maven install. And see if this fixes the sign error mentioned above.

Apart from that: Total Java noob here, but I've looked through your commits and the native integration seems totally different from the rest. Did we use JNI in the past and you're now using JNA? I'm just wondering if this is necessary. It seems like that we would then distribute two .dylibs.

Yes, it's two libs. For the question on why JNA and not Panama, please see my #3311 (comment) before. But you mentioned JNI. This requires C code and someone would need to write it. I am not capable of doing that. 🤷🏻‍♂️

@purejava

This comment was marked as outdated.

@purejava

This comment was marked as outdated.

@purejava

purejava commented May 27, 2024 •

Copy link
Copy Markdown
Contributor Author

While still working on Touch ID support, I'd like to offer the tested and mature code so far to replace the deprecated SecKeychain with SecItem (without SecAccessControl to get Touch ID functionality).

@purejava

purejava commented Jun 9, 2024

Copy link
Copy Markdown
Contributor Author

I ruled out the Error code 34018 meaning errSecMissingEntitlement problems. First, it must be noted, that configuring this for a library is the wrong approach: If you’re building library code, its data protection keychain access is determined by the entitlements of the host process’s main executable.

The correct entitlement for accessing data protection keychain items is the following:

<key>keychain-access-groups</key>
<array/>

See: The data protection keychain uses keychain access groups, supplemented by an optional access control object (SecAccessControl).

In addition to that, we need a provisioning profile: In contrast, restricted entitlements must be authorized by a provisioning profile. This is an important security feature on macOS. For example, the fact that the keychain-access-groups entitlement must be authorized by a profile means that other developers can’t impersonate your app in order to steal its keychain items.

macOS expects to find the profile at Cryptomator.app/Contents/embedded.provisionprofile.

Finally, the Cryptomator entitlements need to match the entitlements in the provisioning profile, namely the keys com.apple.application-identifier and com.apple.developer.team-identifier need to be added to the Cryptomator entitlements:

index 22d0f6954d..178c0fc974 100644
--- a/dist/mac/Cryptomator.entitlements
+++ b/dist/mac/Cryptomator.entitlements
@@ -2,6 +2,10 @@
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
+	<key>com.apple.application-identifier</key>
+	<string>XXXXXXXXXX.net.plawetzki.cryptomator</string>
+	<key>com.apple.developer.team-identifier</key>
+	<string>XXXXXXXXXX</string>
 	<key>com.apple.security.cs.allow-jit</key>
 	<true/>
 	<key>com.apple.security.cs.allow-unsigned-executable-memory</key>

The former needs to match the App ID in the provisioning profile:

Bildschirmfoto 2024-06-09 um 18 28 57

@tobihagemann

Copy link
Copy Markdown
Member

Thank you for the info, @purejava. Took me some time to look into it, sorry for that.

I did the "risky" thing and just pushed something in develop, see 45c7d2b. I didn't want to expose any identifiers in order to be "flexible" and I've read that the provisioning profile should be kept secret. Even though I don't quite understand the latter because the profile has to be embedded in the .app container anyway, which is... public.

In order to build the application locally, you have to put the provisioning profile in /dist/mac/embedded.provisionprofile (which is gitignored so that you don't accidentally push it). And then use the build.sh script with the added -t option to specify the team identifier.

In the CI build, I've made the adjustments that the provisioning profile (decoded as base64) and team identifier are saved as secret variables.

And I've also added an entry to the keychain-access-groups array, because I didn't know why it should be empty.

Does that all make sense? 😄

@purejava

Copy link
Copy Markdown
Contributor Author

Thank you for the info, @purejava. Took me some time to look into it, sorry for that.

You are welcome @tobihagemann. Absolutely no need to worry - I am glad that you could look into it!

I did the "risky" thing and just pushed something in develop, see 45c7d2b. I didn't want to expose any identifiers in order to be "flexible" and I've read that the provisioning profile should be kept secret. Even though I don't quite understand the latter because the profile has to be embedded in the .app container anyway, which is... public.

I looked through your change and yes: that's the way it should be done, from the DevOps point of view as well as from the security point of view. I've read too, that the profile should not be committed and kept secret, but you are right: it's part of the final app. 🤷🏻

In order to build the application locally, you have to put the provisioning profile in /dist/mac/embedded.provisionprofile (which is gitignored so that you don't accidentally push it). And then use the build.sh script with the added -t option to specify the team identifier.

Yes, I saw that in your code.

In the CI build, I've made the adjustments that the provisioning profile (decoded as base64) and team identifier are saved as secret variables.

Yes, I saw that in your code too.

And I've also added an entry to the keychain-access-groups array, because I didn't know why it should be empty.

I think we need to test that. Meanwhile I noticed, that a different group is used in the iOS app. Creating a vault on iOS and open it on macOS and vice versa should be a good starting point.

Does that all make sense? 😄

That all makes perfectly sense! 😄
One thing that is missing from my point of view is that the build.sh lacks code signing we have in the GitHub workflow for the dmg and I noticed that we need this with the enhanced entitlements containing the keychain-access-groups:

# codesign
if [ -n "${CODESIGN_IDENTITY}" ]; then
+   echo "Codesigning jdk files..."
+   find ${APP_NAME}.app/Contents/runtime/Contents/Home/lib/ -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
+   find ${APP_NAME}.app/Contents/runtime/Contents/Home/lib/ -name 'jspawnhelper' -exec codesign --force -o runtime -s ${CODESIGN_IDENTITY} {} \;
+   echo "Codesigning jar contents..."
    find ${APP_NAME}.app/Contents/runtime/Contents/MacOS -name '*.dylib' -exec codesign --force -s ${CODESIGN_IDENTITY} {} \;
    for JAR_PATH in `find ${APP_NAME}.app -name "*.jar"`; do
    if [[ `unzip -l ${JAR_PATH} | grep '.dylib\|.jnilib'` ]]; then

@tobihagemann

Copy link
Copy Markdown
Member

Ah, thanks, fixed in d60ced5. Probably never noticed it because I use Temurin locally and I believe we had to make the changes when we switched to Zulu in the CI builds (I don't know why) or for whatever different reason.

I think we need to test that. Meanwhile I noticed, that a different group is used in the iOS app. Creating a vault on iOS and open it on macOS and vice versa should be a good starting point.

I don't think that we need to test that scenario. The keychain access group on iOS is used to share data between the host application and the app extensions (file provider and file provider UI). Since we don't make the keychain entries "synchronizable" (kSecAttrSynchronizable), the keychain entries should only be available on the device. And I think that it should stay that way and should be the same on macOS. Saved passwords should only be saved on the device itself. This feature is basically "optional" and only a convenience method for a faster unlock on a trusted device, which shouldn't influence other devices in any way.

@purejava

Copy link
Copy Markdown
Contributor Author

I don't think that we need to test that scenario. The keychain access group on iOS is used to share data between the host application and the app extensions (file provider and file provider UI). Since we don't make the keychain entries "synchronizable" (kSecAttrSynchronizable), the keychain entries should only be available on the device. And I think that it should stay that way and should be the same on macOS. Saved passwords should only be saved on the device itself. This feature is basically "optional" and only a convenience method for a faster unlock on a trusted device, which shouldn't influence other devices in any way.

Good. When it's already decided, that the keychain entries won't be "synchronizable" for now, we can keep the entitlements as they are.

@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

Outside diff range, codebase verification and nitpick comments (2)
src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java (2)

3-3: Remove unused import.

The import org.apache.commons.lang3.SystemUtils is not used in the current file.

- import org.apache.commons.lang3.SystemUtils;

54-62: Clarify the TODO comment and improve code readability.

The TODO comment should be more specific about what needs to be adjusted. Additionally, consider improving the readability of the conditional block by using a single line for setting the visibility property.

-		// ToDo Remove or adjust, as soon as there are implementations for integrations-api
-		//  KeychainAccessProvider:storePassphraseForAuthenticatedUser for other OSes
+		// TODO: Remove or adjust when implementations for integrations-api KeychainAccessProvider:storePassphraseForAuthenticatedUser are available for other OSes.
		if (!SystemUtils.IS_OS_MAC) {
-			needAuthenticatedUserCheckbox.visibleProperty().set(false);
+			needAuthenticatedUserCheckbox.setVisible(false);
		}
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d60ced5 and efd4bf0.

Files selected for processing (9)
  • pom.xml (1 hunks)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (1 hunks)
  • src/main/java/org/cryptomator/common/settings/VaultSettings.java (5 hunks)
  • src/main/java/org/cryptomator/common/settings/VaultSettingsJson.java (1 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1 hunks)
  • src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java (4 hunks)
  • src/main/resources/fxml/vault_options_masterkey.fxml (2 hunks)
  • src/main/resources/i18n/strings.properties (1 hunks)
  • src/test/java/org/cryptomator/common/keychain/MapKeychainAccess.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • src/main/resources/i18n/strings.properties
Additional comments not posted (15)
src/test/java/org/cryptomator/common/keychain/MapKeychainAccess.java (1)

31-34: LGTM!

The method storePassphraseForAuthenticatedUser is a straightforward delegation to the existing storePassphrase method, enhancing code clarity.

src/main/resources/fxml/vault_options_masterkey.fxml (1)

34-36: LGTM!

The new CheckBox element with fx:id="needAuthenticatedUserCheckbox" is well-integrated into the existing layout.

src/main/java/org/cryptomator/common/settings/VaultSettingsJson.java (1)

68-69: LGTM!

The new boolean field needAuthenticatedUser is correctly annotated with @JsonProperty and initialized with a default value.

src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java (1)

33-33: Ensure the new CheckBox property is initialized.

The needAuthenticatedUserCheckbox property is declared but not initialized. Ensure it is properly initialized in the FXML file.

Verification successful

Let's expand the search to include all file types and refine the search pattern to ensure we capture any initialization of the needAuthenticatedUserCheckbox.


The needAuthenticatedUserCheckbox is properly initialized.

The needAuthenticatedUserCheckbox is declared in the MasterkeyOptionsController.java file and initialized in the vault_options_masterkey.fxml file as follows:

  • src/main/resources/fxml/vault_options_masterkey.fxml: <CheckBox text="%vaultOptions.masterkey.needAuthenticatedUser" fx:id="needAuthenticatedUserCheckbox"/>
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `needAuthenticatedUserCheckbox` is properly initialized in the FXML file.

# Test: Search for the `needAuthenticatedUserCheckbox` in the FXML file. Expect: The checkbox should be declared and initialized.
rg --type xml 'needAuthenticatedUserCheckbox'

Length of output: 45


Script:

#!/bin/bash
# Description: Verify that the `needAuthenticatedUserCheckbox` is properly initialized in the codebase.

# Test: Search for the `needAuthenticatedUserCheckbox` in all files. Expect: The checkbox should be declared and initialized.
rg 'needAuthenticatedUserCheckbox'

Length of output: 1027

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

53-56: Ensure proper exception handling.

The new method storePassphraseForAuthenticatedUser correctly throws KeychainAccessException. Ensure that this method is called in contexts where this exception is properly handled.

Verification successful

Proper exception handling is implemented.

The method storePassphraseForAuthenticatedUser is correctly wrapped in try-catch blocks that handle KeychainAccessException in both MasterkeyOptionsController.java and MasterkeyFileLoadingStrategy.java.

  • src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `storePassphraseForAuthenticatedUser` method is called in contexts where `KeychainAccessException` is properly handled.

# Test: Search for the method usage. Expect: The method should be called in contexts where `KeychainAccessException` is properly handled.
rg --type java 'storePassphraseForAuthenticatedUser'

Length of output: 1122


Script:

#!/bin/bash
# Description: Verify that the `storePassphraseForAuthenticatedUser` method is called in contexts where `KeychainAccessException` is properly handled.

# Check for exception handling in MasterkeyOptionsController.java
rg -A 5 'storePassphraseForAuthenticatedUser' src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java

# Check for exception handling in MasterkeyFileLoadingStrategy.java
rg -A 5 'storePassphraseForAuthenticatedUser' src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java

Length of output: 1007

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

117-121: Verify the conditional logic for storing passphrases.

The conditional logic for storing passphrases based on the vault's settings looks correct. Ensure that the needAuthenticatedUser setting is properly initialized and used.

Verification successful

The conditional logic for storing passphrases based on the vault's settings is correct.

The needAuthenticatedUser setting is properly initialized and used across the codebase.

  • VaultSettings.java: Initialization
  • VaultSettingsJson.java: Serialization/Deserialization
  • MasterkeyOptionsController.java: UI Binding and Event Handling
  • MasterkeyFileLoadingStrategy.java: Conditional Logic
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `needAuthenticatedUser` setting is properly initialized and used.

# Test: Search for the initialization and usage of `needAuthenticatedUser`. Expect: The setting should be properly initialized and used.
rg --type java 'needAuthenticatedUser'

Length of output: 2147

src/main/java/org/cryptomator/common/settings/VaultSettings.java (5)

43-43: LGTM! Added constant for default authenticated user requirement.

The new constant DEFAULT_NEED_AUTHENTICATED_USER is appropriately added with a default value of false.


62-62: LGTM! Added property for authenticated user requirement.

The new property needAuthenticatedUser is appropriately added to the VaultSettings class.


89-89: LGTM! Initialized authenticated user requirement property in constructor.

The needAuthenticatedUser property is correctly initialized in the constructor using the value from the VaultSettingsJson object.


105-105: LGTM! Included authenticated user requirement property in observables.

The needAuthenticatedUser property is correctly included in the array of observables returned by the observables method.


136-136: LGTM! Included authenticated user requirement property in serialized output.

The needAuthenticatedUser property is correctly included in the serialized output of the VaultSettings class.

pom.xml (4)

37-37: LGTM! Updated Cryptomator integrations version.

The version is updated from 1.3.1 to 1.4.0-SNAPSHOT, likely including new features or bug fixes.


38-38: LGTM! Updated Windows integrations version.

The version is updated from 1.2.5 to 1.3.0-SNAPSHOT, likely including new features or bug fixes.


39-39: LGTM! Updated macOS integrations version.

The version is updated from 1.2.4 to 1.3.0-SNAPSHOT, likely including new features or bug fixes.


40-40: LGTM! Updated Linux integrations version.

The version is updated from 1.4.5 to 1.5.0-SNAPSHOT, likely including new features or bug fixes.

@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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between efd4bf0 and 0e3f6a1.

Files selected for processing (1)
  • src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/cryptomator/ui/vaultoptions/MasterkeyOptionsController.java

@purejava

purejava commented Aug 4, 2024 •

Copy link
Copy Markdown
Contributor Author
Screenshot 2024-08-04 at 14 03 55

This is ready for review, and I'd like to request a review from someone, who finds the time, maybe @tobihagemann, @overheadhunter, ... 😄.

It took me a while to figure out, on how to minimize the amount of Touch ID pop-ups that come up on unlocking a vault. After implementing this, four succeeding Touch ID pop-ups had to overcome: check_if_passphrase_is_stored, load the passphrase, load it again to update it and update it. This can be done be reusing LAContext and is solved now. But let's start at the beginning ...

This PR is intended to solve #2180, which includes two requirements:

  • use Touch ID to unlock a vault as a speedy way to do so, without the necessity to enter a password
  • use Touch ID to allow accessing a vault only by a user authenticated via Touch ID

As the first bullet point is already implemented in the app with the normal keychain functionality, it is not possible to do so without providing a password. The whole concept of the app is designed around a password that protects a vault.

Design
Having these requirements, I decided to:

  • add a feature per vault to require access to this vault only after having authenticated via Touch ID or a password (whatever is available); this way, a user can decide, what vault needs extra security
Screenshot 2024-08-04 at 14 03 55
  • make it possible to seamlessly switch between the old mode (without user authentication) and the new mode
  • implement it in a way, that using the new mode does not slow down the app, e.g. needs extra steps
  • an API change is required, as the new method KeechainAccessProvider#storePassphraseForAuthenticatedUser is needed; this is a less invasive approach than inventing a new service
  • the new method can be used with Windows Hello and PolkitDbus on Linux to access secured keychain items that require authentication
  • a hack has been used to restrict this new functionality to Mac, until the other implementations for Windows and Linux are done

Features

  • authentication on Mac is provided by Touch ID (in case it's available and configured) or by password as a fallback (e.g. for iMac without Touch ID)
  • existing keychain items do work flawlessly; on enabling this new feature, an existing keychain item gets changed to a secured one, that requires authentication and vice versa

Maintenance

  • it was necessary to fix org_cryptomator_macos_keychain_MacKeychain_Native#Java_org_cryptomator_macos_keychain_MacKeychain_00024Native_deletePassword, so that it deletes keychain entries with additional kSecAttrAccessControl attributes as well
  • note: PR 46 works well as a stand alone, as it only handles keychain items without additional kSecAttrAccessControl attributes

Thanks.

@purejava

purejava commented Aug 4, 2024

Copy link
Copy Markdown
Contributor Author

@tobihagemann

Copy link
Copy Markdown
Member

Thank you! have some questions based on your description. I must admit that I didn't test it yet and wasn't able to figure it out by looking at the code, so I'll just ask:

  1. You mentioned that the user is able to switch between the old mode and the new mode. What happens exactly when they switch from the old mode to the new mode and vice versa? Is there a Touch ID pop-up in each direction?
  2. What happens when a user sets everything up with Touch ID and then changes the keyboard to something without Touch ID (or deactivates Touch ID in general)? Does Cryptomator then just ask for the password again?
  3. Is it possible to make the "new mode" the new default when enabling the checkmark in the "unlock vault" dialog?

And I'd suggest to use the term "Touch ID" in the UI on macOS, so that users instantly know what the new setting is about.

@purejava

purejava commented Dec 2, 2024

Copy link
Copy Markdown
Contributor Author

All done @infeo. This is a working implementation for Windows Hello and Touch ID on Mac.

@infeo infeo linked an issue Dec 15, 2024 that may be closed by this pull request
2 tasks done

@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/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1)

115-121: Consider adding biometric authentication retry logic.

For a better user experience with Touch ID/Windows Hello, consider implementing retry logic when biometric authentication fails.

Example implementation:

 try {
     if (keychain.isSupported() && !keychain.isPassphraseStored(vault.getId())) {
+        int maxRetries = 3;
+        int attempts = 0;
+        KeychainAccessException lastException = null;
+        while (attempts < maxRetries) {
             try {
                 keychain.storePassphrase(vault.getId(), vault.getDisplayName(), passphrase,
                     vault.getVaultSettings().needAuthenticatedUser.get());
+                break;
             } catch (KeychainAccessException e) {
+                lastException = e;
+                if (e.getMessage().contains("authentication")) {
+                    attempts++;
+                    if (attempts < maxRetries) {
+                        LOG.info("Biometric authentication failed, attempt {}/{}", attempts, maxRetries);
+                        Thread.sleep(1000); // Brief delay before retry
+                        continue;
+                    }
+                }
+                throw e;
             }
+        }
+        if (lastException != null) {
+            throw lastException;
+        }
     }
 } catch (KeychainAccessException e) {
     LOG.error("Failed to store passphrase in system keychain.", e);
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be59097 and 526c397.

📒 Files selected for processing (2)
  • pom.xml (1 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1 hunks)
🔇 Additional comments (4)
pom.xml (1)

38-39: Version updates align with biometric authentication features.

The version updates for Windows (1.4.0) and macOS (1.3.0) integrations correspond to the addition of Windows Hello and Touch ID support respectively.

Let's verify these versions are published and check for any security advisories:

Suggestion: Consider adding a comment in the properties section documenting the security-related changes in these versions:

 <!-- cryptomator dependencies -->
 <cryptomator.cryptofs.version>2.7.1</cryptomator.cryptofs.version>
 <cryptomator.integrations.version>1.4.0</cryptomator.integrations.version>
+<!-- Windows Hello support added in 1.4.0 -->
 <cryptomator.integrations.win.version>1.4.0</cryptomator.integrations.win.version>
+<!-- Touch ID support added in 1.3.0 -->
 <cryptomator.integrations.mac.version>1.3.0</cryptomator.integrations.mac.version>
✅ Verification successful

✓ Dependencies verified: versions exist and no security advisories found

Both Windows (1.4.0) and macOS (1.3.0) integration versions are published in Maven Central and have no reported security vulnerabilities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the published versions and security status of the integration dependencies

# Check if the Windows integration version exists in Maven Central
echo "Checking Windows integration version..."
curl -s "https://search.maven.org/solrsearch/select?q=g:org.cryptomator+AND+a:integrations-win+AND+v:1.4.0" | jq '.response.numFound'

# Check if the macOS integration version exists in Maven Central
echo "Checking macOS integration version..."
curl -s "https://search.maven.org/solrsearch/select?q=g:org.cryptomator+AND+a:integrations-mac+AND+v:1.3.0" | jq '.response.numFound'

# Check for security advisories
echo "Checking for security advisories..."
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: MAVEN, package: "org.cryptomator:integrations-win") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: MAVEN, package: "org.cryptomator:integrations-mac") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 1261

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

115-119: Add authentication validation before storing passphrase.

While the code correctly checks if the keychain is supported, it should verify that the user is authenticated before attempting to store the passphrase, especially when Touch ID is enabled.

Run this script to check for other instances where authentication validation might be missing:

#!/bin/bash
# Search for keychain storage calls without authentication checks
ast-grep --pattern 'storePassphrase($$$)' 

119-121: Enhance error handling for authentication failures.

The current error handling doesn't distinguish between different types of keychain access failures, which is particularly important for biometric authentication failures.


115-119: ⚠️ Potential issue

Add missing authentication requirement for biometric validation.

The storePassphrase call is missing the authentication requirement parameter needed for Touch ID/Windows Hello support. This could bypass biometric authentication requirements.

Apply this diff to restore the authentication requirement:

 if (keychain.isSupported() && !keychain.isPassphraseStored(vault.getId())) {
-    keychain.storePassphrase(vault.getId(), vault.getDisplayName(), passphrase);
+    keychain.storePassphrase(vault.getId(), vault.getDisplayName(), passphrase, 
+        vault.getVaultSettings().needAuthenticatedUser.get());
 }

Likely invalid or redundant comment.

@infeo

infeo commented Jan 14, 2025

Copy link
Copy Markdown
Member

@purejava I updated the dependencies, so that it works out of the box. Additionally, i fixed in dc16c96 the redundant-passphrase-storage-issue.

I need to make some additional tests about UI reactivity when changing the provider.

@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/mainwindow/VaultDetailLockedController.java (1)

33-36: Consider adding error handling to the binding.

The reactive binding implementation is a good improvement, but consider handling potential keychain access failures:

 this.passwordSaved = Bindings.createBooleanBinding(() -> {
     var v = vault.get();
-    return v != null && keychain.getPassphraseStoredProperty(v.getId()).getValue();
+    try {
+        return v != null && keychain.getPassphraseStoredProperty(v.getId()).getValue();
+    } catch (Exception e) {
+        logger.error("Failed to check keychain state", e);
+        return false;
+    }
 }, vault, keychain.getKeychainImplementation());
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 526c397 and ebce90e.

📒 Files selected for processing (5)
  • pom.xml (2 hunks)
  • src/main/java/module-info.java (1 hunks)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (6 hunks)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java (1 hunks)
  • src/main/java/org/cryptomator/ui/mainwindow/VaultDetailLockedController.java (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/java/org/cryptomator/ui/keyloading/masterkeyfile/MasterkeyFileLoadingStrategy.java
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java
  • pom.xml
🔇 Additional comments (5)
src/main/java/module-info.java (3)

54-54: Clarify the relevance of Caffeine to Touch ID implementation.

The addition of Caffeine appears unrelated to the PR's main objective of adding Touch ID and Windows Hello support. Could you clarify why this caching library is needed as part of this implementation?


54-54: Verify build configuration for Caffeine dependency.

The addition of Caffeine as a module dependency looks correct. However, ensure this dependency is properly declared in the build configuration file (e.g., pom.xml or build.gradle).

Run the following script to check the build configuration:

✅ Verification successful

Caffeine dependency is properly configured ✅

The Caffeine dependency is correctly declared in both the module descriptor (module-info.java) and the Maven build configuration (pom.xml).

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if Caffeine dependency is properly declared in build files

# Check Maven POM file
if [ -f "pom.xml" ]; then
    echo "Checking Maven POM..."
    rg -A 3 "com\.github\.benmanes\.caffeine" pom.xml
fi

# Check Gradle build file
if [ -f "build.gradle" ]; then
    echo "Checking Gradle build..."
    rg -A 3 "com\.github\.benmanes\.caffeine" build.gradle
fi

Length of output: 151


Script:

#!/bin/bash
# Search for any Caffeine-related dependency declarations with broader patterns
echo "Checking for Caffeine dependency with broader patterns..."
rg -i "caffeine" pom.xml

echo -e "\nChecking for parent POM references..."
rg "<parent>" -A 5 pom.xml

echo -e "\nLooking for other POM files..."
fd "pom.xml$"

Length of output: 479


54-54: Consider completing Guava to Caffeine transition.

Since you're adding Caffeine as a caching solution, consider removing the Guava dependency (requires com.google.common) if it's no longer needed. This would help avoid maintaining two caching libraries.

Run the following script to check remaining Guava cache usage:

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

11-11: LGTM! Good move towards reactive programming.

The addition of the Bindings import supports the transition to a more reactive programming model using JavaFX bindings.


33-36: Verify security implications of the binding.

Given that this PR implements biometric authentication support, we should verify that this binding:

  1. Respects the authentication state
  2. Doesn't expose keychain information before proper authentication
  3. Properly handles the keychain locked/unlocked state

Let's verify the security implications:

✅ Verification successful

Binding implementation follows security best practices

The binding is implemented securely:

  • Only indicates password presence without exposing sensitive data
  • Respects keychain locked state through proper authentication checks
  • Updates appropriately with keychain implementation changes
  • Actual password access requires separate authentication
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for authentication checks in KeychainManager
ast-grep --pattern 'class KeychainManager {
  $$$
  getPassphraseStoredProperty($_) {
    $$$
  }
  $$$
}'

# Look for related security checks
rg -A 5 "kSecAccessControl|SecAccessControl|TouchID|WindowsHello" 

Length of output: 1417


Script:

#!/bin/bash
# Find KeychainManager implementation
fd -e java -x rg -l "class.*KeychainManager"

# Look for biometric authentication related code
rg -A 5 "biometric|authenticate|unlock.*keychain|isLocked"

# Find all uses of getPassphraseStoredProperty
rg -A 3 "getPassphraseStoredProperty"

# Look for security state management
ast-grep --pattern 'class $_ implements Keychain {
  $$$
}'

Length of output: 12284

@infeo infeo removed this from the next milestone Jan 20, 2025

@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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2f81237 and d390913.

📒 Files selected for processing (2)
  • src/main/java/org/cryptomator/common/keychain/KeychainManager.java (6 hunks)
  • src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (2 hunks)
🔇 Additional comments (5)
src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (2)

22-28: LGTM! Proper JavaFX initialization setup.

The startup method correctly initializes the JavaFX platform with appropriate timeout and error handling.


38-38: Verify test coverage for new authentication parameter.

The test case doesn't verify the new requireOsAuthentication parameter behavior introduced for Touch ID/Windows Hello support.

Consider adding test cases to verify:

  1. Authentication requirement when storing passwords
  2. Different behavior when requireOsAuthentication is true vs false

Also applies to: 46-46

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

3-3: Consider security implications of soft references.

The switch from Guava's weak references to Caffeine's soft references could potentially keep sensitive data in memory longer than necessary.

Consider:

  1. Using weak references instead of soft references for sensitive data
  2. Adding explicit cleanup mechanisms

Also applies to: 26-28


109-113: LGTM! Proper thread-safe property updates.

The implementation correctly handles property updates on the JavaFX application thread.


140-142: Review necessity of exposing keychain implementation.

Exposing the internal keychain implementation could lead to security vulnerabilities if misused.

Consider:

  1. Documenting the security implications of accessing the raw implementation
  2. Adding access controls or limiting the exposed functionality
  3. Evaluating if this exposure is necessary for the Touch ID/Windows Hello integration

@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

🔭 Outside diff range comments (1)
src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (1)

Add test coverage for biometric authentication features

The codebase lacks test coverage for biometric authentication features. Current tests only cover basic keychain operations. Required test coverage:

  • Enabling/disabling biometric authentication
  • Authentication flow with Touch ID/Windows Hello
  • Error handling for biometric authentication failures
  • Integration with platform-specific keychain implementations
🔗 Analysis chain

Line range hint 37-55: Add test coverage for biometric authentication.

Based on the PR objectives to add Touch ID and Windows Hello support, we need test coverage for:

  1. Enabling/disabling biometric authentication
  2. Authentication flow with Touch ID/Windows Hello
  3. Error handling for biometric authentication failures

Let's verify if there are any existing biometric authentication tests:

Would you like me to help create test cases for the biometric authentication features?

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for biometric authentication related tests
echo "Searching for biometric authentication test files..."
fd -e java -e kt test | xargs rg -l "Touch.*ID|Windows.*Hello|[Bb]iometric"

echo "Searching for biometric authentication test methods..."
ast-grep --pattern 'class $_ {
  $$$
  @Test
  $$$
  test$_(Touch|Hello|Biometric)$_($$$) {
    $$$
  }
  $$$
}'

Length of output: 484


Script:

#!/bin/bash
# Check content of EnvironmentTest.java
echo "=== Content of EnvironmentTest.java ==="
cat src/test/java/org/cryptomator/common/EnvironmentTest.java

echo -e "\n=== Searching for biometric implementation files ==="
rg -l "biometric|touchid|hello" --type java --type kotlin

echo -e "\n=== Searching for keychain/auth related test files ==="
fd -e java -e kt test | xargs rg -l "keychain|auth|credential"

Length of output: 4792


Script:

#!/bin/bash
echo "=== Content of HandleLaunchArgsMessageTest.java ==="
cat src/test/java/org/cryptomator/ipc/HandleLaunchArgsMessageTest.java

echo -e "\n=== Full content of KeychainManagerTest.java ==="
cat src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java

Length of output: 3920

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

1-20: Add documentation and improve error handling.

The utility class needs the following improvements:

  1. Add class-level JavaDoc explaining its purpose and usage
  2. Extract timeout value as a constant
  3. Consider adding debug logging for initialization failures

Apply this diff:

 package org.cryptomator;

 import javafx.application.Platform;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;

+/**
+ * Utility class for JavaFX platform initialization.
+ * Provides thread-safe initialization of the JavaFX runtime with timeout handling.
+ */
 public class JavaFXUtil {
+    private static final Logger LOG = LoggerFactory.getLogger(JavaFXUtil.class);
+    private static final int PLATFORM_STARTUP_TIMEOUT_SECONDS = 5;

     public static boolean startPlatform() throws InterruptedException {
         CountDownLatch latch = new CountDownLatch(1);
         try {
             Platform.startup(latch::countDown);
         } catch (IllegalStateException e) {
             //already initialized
+            LOG.debug("JavaFX platform already initialized");
             latch.countDown();
         }
-        return latch.await(5, TimeUnit.SECONDS);
+        boolean started = latch.await(PLATFORM_STARTUP_TIMEOUT_SECONDS, TimeUnit.SECONDS);
+        if (!started) {
+            LOG.error("JavaFX platform initialization timed out after {} seconds", PLATFORM_STARTUP_TIMEOUT_SECONDS);
+        }
+        return started;
     }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d4066d and 1fb9876.

📒 Files selected for processing (3)
  • src/main/java/org/cryptomator/JavaFXUtil.java (1 hunks)
  • src/test/java/org/cryptomator/common/keychain/KeychainManagerTest.java (3 hunks)
  • src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java (2 hunks)
🔇 Additional comments (2)
src/test/java/org/cryptomator/ui/controls/SecurePasswordFieldTest.java (1)

3-3: LGTM!

Good refactoring to use the centralized JavaFX initialization utility.

Also applies to: 22-23

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

23-27: LGTM!

Good refactoring to use the centralized JavaFX initialization utility.

@purejava purejava closed this by deleting the head repository Feb 15, 2025
infeo added a commit that referenced this pull request Feb 19, 2025
@PKizzle

PKizzle commented Feb 20, 2025

Copy link
Copy Markdown

Has this been merged or what is the reason for this PR being closed?

@infeo

infeo commented Feb 20, 2025

Copy link
Copy Markdown
Member

We'll integrate TouchID and Windows Support in seperate PRs. Additionally, it contained too many unrelated changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants