Skip to content

Commit fe2ea26

Browse files
Fix null handling and ensure requirement
1 parent 884f76e commit fe2ea26

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private static readonly ConcurrentTLruCache<string, ImageMetadata> SourceMetadat
3838
/// <summary>
3939
/// Used to temporarily store cached HMAC-s to reduce the overhead of HMAC token generation.
4040
/// </summary>
41-
private static readonly ConcurrentTLruCache<string, string> HMACTokenLru
41+
private static readonly ConcurrentTLruCache<string, string?> HMACTokenLru
4242
= new(1024, TimeSpan.FromSeconds(30));
4343

4444
/// <summary>
@@ -244,7 +244,7 @@ private async Task Invoke(HttpContext httpContext, bool retry)
244244

245245
// At this point we know that this is an image request designed for processing via this middleware.
246246
// Check for a token if required and reject if invalid.
247-
if (checkHMAC && hmac != token)
247+
if (checkHMAC && (hmac != token || (hmac is null && commands.Count > 0)))
248248
{
249249
SetBadRequest(httpContext);
250250
return;

0 commit comments

Comments
 (0)