0 votes

Our.Umbraco.MediaProtection

This prevents bad actors from manipulating processing parameters and DOS your site by requesting a large amount of slightly different image URLs that all need to process the image (a potentially CPU and memory expensive process). These processed images are then also saved to the ImageSharp cache (stored in umbraco\Data\TEMP\MediaCache by default), which doesn't have a built-in way to clean up old/infrequently used files and could therefore fill up your disk.

Usage:
You know GetCropUrl() build in i Umbraco. Well after installing this package you need to use GetHmacUrl() i can the same as Umbraco but i generate a key to prevents bad actors.

If you trying to use GetCropUrl() or simple Url() + "?width=400" the image wil get an statuscode 400.

appsettings
"MediaProtection": {
    "Secret": "...",
    "HmacHashMode": "Hmac512"
}

The HmacHasMode is default Hmac256. But you can also config it to Hmac384 or Hmac512.
The Secrect, is an string witch is required.


NuGet install instructions for Umbraco 9+

dotnet add package Our.Umbraco.MediaProtection

Package owner

Lucas Bisgaard

Lucas Bisgaard

Lucas has 126 karma points

Package Information

  • Package owner: Lucas Bisgaard
  • Created: 10/09/2022
  • Current version 1.0.1
  • License MIT
  • Downloads on Our: 0
  • Downloads on NuGet: 124
  • Total downloads : 124