Skip to content

Azure generate_blob_sas() does not set a start time #1529

@andyp05

Description

@andyp05

While this is not an issue for the django users, it does invalidate a safety check in azure. I have other apps that access the storage account and the following settings can't be activated without a start date.

Image

Based on the Example from Microsoft docs the code change would be:

        start_time = datetime.datetime.now(datetime.timezone.utc) - timedelta(minutes=1)
        if expire:
            sas_token = generate_blob_sas(
                self.account_name,
                self.azure_container,
                name,
                account_key=self.account_key,
                user_delegation_key=user_delegation_key,
                permission=permission,
                expiry=expiry,
                start=start_time,
                **params,
            )

Need to subtract a small amount of time (1 minute) to make sure it still works if clocks are off by even a little.
Only the start_time and start= lines need to be added.
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions