mirror of
https://github.com/rclone/rclone.git
synced 2025-08-09 13:55:15 +02:00
protondrive: implement two-password mode (#7279)
This commit is contained in:
@ -61,13 +61,23 @@ func init() {
|
||||
NewFs: NewFs,
|
||||
Options: []fs.Option{{
|
||||
Name: "username",
|
||||
Help: `The username of your proton drive account`,
|
||||
Help: `The username of your proton account`,
|
||||
Required: true,
|
||||
}, {
|
||||
Name: "password",
|
||||
Help: "The password of your proton drive account.",
|
||||
Help: "The password of your proton account.",
|
||||
Required: true,
|
||||
IsPassword: true,
|
||||
}, {
|
||||
Name: "mailboxPassword",
|
||||
Help: `The mailbox password of your two-password proton account.
|
||||
|
||||
For more information regarding the mailbox password, please check the
|
||||
following official knowledge base article:
|
||||
https://proton.me/support/the-difference-between-the-mailbox-password-and-login-password
|
||||
`,
|
||||
IsPassword: true,
|
||||
Advanced: true,
|
||||
}, {
|
||||
Name: "2fa",
|
||||
Help: `The 2FA code
|
||||
@ -149,9 +159,10 @@ then we might have a problem with caching the stale data.`,
|
||||
|
||||
// Options defines the configuration for this backend
|
||||
type Options struct {
|
||||
Username string `config:"username"`
|
||||
Password string `config:"password"`
|
||||
TwoFA string `config:"2fa"`
|
||||
Username string `config:"username"`
|
||||
Password string `config:"password"`
|
||||
MailboxPassword string `config:"mailboxPassword"`
|
||||
TwoFA string `config:"2fa"`
|
||||
|
||||
// advanced
|
||||
Enc encoder.MultiEncoder `config:"encoding"`
|
||||
@ -313,6 +324,7 @@ func newProtonDrive(ctx context.Context, f *Fs, opt *Options, m configmap.Mapper
|
||||
config.UseReusableLogin = false
|
||||
config.FirstLoginCredential.Username = opt.Username
|
||||
config.FirstLoginCredential.Password = opt.Password
|
||||
config.FirstLoginCredential.MailboxPassword = opt.MailboxPassword
|
||||
config.FirstLoginCredential.TwoFA = opt.TwoFA
|
||||
protonDrive, auth, err := protonDriveAPI.NewProtonDrive(ctx, config, authHandler, deAuthHandler)
|
||||
if err != nil {
|
||||
@ -344,6 +356,14 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
}
|
||||
}
|
||||
|
||||
if opt.MailboxPassword != "" {
|
||||
var err error
|
||||
opt.MailboxPassword, err = obscure.Reveal(opt.MailboxPassword)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't decrypt mailbox password: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
ci := fs.GetConfig(ctx)
|
||||
|
||||
root = strings.Trim(root, "/")
|
||||
|
Reference in New Issue
Block a user