azblob: store SAS URL as kms.Secret

This commit is contained in:
Nicola Murino
2021-06-11 22:27:36 +02:00
parent 8607788975
commit 9d3d7db29c
26 changed files with 1026 additions and 72 deletions

View File

@@ -75,13 +75,16 @@ func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsCo
if err := fs.config.AccountKey.TryDecrypt(); err != nil {
return fs, err
}
if err := fs.config.SASURL.TryDecrypt(); err != nil {
return fs, err
}
fs.setConfigDefaults()
version := version.Get()
telemetryValue := fmt.Sprintf("SFTPGo-%v_%v", version.Version, version.CommitHash)
if fs.config.SASURL != "" {
u, err := url.Parse(fs.config.SASURL)
if fs.config.SASURL.GetPayload() != "" {
u, err := url.Parse(fs.config.SASURL.GetPayload())
if err != nil {
return fs, fmt.Errorf("invalid credentials: %v", err)
}
@@ -144,8 +147,8 @@ func NewAzBlobFs(connectionID, localTempDir, mountPath string, config AzBlobFsCo
// Name returns the name for the Fs implementation
func (fs *AzureBlobFs) Name() string {
if fs.config.SASURL != "" {
return fmt.Sprintf("Azure Blob SAS URL %#v", fs.config.Container)
if !fs.config.SASURL.IsEmpty() {
return fmt.Sprintf("Azure Blob with SAS URL, container %#v", fs.config.Container)
}
return fmt.Sprintf("Azure Blob container %#v", fs.config.Container)
}