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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

New storage provider: Google Cloud Storage #269

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

TheOpalium
Copy link

This PR adds Google Cloud Storage, Google's object storage solution (in their cloud platform), as a storage provider for KeeAnywhere.
I use GCS for my projects and would love to be able to use it for KeePass, so I figured I should chip-in and help make it happen! I tried my luck with the S3-compatible method first but it didn't seem to work, hence why I decided to just implement it 'natively'.

image image

A few things to note about this implementation:

  • Unlike S3 and Azure, GCS uses a different authentication mechanism. There's no ID and Secret; instead, there's a JSON key file that contains various information, including a private key and other secrets. Since this is not the format KeeAnywhere expects, I'm keeping the entire key file JSON string as the account secret. This is the simplest way to do it without having to change the entire format of AccountConfiguration.
  • During account creation, the user is requested to simply select the key file they downloaded from GCP, and the project ID (required by the lib). This is to make the process as simple as possible.
  • Google's .NET libs use IAsyncEnumerable for their async operations. This is fine since C# 5 supports it properly, but it did require a slightly uglier implementation since the 'luxury' of using await foreach is only for C# 8 and above.

I hope this will prove useful! Please let me know if there's anything you want me to add/change/remove.
馃槃

@TheOpalium
Copy link
Author

Why this is marked as a draft:
Well... I actually need a hand with testing this.

I'm not entirely sure what happened, but during development I suddenly started running into a strange problem with the Google API packages failing to load the proper version. The ol' Assembly failed to load error because of a version mismatch. Due to this, I can't continue testing my additions.
What's even more strange is that despite defining binding redirects in app.config, it still doesn't seem to work. It's as if the file is being completely ignored... I tried various other solutions but I can't get it to work.

I'm kinda stuck now, so I wonder if anyone can help me figure this one out.
Please let me know!

@Kyrodan Kyrodan added this to the 2.1.0 milestone May 18, 2021
@Kyrodan
Copy link
Owner

Kyrodan commented May 18, 2021

app.config is not used for assembly redirection.
In KeeAnywhereExt.cs a method called FixDependencyLoading tries to circumvent the problems.
Please try to use this or report back. I'm willing to help with this for next v2.1 Release.

The 'using' keyword ended up disposing the memory stream before it was actually opened. Also, the stream had to be seeked to the start.
Directories don't actually exist in GCS; instead, object names include a slash-separated prefix. This commit includes changes that interpret this prefix into sub-directories in the KeeAnywhere browser.
Since we only really need the object name and last update date, we can request GCS to only send those and omit the rest of the data.
@TheOpalium TheOpalium marked this pull request as ready for review May 24, 2021 16:42
@TheOpalium
Copy link
Author

app.config is not used for assembly redirection.
In KeeAnywhereExt.cs a method called FixDependencyLoading tries to circumvent the problems.

Thank you! That did the trick 馃槃
Now that this is solved, I was able to finish testing my additions and make any necessary changes. Ready to review!

KeePass_QBJwxgOP7K

Please let me know if there are any further changes or fixes required.

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.

None yet

2 participants