Skip to content

Commit

Permalink
Resolved BugFix #993 (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersondepaiva authored and thiagoloureiro committed Sep 23, 2019
1 parent 88f3196 commit c8a2144
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class AuthorisationMiddleware : OcelotMiddleware

public async Task Invoke(DownstreamContext context)
{
if (IsAuthenticatedRoute(context.DownstreamReRoute))
if (!IsOptionsHttpMethod(context) && IsAuthenticatedRoute(context.DownstreamReRoute))
{
Logger.LogInformation("route is authenticated scopes must be checked");

Expand All @@ -52,7 +52,7 @@ public async Task Invoke(DownstreamContext context)
}
}

if (IsAuthorisedRoute(context.DownstreamReRoute))
if (!IsOptionsHttpMethod(context) && IsAuthorisedRoute(context.DownstreamReRoute))
{
Logger.LogInformation("route is authorised");

Expand Down Expand Up @@ -98,6 +98,11 @@ private static bool IsAuthenticatedRoute(DownstreamReRoute reRoute)
private static bool IsAuthorisedRoute(DownstreamReRoute reRoute)
{
return reRoute.IsAuthorised;
}

private static bool IsOptionsHttpMethod(DownstreamContext context)
{
return context.HttpContext.Request.Method.ToUpper() == "OPTIONS";
}
}
}

0 comments on commit c8a2144

Please sign in to comment.