cryptomator / ios

Cryptomator for iOS
https://cryptomator.org
GNU General Public License v3.0
194 stars 25 forks source link

Feature: Hub 1.3.0 Compatibility #332

Closed phil1995 closed 5 months ago

phil1995 commented 6 months ago

Adds support for the updated Device Registration and Unlock which has been introduced with Cryptomator Hub 1.3.0. For more details about the updated flow see https://github.com/cryptomator/cryptomator/pull/3041 and https://github.com/cryptomator/cryptomator/issues/3181. Unlike the Cryptomator Desktop App we removed the support for Cryptomator Hub instances with a minimum API level of 0, i.e. Cryptomator Hub < 1.3.0. Therefore, we request the API config at (<API-BASE-URL>/config/ and check that apiLevel >= 1.

This can't be merged at the current state because we still need to update cloud-access-swift to use the latest JOSESwift branch which adds support for PBES2_HS512_A256KW (needed to decrypt the user key). Additionally we need to update the HubConfig to the following:

public struct HubConfig: Equatable, Codable {
    public let clientId: String
    public let authEndpoint: String
    public let tokenEndpoint: String
    public let authSuccessUrl: String
    public let authErrorUrl: String
    public let apiBaseUrl: String?
    public let devicesResourceUrl: String

    public init(clientId: String, authEndpoint: String, tokenEndpoint: String, authSuccessUrl: String, authErrorUrl: String, apiBaseUrl: String?, devicesResourceUrl: String) {
        self.clientId = clientId
        self.authEndpoint = authEndpoint
        self.tokenEndpoint = tokenEndpoint
        self.authSuccessUrl = authSuccessUrl
        self.authErrorUrl = authErrorUrl
        self.apiBaseUrl = apiBaseUrl
        self.devicesResourceUrl = devicesResourceUrl
    }
}

Also the localization for the authentication errors is still missing.

I have added a new dependency https://github.com/leif-ibsen/SwiftECC. The only reason it has been added is to support PKCS#8 since CryptoKit does not support it out of the box. We can exchange this later with our own implementation in cryptolib-swift if we want.

Summary by CodeRabbit

coderabbitai[bot] commented 6 months ago

Walkthrough

The project has undergone a significant update, enhancing the authentication flow with the Cryptomator Hub. It now supports a new cryptographic library, SwiftECC, and includes UI updates for account key entry. The authentication process has been refined with additional error handling and a minimum hub version requirement. The JWEHelper has been expanded with new encryption and decryption methods, and the tests have been updated to cover the new functionality.

Changes

File Path Change Summary
CryptomatorCommon/Package.swift Updated Swift tools to 5.9, added "SwiftECC" dependency, included "SwiftUIIntrospect" and "SwiftECC" in products.
CryptomatorCommon/Sources/CryptomatorCommonCore/Hub/*.swift Refactored authentication enums, added new methods and constants, updated protocols and UI elements for account key handling. Introduces a new method in HubAuthenticationCoordinator extension.
CryptomatorCommon/Sources/CryptomatorCommonCore/JWEHelper.swift Renamed and added methods for key decryption and encryption, added private key extension.
CryptomatorCommon/Sources/CryptomatorCommonCore/SwiftUI/SwiftUI+CustomKeyboard.swift Added extensions for custom keyboard functionality.
CryptomatorCommon/Tests/CryptomatorCommonCoreTests/Hub/HubAuthenticationViewModelTests.swift,
CryptomatorCommon/Tests/CryptomatorCommonCoreTests/Hub/JWEHelperTests.swift
Updated tests for new authentication flow and JWEHelper methods.
SharedResources/en.lproj/Localizable.strings Added new keys for hub authentication messages.
.github/workflows/build.yml Added a step to select Xcode 15.1 using sudo xcode-select command.
Cryptomator.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved Additions and updates to remote source control dependencies.

🐇✨ A hop of code, a leap of Swift,
Encryption's gift, now set adrift.
Keys entwine in a silent ballet,
Cryptomator's dance, secure they'll stay. 🌟🔐

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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

Tips ### Chat with CodeRabbit Bot (`@coderabbitai`) - You can directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit-tests for this file.` - You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging `@coderabbitai` in a comment. Examples: - `@coderabbitai generate unit tests for this file.` - `@coderabbitai modularize this function.` - You can tag `@coderabbitai` in a PR comment and ask questions about the PR and the codebase. Examples: - `@coderabbitai generate interesting stats about this repository from git and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit tests.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.` - `@coderabbitai read the files in the src/scheduler package and generate README in the markdown format.` 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. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - The JSON schema for the configuration file is available [here](https://coderabbit.ai/integrations/coderabbit-overrides.v2.json). - 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/coderabbit-overrides.v2.json` ### CodeRabbit Discord Community Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback.
tobihagemann commented 6 months ago

@coderabbitai review

tobihagemann commented 6 months ago

cloud-access-swift 1.9.0 has been released and can be used now.