SAS tokens instead of keys in app
It would be really cool if you could use a SAS token (generated elsewhere) instead of storing the account key in the application.
I have a backend where I generate SAS tokens but I don't really know what to do with them, so that's pretty much the functionality I am asking for :)
SAS token support is something I would like to add here... But with .NET 4.6 (Experiment) support looming I have held fire on developing this as it looks like we are close to being able to use the full SDKs now. https://docs.microsoft.com/en-us/sandbox/gamedev/unity/azure-storage-unity
Makes sense. I have already jumped ship to 4.6 myself :)
The experimental Unity Azure SDK has been removed from the web, and from what I saw elsewhere, no longer works anyway.
So here's a quick and dirty modification that works for my needs and will hopefully save someone time:
public void AuthorizeRequest(StorageServiceClient client, Method method, string resourcePath = "", Dictionary<string, string> queryParams = null, Dictionary<string, string> headers = null, int contentLength = 0)
{
AuthorizationHeaders authHeaders = new AuthorizationHeaders(client, method, resourcePath, queryParams, headers, contentLength);
string stringToSign = authHeaders.ToString();
this.AddHeader("x-ms-date", authHeaders.MSDate());
this.AddHeader("x-ms-version", authHeaders.MSVersion());
// NOTE: you'll need to add string SASParams to the client also
if (client.SASParams != null)
{
this.Request.url = $"{client.Url}{resourcePath}{client.SASParams}";
}
else
{
string signature = GetSignature(client.Key, stringToSign);
string authorization = GetAuthorizationHeader(client.Account, signature);
this.AddHeader("Authorization", authorization);
Debug.Log("Authorized request url:" + this.Request.url + "\n\nauthorization: \"" + authorization + "\"\nx-ms-date: " + authHeaders.MSDate() + "\nstringToSign:'" + stringToSign + "'");
}
if (headers != null)
{
this.AddHeaders(headers);
}