b2: Support Application Keys - fixes #2428

This supports B2 application keys limited to a bucket by making sure
we only list the buckets of the bucket ID that the key is limited to.
This commit is contained in:
Nick Craig-Wood
2018-08-06 14:32:53 +01:00
parent ffd11662ba
commit a119ca9f10
3 changed files with 42 additions and 12 deletions
+6 -2
View File
@@ -66,7 +66,7 @@ func init() {
NewFs: NewFs,
Options: []fs.Option{{
Name: "account",
Help: "Account ID",
Help: "Account ID or Application Key ID",
Required: true,
}, {
Name: "key",
@@ -691,7 +691,11 @@ type listBucketFn func(*api.Bucket) error
// listBucketsToFn lists the buckets to the function supplied
func (f *Fs) listBucketsToFn(fn listBucketFn) error {
var account = api.Account{ID: f.info.AccountID}
var account = api.ListBucketsRequest{
AccountID: f.info.AccountID,
BucketID: f.info.Allowed.BucketID,
}
var response api.ListBucketsResponse
opts := rest.Opts{
Method: "POST",