azureazureservicebusazure-sdk-.netazure-sas

Service bus sas token working even after the expiry time


I was investigating access to a service bus done through SAS token. I converted the "se" ticks value from the token to actual date-time and found that to be 1 AM which was 1 minute from the time I observed. That means the token must expire in a minute. I was constantly sending messages to the service using the aforementioned Sas token and noticed that the send was happening even after 1 min had elapsed. The actual expiry happened and the "token expiry" error was thrown after 6 mins. i.e instead of 1:00:00, it happened at 1:05:00. Is there a default added by the service bus or am I missing something here?

I was using Azure.Messaging.ServiceBus latest .net nuget package.


Solution

  • SAS tokens have an certain amount of clock skew, to account for machines having different set clocks.

    I cannot find the exact allowed time for Azure ServiceBus, but Azure Blob Storage allows for 15 minutes clock skew in their SAS tokens.

    remember that you may observe up to 15 minutes of clock skew in either direction on any request.
    -- https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview