Skip to content

Commit

Permalink
Merge pull request #102 from DuendeSoftware/dom/metadata-orderingD
Browse files Browse the repository at this point in the history
Fix metadata order parsing
  • Loading branch information
leastprivilege authored Jun 13, 2022
2 parents a906233 + baa3137 commit 9cddd16
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/Duende.Bff/BffMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,15 @@ public async Task Invoke(HttpContext context)
return;
}

var localEndpointMetadata = endpoint.Metadata.GetOrderedMetadata<BffApiAttribute>();
if (localEndpointMetadata.Any())
var localEndpointMetadata = endpoint.Metadata.GetMetadata<BffApiAttribute>();
if (localEndpointMetadata is { RequireAntiForgeryCheck: true })
{
var requireLocalAntiForgeryCheck = localEndpointMetadata.First().RequireAntiForgeryCheck;
if (requireLocalAntiForgeryCheck)
if (!context.CheckAntiForgeryHeader(_options))
{
if (!context.CheckAntiForgeryHeader(_options))
{
_logger.AntiForgeryValidationFailed(context.Request.Path);
_logger.AntiForgeryValidationFailed(context.Request.Path);

context.Response.StatusCode = 401;
return;
}
context.Response.StatusCode = 401;
return;
}
}
else
Expand All @@ -82,7 +78,7 @@ public async Task Invoke(HttpContext context)
}

#if NETCOREAPP3_1
context.Response.OnStarting(() =>
context.Response.OnStarting(() =>
{
// outbound: for .NET Core 3.1 - we assume that an API will never return a 302
// if a 302 is returned, that must be the challenge to the OIDC provider
Expand All @@ -101,6 +97,7 @@ public async Task Invoke(HttpContext context)
context.Response.Headers.Remove("Set-Cookie");
}
}
return Task.CompletedTask;
});
#endif
Expand Down

0 comments on commit 9cddd16

Please sign in to comment.