mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 14:58:16 +08:00

committed by
Tom Pallister

parent
1e5a20c2f2
commit
54cdc74293
@ -22,12 +22,12 @@ namespace Ocelot.Authentication.Middleware
|
||||
|
||||
public async Task Invoke(DownstreamContext context)
|
||||
{
|
||||
if (IsAuthenticatedRoute(context.DownstreamReRoute))
|
||||
if (context.HttpContext.Request.Method.ToUpper() != "OPTIONS" && IsAuthenticatedRoute(context.DownstreamReRoute))
|
||||
{
|
||||
Logger.LogInformation($"{context.HttpContext.Request.Path} is an authenticated route. {MiddlewareName} checking if client is authenticated");
|
||||
|
||||
|
||||
var result = await context.HttpContext.AuthenticateAsync(context.DownstreamReRoute.AuthenticationOptions.AuthenticationProviderKey);
|
||||
|
||||
|
||||
context.HttpContext.User = result.Principal;
|
||||
|
||||
if (context.HttpContext.User.Identity.IsAuthenticated)
|
||||
@ -41,7 +41,7 @@ namespace Ocelot.Authentication.Middleware
|
||||
$"Request for authenticated route {context.HttpContext.Request.Path} by {context.HttpContext.User.Identity.Name} was unauthenticated");
|
||||
|
||||
Logger.LogWarning($"Client has NOT been authenticated for {context.HttpContext.Request.Path} and pipeline error set. {error}");
|
||||
|
||||
|
||||
SetPipelineError(context, error);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user