Rollback API deleted by mistake on Webhook Client
This commit is contained in:
parent
771d62a43a
commit
7edb45179f
@ -14,6 +14,37 @@ builder.Services.AddControllers();
|
|||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
app.UseServiceDefaults();
|
app.UseServiceDefaults();
|
||||||
|
|
||||||
|
app.Map("/check", capp =>
|
||||||
|
{
|
||||||
|
capp.Run(async (context) =>
|
||||||
|
{
|
||||||
|
if ("OPTIONS".Equals(context.Request.Method, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
var validateToken = bool.TrueString.Equals(builder.Configuration["ValidateToken"], StringComparison.InvariantCultureIgnoreCase);
|
||||||
|
var header = context.Request.Headers[HeaderNames.WebHookCheckHeader];
|
||||||
|
var value = header.FirstOrDefault();
|
||||||
|
var tokenToValidate = builder.Configuration["Token"];
|
||||||
|
if (!validateToken || value == tokenToValidate)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(tokenToValidate))
|
||||||
|
{
|
||||||
|
context.Response.Headers.Add(HeaderNames.WebHookCheckHeader, tokenToValidate);
|
||||||
|
}
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("Invalid token");
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Fix samesite issue when running eShop from docker-compose locally as by default http protocol is being used
|
// Fix samesite issue when running eShop from docker-compose locally as by default http protocol is being used
|
||||||
// Refer to https://github.com/dotnet-architecture/eShopOnContainers/issues/1391
|
// Refer to https://github.com/dotnet-architecture/eShopOnContainers/issues/1391
|
||||||
app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Lax });
|
app.UseCookiePolicy(new CookiePolicyOptions { MinimumSameSitePolicy = SameSiteMode.Lax });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user