Hi Wajih ARFAOUI,
To restrict access to a link and enforce authentication before showing the content, you can use Shared Access Signatures (SAS) tokens with specific permissions. By delegating SAS access at either the container level or the blob level, you can control who can access the content based on the permissions assigned to the SAS token.
- Azure AD Authentication: Configure your blob storage to use Azure AD for authentication. This way, users will need to log in with their Azure AD credentials to access the files. You can assign roles to specific users or groups to control access. This adds a layer of security, as users must log in with their Azure AD accounts, which can be managed and controlled centrally.
- User Delegation SAS: Use a User Delegation SAS (Shared Access Signature) that is secured with Azure AD credentials instead of the storage account key. This ensures that only authenticated users can access the files. Only authenticated users can generate and use the SAS token, ensuring that even if someone has the link, they cannot access the content without proper authentication.
- Private Blob Containers with Backend Service: Keep your blob containers private and create a backend service (e.g., an Azure Function) that retrieves the files. The backend service can check the user's authentication and authorization before providing access to the files. This adds an additional layer of control, as the backend service can enforce business logic, such as checking user roles or permissions before granting access to the files.
Here are some steps to configure Azure AD authentication for your blob storage
- Assign Azure Roles: Assign Azure roles to users or groups that need access to the blob storage. You can do this in the Azure portal by navigating to your storage account, selecting "Access control (IAM)," and adding role assignments.
- Generate User Delegation SAS: Create a User Delegation SAS for the blob storage. This SAS token will be secured with Azure AD credentials and will require users to authenticate before accessing the files.
- Integrate with Your Chatbot: Ensure your chatbot generates URLs with the User Delegation SAS token. When users click on the URLs, they will be prompted to log in with their Azure AD credentials if they are not already authenticated.
By implementing Azure AD authentication, using User Delegation SAS tokens, and keeping your blob containers private with a backend service, you effectively restrict access to your Azure Blob Storage files. This ensures that only authenticated users with the appropriate permissions can access the content.
Hope the above suggestion helps. Please let us know if you have any further queries.
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.