-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Azure SAS Token Authentication #812
Added Azure SAS Token Authentication #812
Conversation
Thank you for this PR, but I am not sure if this is a good fit inside tusd. Is it a common pattern in Azure deployments that the application continuously request new SAS tokens? If so, does the Azure SDK offer this integration on its own? Then we would not have to maintain this logic inside tusd. Maybe @omBratteng can also shed some more light on this. |
In our case we have implemented an Azure function that issues the SAS token. So when the token expires tusd can fetch a new SAS Token from the Azure function. Does this answer your question? |
Hello, Many greetings, |
Sorry, I have been quite swamped lately. I'll try to take a look at this this week. |
What does this exactly mean? What would a SAS token provision be? Basically, to me this looks like a feature that is only helpful for your own setup and might not be useful for anybody else. And I am concerned about adding such functionality if it only benefits a single user. I might be wrong as I don't use Azure but that is the reason for my hesitation and the inspiration of why I ask about alternative approaches here. I hope you understand. |
Thank you for your reply. I understand your questions. A shared access signature (SAS Token) provides secure delegated access to resources in your storage account. With a SAS, you have granular control over how a client can access your data. The SAS tokens are provided by Azure (see: https://learn.microsoft.com/en-us/rest/api/storageservices/create-account-sas). Therefore the new feature can be used by anyone who wants to authenticate against the Azure storage account with a SAS and not with the account key. |
I see that, yes. It would just be nice to hear from another Azure-experienced person if this approach would be useful for others as well (maybe from @omBratteng if he has some time).
Does this mean that the check is only performed if we want to upload data from a PATCH request? Shouldn't this check be included in every API request to Azure? Otherwise we might issue a request with an outdated token. |
Where are other API request to Azure? In our tests it always worked with and outdated token (because a new on was fetched). |
Ok, I see. |
I'm unsure if this would benefit anyone else. I am not familiar with anyone else solving it like this. |
Hello, okay I see your point. We have considered the following solution as an alternative: Basically for our solution we need a way to set the credentials to NewAnonymousCredential and attach a SAS token or presigned URL to the containerURL. We could also inject SAS tokens via a new "NewBlockBlobURL" callback function which is passed as parameter from the CLI to the AzureSerivce. The complete logic of how the SAS token or any other presigned URL is loaded is then controlled in the new function which is defined outside of the TUSD pkg. The anonymous credentials could be set in the if there is no AZURE_STORAGE_KEY available. The following is a prototype of our new solution approach:
Is this a solution that you would support? If yes, we would adjust our pull request. Many greetings, |
Seeing as I rarely have time for it, would you be open to create a new PR, where you replace the deprecated azure-storage-blob-go with the new azblob from azure-sdk-for-go package? |
Hi @omBratteng and @Acconut We took a look at the new azure-sdk-for-go package. Unfortunately it does not solve our problem directly. Since the SAS URL still has to be passed from the outside. However, we can imagine the following solution:
What do you think about these approaches? In principle, the described solution would also be possible with the old azure-storage-blob-go package (see comment from November 15). But if we could solve our need and contribute to the repo in general by switching to the new azure-sdk-for-go package, we'd be happy to do that too. |
Hi @Acconut |
Dear all, As microsoft states in their documentation: "With a SAS, you have granular control over how a client can access your data" The real benefit of using SAS for me would be to use this instead of the
Especially the first point is of real added value, ideally you would not even allow reading but this is necessary for
|
Hello together, the following picture should describes again what advantages a SAS token based authentication in tusd would have for us and others. In this case there is no need to have a AZURE_STORAGE_KEY on the edge device. The SAS token is obtained via the NewBlockBlobUrlFunc parameter (or as originally planned via the AZURE_STORAGE_SAS_URL env var). As @OlafHaalstra also mentioned the SAS token can only have read and write permissions to the storage account (and if desired only to a specific container in the storage account). Furthermore, the SAS token is only valid for a certain time and is bound to the IP address of the edge device. In general this solution would work also for other cloud providers (e.g. in AWS with presigned URLs). |
@Acconut could it be a feature in tusd itself, that each provider could hook onto. Like a standard method of fetching temporary auth before a new upload? Then the provider just hooks into that, with its custom methods of fetching credentials? I am not familiar with the And I agree that a SAS token is much more secure, we use something similar in our pipeline when downloading blobs/containers, where we generate a SAS token for the specific blob/container, and then forward it to the downloader. But that is written in python. Ideally, the provider would be upgraded to use the new azblob from azure-sdk-for-go package.
Unsure which order would be preferred. |
@omBratteng
An auth provider would be nice, but I wonder how the signature / hook / callback would look like since it is different for each store. Maybe it would also be possible to extend In general I like the idea of having the ability to add SAS tokens and the hook not being called from the store. |
Apologies for my delay. Azure is very much out of my comfort zone, so this is all very foreign to me. However, I do not longer see any issue with adding SAS support, as you described in #812 (comment), @jonaskaltenbachz. I think it would make sense to upgrade to the new azblob before adding the support, as you mentioned in your comment. Let me know if you are still interested in pursuing this :)
For S3 at least, I am not sure if there is something similar to SAS. As mentioned by others, I would be hesitant to define an interface because it seems to vary a lot across storage providers. So let's avoid a common interface for now. |
This pull request allows to authenticate in Azure with a SAS token. For this, the env var AZURE_STORAGE_SAS_URL must be set.
If no AZURE_STORAGE_KEY is set, a SAS token is requested from the AZURE_STORAGE_SAS_URL. The SAS token is initially requested in the NewAzureService func. Additionally, the NewBlob func checks if the token is still valid and fetches a new one if necessary.
If AZURE_STORAGE_KEY is set, the key is used for authentication.