Skip to content

Commit

Permalink
Merge branch 'main' into support-http-etags-and-if-none-match-header
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Mar 4, 2025
2 parents 8d7c4da + 53a6a45 commit b8243f5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public AuthorizationController(
}

[HttpPost("~/connect/token")]
[IgnoreAntiforgeryToken]
[Produces("application/json")]
[Consumes("application/x-www-form-urlencoded")]
[AllowAnonymous]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Backbone.BuildingBlocks.Infrastructure.CorrelationIds;
using Backbone.Tooling.Extensions;
using Microsoft.AspNetCore.Http;

namespace Backbone.BuildingBlocks.API.Mvc.Middleware;
Expand All @@ -20,6 +21,10 @@ public async Task InvokeAsync(HttpContext context)
{
correlationId = CustomLogContext.GenerateCorrelationId();
}
else
{
correlationId = correlationId.Trim().ReplaceLineEndings("").TruncateToXChars(100);
}

context.Response.Headers["X-Correlation-ID"] = correlationId;

Expand Down
5 changes: 5 additions & 0 deletions BuildingBlocks/src/Tooling/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public static bool MatchesRegex(this string text, string regexString)
return regex.IsMatch(text);
}

public static string TruncateToXChars(this string text, int maxLength)
{
return text[..Math.Min(text.Length, maxLength)];
}

public static byte[] GetBytes(this string text)
{
return Encoding.UTF8.GetBytes(text);
Expand Down

0 comments on commit b8243f5

Please sign in to comment.