feat: OneDrive + Google Drive storage backends (OAuth2 device code)#13
Open
pszymkowiak wants to merge 1 commit into
Open
feat: OneDrive + Google Drive storage backends (OAuth2 device code)#13pszymkowiak wants to merge 1 commit into
pszymkowiak wants to merge 1 commit into
Conversation
Adds two new storage backends that target the substantial free tiers of
consumer cloud accounts (1 TB on OneDrive with O365, 15 GB on personal
Google Drive), making Enigma viable for personal backups without paying
for object storage.
Both providers authenticate via OAuth2 device code flow — the user enters
an 8-character code on microsoft.com/devicelogin or google.com/device once,
and refresh tokens stored AES-256-GCM-encrypted on disk handle every
subsequent operation transparently.
New module: enigma-storage/src/oauth/
- device_flow.rs: hand-rolled OAuth2 device code + refresh implementation
that handles both Microsoft Graph and Google identity endpoints
- token_store.rs: encrypted token persistence at <config_dir>/oauth_tokens.enc
(Argon2id + HKDF-SHA256(info="enigma-oauth-v1") + AES-256-GCM, same
passphrase as the keystore)
- retry.rs: with_retry helper honoring HTTP 429 + Retry-After
New backends:
- onedrive.rs: Microsoft Graph /me/drive/special/approot endpoints with
Files.ReadWrite.AppFolder scope (isolated to /Apps/Enigma/). Inline
PUT for chunks ≤ 4 MiB; upload session for larger chunks (10 MiB
segments) since FastCDC can produce ~8 MiB.
- gdrive.rs: Drive v3 with drive.file scope (app sees only its own
files). Flat folder strategy + in-memory chunk-key → file-id cache
bulk-populated on first use.
New CLI subcommand:
- enigma auth login {onedrive,gdrive} --client-id <id> [--client-secret <s>]
- enigma auth status
- enigma auth logout <provider>
Config: existing [[providers]] schema; type = "onedrive" or "gdrive";
bucket field unused (OneDrive uses approot, Drive uses fixed
"enigma-chunks" folder).
Wiring:
- ProviderType::Onedrive, ProviderType::Gdrive added to enigma-core
- enigma-cli/commands/providers.rs: lazy-open the encrypted token store
only when an OAuth provider is configured; bubble a clear error if no
passphrase is available
- backup / restore / verify / gc updated to thread base_dir + passphrase
through init_providers
Tests:
- Unit tests for retry backoff, retry-after parsing, token store
roundtrip + wrong-passphrase rejection, OneDrive URL path encoding,
Drive name flattening, multipart boundary uniqueness
Out of scope (follow-ups):
- enigma-proxy dispatch (S3 gateway) for OneDrive/GDrive — currently
bails through the existing `_ => bail` arm
- README translations (13 other languages)
- Multi-account-per-provider support
Note: this commit was not validated locally because the dev environment
lacks build-essential / gcc. CI will catch any issues; follow-up commits
will fix compile errors.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What's in
App scopes (least-privilege)
Test plan
`Out of scope (follow-ups)
Known limitations
This branch was committed without local compile validation (no build-essential on dev machine). Expect CI to catch any issues; follow-up fixes will land on this branch before merge.
🤖 Generated with Claude Code