Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

azureblob: allow anonymous access for public resources

Nick Craig-Wood4824837eedcf
diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index 6c07a3320..662be58a7 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -711,10 +711,11 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
ClientOptions: policyClientOptions,
}
- // Here we auth by setting one of cred, sharedKeyCred or f.svc
+ // Here we auth by setting one of cred, sharedKeyCred, f.svc or anonymous
var (
cred azcore.TokenCredential
sharedKeyCred *service.SharedKeyCredential
+ anonymous = false
)
switch {
case opt.EnvAuth:
@@ -874,6 +875,9 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
if err != nil {
return nil, fmt.Errorf("failed to acquire MSI token: %w", err)
}
+ case opt.Account != "":
+ // Anonymous access
+ anonymous = true
default:
return nil, errors.New("no authentication method configured")
}
@@ -903,6 +907,12 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
if err != nil {
return nil, fmt.Errorf("create client failed: %w", err)
}
+ } else if anonymous {
+ // Anonymous public access
+ f.svc, err = service.NewClientWithNoCredential(opt.Endpoint, &clientOpt)
+ if err != nil {
+ return nil, fmt.Errorf("create public client failed: %w", err)
+ }
}
}
if f.svc == nil {
diff --git a/docs/content/azureblob.md b/docs/content/azureblob.md
index 987045cb2..58c3f1f05 100644
--- a/docs/content/azureblob.md
+++ b/docs/content/azureblob.md
@@ -289,6 +289,13 @@ be explicitly specified using exactly one of the `msi_object_id`,
If none of `msi_object_id`, `msi_client_id`, or `msi_mi_res_id` is
set, this is is equivalent to using `env_auth`.
+#### Anonymous {#anonymous}
+
+If you want to access resources with public anonymous access then set
+`account` only. You can do this without making an rclone config:
+
+ rclone lsf :azureblob,account=ACCOUNT:CONTAINER
+
{{< rem autogenerated options start" - DO NOT EDIT - instead edit fs.RegInfo in backend/azureblob/azureblob.go then run make backenddocs" >}}
### Standard options