Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit 9cddd16

Browse files
Merge pull request #102 from DuendeSoftware/dom/metadata-orderingD
Fix metadata order parsing
2 parents a906233 + baa3137 commit 9cddd16

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Duende.Bff/BffMiddleware.cs

+8-11
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,15 @@ public async Task Invoke(HttpContext context)
5151
return;
5252
}
5353

54-
var localEndpointMetadata = endpoint.Metadata.GetOrderedMetadata<BffApiAttribute>();
55-
if (localEndpointMetadata.Any())
54+
var localEndpointMetadata = endpoint.Metadata.GetMetadata<BffApiAttribute>();
55+
if (localEndpointMetadata is { RequireAntiForgeryCheck: true })
5656
{
57-
var requireLocalAntiForgeryCheck = localEndpointMetadata.First().RequireAntiForgeryCheck;
58-
if (requireLocalAntiForgeryCheck)
57+
if (!context.CheckAntiForgeryHeader(_options))
5958
{
60-
if (!context.CheckAntiForgeryHeader(_options))
61-
{
62-
_logger.AntiForgeryValidationFailed(context.Request.Path);
59+
_logger.AntiForgeryValidationFailed(context.Request.Path);
6360

64-
context.Response.StatusCode = 401;
65-
return;
66-
}
61+
context.Response.StatusCode = 401;
62+
return;
6763
}
6864
}
6965
else
@@ -82,7 +78,7 @@ public async Task Invoke(HttpContext context)
8278
}
8379

8480
#if NETCOREAPP3_1
85-
context.Response.OnStarting(() =>
81+
context.Response.OnStarting(() =>
8682
{
8783
// outbound: for .NET Core 3.1 - we assume that an API will never return a 302
8884
// if a 302 is returned, that must be the challenge to the OIDC provider
@@ -101,6 +97,7 @@ public async Task Invoke(HttpContext context)
10197
context.Response.Headers.Remove("Set-Cookie");
10298
}
10399
}
100+
104101
return Task.CompletedTask;
105102
});
106103
#endif

0 commit comments

Comments
 (0)