azure: Strip ? prefix from sas token

This commit is contained in:
Michael Eischer 2022-07-16 23:45:41 +02:00
parent 64a7ec5341
commit 5639c41b6a
2 changed files with 6 additions and 5 deletions

View File

@ -506,10 +506,6 @@ or
$ export AZURE_ACCOUNT_NAME=<ACCOUNT_NAME>
$ export AZURE_ACCOUNT_SAS=<SAS_TOKEN>
With the later form, ensure your ``SAS_TOKEN`` does not start with a leading
``?``. If the generated token starts with a leading ``?`` it is safe to just
delete the first character (the ``?``) before use.
Afterwards you can initialize a repository in a container called ``foo`` in the
root path like this:

View File

@ -57,7 +57,12 @@ func open(cfg Config, rt http.RoundTripper) (*Backend, error) {
// we (as per the SDK ) assume the default Azure portal.
url := fmt.Sprintf("https://%s.blob.core.windows.net/", cfg.AccountName)
debug.Log(" - using sas token")
client, err = storage.NewAccountSASClientFromEndpointToken(url, cfg.AccountSAS.Unwrap())
sas := cfg.AccountSAS.Unwrap()
// strip query sign prefix
if sas[0] == '?' {
sas = sas[1:]
}
client, err = storage.NewAccountSASClientFromEndpointToken(url, sas)
if err != nil {
return nil, errors.Wrap(err, "NewAccountSASClientFromEndpointToken")
}