Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hub subscription header #333

Merged
merged 1 commit into from
Jan 16, 2024
Merged

Conversation

phil1995
Copy link
Collaborator

@phil1995 phil1995 commented Jan 12, 2024

During the implementation of #332 we somehow forgot to actually pass the header, which includes the Cryptomator Hub subscription state since Hub 1.3.1, to the HubAuthenticationFlow after a successful unlock of the Cryptomator Hub vault.
This has now been fixed 🎉

Summary by CodeRabbit

  • New Features
    • Enhanced the authentication process to include additional header information upon successful retrieval of encrypted vault keys.

Copy link

coderabbitai bot commented Jan 12, 2024

Walkthrough

The changes involve updating the authentication process in the CryptomatorHubAuthenticator. The success case of the retrieveMasterkeyResponse now includes a header along with the key. Additionally, the success return type has been expanded to include not just the encryptedVaultKey but also the header information, which consists of HTTP response headers.

Changes

File Path Change Summary
.../CryptomatorCommonCore/Hub/CryptomatorHubAuthenticator.swift Added a header to the success case in retrieveMasterkeyResponse and updated the success return type to include header information.

Poem

In the vault of code where secrets hide, 🐇💻
A rabbit tweaked the lock inside. 🔐
With headers now in success's keep,
Secure the keys that secrets seep. 🗝️✨

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 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 and a 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. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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.
  • 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 to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 50fd566 and 7b2b97e.
Files selected for processing (1)
  • CryptomatorCommon/Sources/CryptomatorCommonCore/Hub/CryptomatorHubAuthenticator.swift (4 hunks)
Additional comments: 3
CryptomatorCommon/Sources/CryptomatorCommonCore/Hub/CryptomatorHubAuthenticator.swift (3)
  • 70-74: The changes made to the switch statement to capture the header in the .success case are consistent with the PR objectives. The variables encryptedVaultKey and unlockHeader are correctly assigned from the tuple returned by the getVaultMasterKey function.

However, it's important to ensure that all other parts of the code that depend on the HubAuthenticationFlowSuccess structure and the getVaultMasterKey function are updated to handle the new tuple format.

Verification successful

The verification process has revealed that the changes to the getVaultMasterKey function are localized to the CryptomatorHubAuthenticator.swift file, and there is no evidence of the HubAuthenticationFlowSuccess structure being used elsewhere in the codebase. This suggests that the changes made in the pull request are self-contained and consistent with the PR objectives, which state that the changes are confined to the CryptomatorHubAuthenticator.swift file within the CryptomatorCommonCore module.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new tuple format is correctly handled wherever `HubAuthenticationFlowSuccess` is used.
ast-grep --lang swift --pattern $'HubAuthenticationFlowSuccess($_, $_, $_)'
# Verify that the `getVaultMasterKey` function's new return type is correctly handled.
ast-grep --lang swift --pattern $'getVaultMasterKey($_, $_, $_).success($_, $_)'

Length of output: 158



Script:

#!/bin/bash
# Search for the usage of the HubAuthenticationFlowSuccess structure with a more general pattern.
ast-grep --lang swift --pattern $'HubAuthenticationFlowSuccess($$$)'

# Search for the usage of the getVaultMasterKey function with a more general pattern.
ast-grep --lang swift --pattern $'getVaultMasterKey($$$)'

Length of output: 659

* 98-98: The return statement in line 98 correctly constructs a `HubAuthenticationFlowSuccess` object with the `encryptedUserKeyJWE`, `encryptedVaultKeyJWE`, and `unlockHeader`. This aligns with the changes made to the `HubAuthenticationFlowSuccess` struct to include the header. It's crucial to ensure that the consumers of this success case are expecting a tuple and handle the header appropriately.
  • 304-304: The update to the RetrieveVaultMasterkeyEncryptedForUserResponse enum to include the header in the .success case is in line with the PR's objectives. This change is necessary to pass the header information along with the encrypted vault key. It's important to verify that all usages of this enum have been updated to handle the new case with the header.

@tobihagemann tobihagemann added this to the 2.5.0 milestone Jan 16, 2024
@tobihagemann tobihagemann merged commit 10511d4 into develop Jan 16, 2024
5 checks passed
@tobihagemann tobihagemann deleted the feature/hub-subscription-header branch January 16, 2024 20:04
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.

2 participants