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

[design] Migrate GDrive from service account to OAuth #3047

Open
xkxx opened this issue May 27, 2023 · 4 comments · May be fixed by #3288
Open

[design] Migrate GDrive from service account to OAuth #3047

xkxx opened this issue May 27, 2023 · 4 comments · May be fixed by #3288

Comments

@xkxx
Copy link
Contributor

xkxx commented May 27, 2023

Hi @jkowalski,

As people reported in #2656, the current GDrive auth doesn't really work as the service account's quota is used instead of the user's. To fix this, we need to migrate to OAuth-based auth. I'm interested in taking on this work, but I'd like your review on this design.

We have two options in terms of grant scope:

With drive.file scope, we need to ask the user to grant us access to one Drive folder. As far as my research goes, the only way is through the Drive File Picker API, which must be embedded in a web page. One way to do it is to run a temporary HTTP server for this.

The upside of this approach:

  • The user selects a folder and grants us access in one go. It's slightly more streamlined than the current GDrive onboarding, where they need to create a service account on GCloud, share the folder on Drive, and then come onto the CLI.
  • We can integrate this whole flow into the Kopia React app for UI users.

The downsides:

  • repository create needs to show a link that the user needs to visit and interact with the Drive widget. If the user runs this command from a headless server behind a NAT, they may need to port-forward the server to their desktop. Alternatively, they can run repository create on a desktop and copy the files over. repository connect is unaffected.

Questions:

  • Is it weird to run a HTTP server as part of repository create? Can you think of a better way through this?

Best,

xkxx

@xkxx xkxx changed the title Migrate GDrive from service account to OAuth [design] Migrate GDrive from service account to OAuth Jun 17, 2023
@xkxx
Copy link
Contributor Author

xkxx commented Jun 30, 2023

ping on this and #3048 - Could I get some feedback on these design proposals?

@xkxx
Copy link
Contributor Author

xkxx commented Sep 9, 2023

Hello @jkowalski - Could you take a look at this design proposal as well as #3048?

@jkowalski
Copy link
Contributor

This sounds like a great idea, would refresh tokens be permanent or time-bounded?

Running HTTP server is a common thing these days for precisely this reason, we can add more use cases like this (for example kopia policy edit could just popup UI in a browser instead of a text editor)

@xkxx
Copy link
Contributor Author

xkxx commented Sep 9, 2023

Thanks for the review!

The refresh token is long-term, but with some caveats. We can be smart and detect if the refresh token is expired due to one of these edge cases, though hitting these in practice should be rare.

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 a pull request may close this issue.

2 participants