forked from TrueCloudLab/rclone
webdav: add bearer token (Macaroon) support for dCache - fixes #2360
This commit is contained in:
parent
69164b3dda
commit
fa051ff970
2 changed files with 44 additions and 45 deletions
|
@ -87,6 +87,10 @@ func init() {
|
||||||
Help: "Password.",
|
Help: "Password.",
|
||||||
Optional: true,
|
Optional: true,
|
||||||
IsPassword: true,
|
IsPassword: true,
|
||||||
|
}, {
|
||||||
|
Name: "bearer_token",
|
||||||
|
Help: "Bearer token instead of user/pass (eg a Macaroon)",
|
||||||
|
Optional: true,
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -270,6 +274,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
|
|
||||||
user := config.FileGet(name, "user")
|
user := config.FileGet(name, "user")
|
||||||
pass := config.FileGet(name, "pass")
|
pass := config.FileGet(name, "pass")
|
||||||
|
bearerToken := config.FileGet(name, "bearer_token")
|
||||||
if pass != "" {
|
if pass != "" {
|
||||||
var err error
|
var err error
|
||||||
pass, err = obscure.Reveal(pass)
|
pass, err = obscure.Reveal(pass)
|
||||||
|
@ -290,7 +295,7 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
root: root,
|
root: root,
|
||||||
endpoint: u,
|
endpoint: u,
|
||||||
endpointURL: u.String(),
|
endpointURL: u.String(),
|
||||||
srv: rest.NewClient(fshttp.NewClient(fs.Config)).SetRoot(u.String()).SetUserPass(user, pass),
|
srv: rest.NewClient(fshttp.NewClient(fs.Config)).SetRoot(u.String()),
|
||||||
pacer: pacer.New().SetMinSleep(minSleep).SetMaxSleep(maxSleep).SetDecayConstant(decayConstant),
|
pacer: pacer.New().SetMinSleep(minSleep).SetMaxSleep(maxSleep).SetDecayConstant(decayConstant),
|
||||||
user: user,
|
user: user,
|
||||||
pass: pass,
|
pass: pass,
|
||||||
|
@ -299,6 +304,11 @@ func NewFs(name, root string) (fs.Fs, error) {
|
||||||
f.features = (&fs.Features{
|
f.features = (&fs.Features{
|
||||||
CanHaveEmptyDirectories: true,
|
CanHaveEmptyDirectories: true,
|
||||||
}).Fill(f)
|
}).Fill(f)
|
||||||
|
if user != "" || pass != "" {
|
||||||
|
f.srv.SetUserPass(user, pass)
|
||||||
|
} else if bearerToken != "" {
|
||||||
|
f.srv.SetHeader("Authorization", "BEARER "+bearerToken)
|
||||||
|
}
|
||||||
f.srv.SetErrorHandler(errorHandler)
|
f.srv.SetErrorHandler(errorHandler)
|
||||||
err = f.setQuirks(vendor)
|
err = f.setQuirks(vendor)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -30,53 +30,17 @@ n/s/q> n
|
||||||
name> remote
|
name> remote
|
||||||
Type of storage to configure.
|
Type of storage to configure.
|
||||||
Choose a number from below, or type in your own value
|
Choose a number from below, or type in your own value
|
||||||
1 / Amazon Drive
|
[snip]
|
||||||
\ "amazon cloud drive"
|
22 / Webdav
|
||||||
2 / Amazon S3 (also Dreamhost, Ceph, Minio)
|
|
||||||
\ "s3"
|
|
||||||
3 / Backblaze B2
|
|
||||||
\ "b2"
|
|
||||||
4 / Box
|
|
||||||
\ "box"
|
|
||||||
5 / Dropbox
|
|
||||||
\ "dropbox"
|
|
||||||
6 / Encrypt/Decrypt a remote
|
|
||||||
\ "crypt"
|
|
||||||
7 / FTP Connection
|
|
||||||
\ "ftp"
|
|
||||||
8 / Google Cloud Storage (this is not Google Drive)
|
|
||||||
\ "google cloud storage"
|
|
||||||
9 / Google Drive
|
|
||||||
\ "drive"
|
|
||||||
10 / Hubic
|
|
||||||
\ "hubic"
|
|
||||||
11 / Local Disk
|
|
||||||
\ "local"
|
|
||||||
12 / Microsoft Azure Blob Storage
|
|
||||||
\ "azureblob"
|
|
||||||
13 / Microsoft OneDrive
|
|
||||||
\ "onedrive"
|
|
||||||
14 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
|
|
||||||
\ "swift"
|
|
||||||
15 / Pcloud
|
|
||||||
\ "pcloud"
|
|
||||||
16 / QingCloud Object Storage
|
|
||||||
\ "qingstor"
|
|
||||||
17 / SSH/SFTP Connection
|
|
||||||
\ "sftp"
|
|
||||||
18 / WebDAV
|
|
||||||
\ "webdav"
|
\ "webdav"
|
||||||
19 / Yandex Disk
|
[snip]
|
||||||
\ "yandex"
|
|
||||||
20 / http Connection
|
|
||||||
\ "http"
|
|
||||||
Storage> webdav
|
Storage> webdav
|
||||||
URL of http host to connect to
|
URL of http host to connect to
|
||||||
Choose a number from below, or type in your own value
|
Choose a number from below, or type in your own value
|
||||||
1 / Connect to example.com
|
1 / Connect to example.com
|
||||||
\ "https://example.com"
|
\ "https://example.com"
|
||||||
url> https://example.com/remote.php/webdav/
|
url> https://example.com/remote.php/webdav/
|
||||||
Name of the WebDAV site/service/software you are using
|
Name of the Webdav site/service/software you are using
|
||||||
Choose a number from below, or type in your own value
|
Choose a number from below, or type in your own value
|
||||||
1 / Nextcloud
|
1 / Nextcloud
|
||||||
\ "nextcloud"
|
\ "nextcloud"
|
||||||
|
@ -98,13 +62,17 @@ Enter the password:
|
||||||
password:
|
password:
|
||||||
Confirm the password:
|
Confirm the password:
|
||||||
password:
|
password:
|
||||||
|
Bearer token instead of user/pass (eg a Macaroon)
|
||||||
|
bearer_token>
|
||||||
Remote config
|
Remote config
|
||||||
--------------------
|
--------------------
|
||||||
[remote]
|
[remote]
|
||||||
|
type = webdav
|
||||||
url = https://example.com/remote.php/webdav/
|
url = https://example.com/remote.php/webdav/
|
||||||
vendor = nextcloud
|
vendor = nextcloud
|
||||||
user = user
|
user = user
|
||||||
pass = *** ENCRYPTED ***
|
pass = *** ENCRYPTED ***
|
||||||
|
bearer_token =
|
||||||
--------------------
|
--------------------
|
||||||
y) Yes this is OK
|
y) Yes this is OK
|
||||||
e) Edit this remote
|
e) Edit this remote
|
||||||
|
@ -133,6 +101,10 @@ Owncloud or Nextcloud rclone will support modified times.
|
||||||
|
|
||||||
Hashes are not supported.
|
Hashes are not supported.
|
||||||
|
|
||||||
|
## Provider notes ##
|
||||||
|
|
||||||
|
See below for notes on specific providers.
|
||||||
|
|
||||||
### Owncloud ###
|
### Owncloud ###
|
||||||
|
|
||||||
Click on the settings cog in the bottom right of the page and this
|
Click on the settings cog in the bottom right of the page and this
|
||||||
|
@ -149,7 +121,7 @@ Owncloud does. This [may be
|
||||||
fixed](https://github.com/nextcloud/nextcloud-snap/issues/365) in the
|
fixed](https://github.com/nextcloud/nextcloud-snap/issues/365) in the
|
||||||
future.
|
future.
|
||||||
|
|
||||||
## Put.io ##
|
### Put.io ###
|
||||||
|
|
||||||
put.io can be accessed in a read only way using webdav.
|
put.io can be accessed in a read only way using webdav.
|
||||||
|
|
||||||
|
@ -174,9 +146,9 @@ mount.
|
||||||
|
|
||||||
For more help see [the put.io webdav docs](http://help.put.io/apps-and-integrations/ftp-and-webdav).
|
For more help see [the put.io webdav docs](http://help.put.io/apps-and-integrations/ftp-and-webdav).
|
||||||
|
|
||||||
## Sharepoint ##
|
### Sharepoint ###
|
||||||
|
|
||||||
Can be used with Sharepoint provided by OneDrive for Business
|
Rclone can be used with Sharepoint provided by OneDrive for Business
|
||||||
or Office365 Education Accounts.
|
or Office365 Education Accounts.
|
||||||
This feature is only needed for a few of these Accounts,
|
This feature is only needed for a few of these Accounts,
|
||||||
mostly Office365 Education ones. These accounts are sometimes not
|
mostly Office365 Education ones. These accounts are sometimes not
|
||||||
|
@ -214,3 +186,20 @@ vendor = other
|
||||||
user = YourEmailAddress
|
user = YourEmailAddress
|
||||||
pass = encryptedpassword
|
pass = encryptedpassword
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### dCache ###
|
||||||
|
|
||||||
|
Configure as normal using the `other` type. Don't enter a username or
|
||||||
|
password, instead enter your Macaroon as the `bearer_token`.
|
||||||
|
|
||||||
|
The config will end up looking something like this.
|
||||||
|
|
||||||
|
```
|
||||||
|
[dcache]
|
||||||
|
type = webdav
|
||||||
|
url = https://dcache...
|
||||||
|
vendor = other
|
||||||
|
user =
|
||||||
|
pass =
|
||||||
|
bearer_token = your-macaroon
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue