diff --git a/DevProxy/ApiSecurity.cs b/DevProxy/ApiSecurity.cs index d20e3a7f..065e8e72 100644 --- a/DevProxy/ApiSecurity.cs +++ b/DevProxy/ApiSecurity.cs @@ -43,17 +43,17 @@ public static string[] GetAllowedOrigins(IConfiguration configuration) return origins; } - public static async Task CheckOriginAsync(HttpContext context, Func next, string[] allowedOrigins) + public static Task CheckOriginAsync(HttpContext context, Func next, string[] allowedOrigins) { context.Response.Headers.CacheControl = "no-store"; if (context.Request.Headers.TryGetValue("Origin", out var origin) && !allowedOrigins.Contains(origin.ToString(), StringComparer.Ordinal)) { context.Response.StatusCode = StatusCodes.Status403Forbidden; - return; + return Task.CompletedTask; } - await next(); + return next(); } public static string GetTokenFilePath(int pid) => @@ -118,7 +118,7 @@ public static async Task CreateClientAsync(ProxyInstanceState state, } } - public static async Task AuthenticateAsync(HttpContext context, Func next) + public static Task AuthenticateAsync(HttpContext context, Func next) { var authorization = context.Request.Headers.Authorization.ToString(); const string prefix = "Bearer "; @@ -129,10 +129,10 @@ public static async Task AuthenticateAsync(HttpContext context, Func next) { context.Response.StatusCode = StatusCodes.Status401Unauthorized; context.Response.Headers.WWWAuthenticate = "Bearer"; - return; + return Task.CompletedTask; } context.Response.Headers.CacheControl = "no-store"; - await next(); + return next(); } } \ No newline at end of file diff --git a/DevProxy/DevProxy.csproj b/DevProxy/DevProxy.csproj index d38af1ff..55ad474f 100644 --- a/DevProxy/DevProxy.csproj +++ b/DevProxy/DevProxy.csproj @@ -36,7 +36,7 @@ - + diff --git a/DevProxy/State/StateManager.cs b/DevProxy/State/StateManager.cs index 4457a5fb..957542b9 100644 --- a/DevProxy/State/StateManager.cs +++ b/DevProxy/State/StateManager.cs @@ -88,12 +88,12 @@ public static string GenerateLogFilePath() /// /// Saves the state of a running detached instance to a per-PID state file. /// - public static async Task SaveStateAsync(ProxyInstanceState state, CancellationToken cancellationToken = default) + public static Task SaveStateAsync(ProxyInstanceState state, CancellationToken cancellationToken = default) { var stateFilePath = GetInstanceStateFilePath(state.Pid); var json = JsonSerializer.Serialize(state, _jsonOptions); - await PrivateFiles.WriteAllTextAsync(stateFilePath, json, cancellationToken); + return PrivateFiles.WriteAllTextAsync(stateFilePath, json, cancellationToken); } /// @@ -114,9 +114,9 @@ public static async Task SaveStateAsync(ProxyInstanceState state, CancellationTo /// Loads the state of a specific instance by PID. /// Returns null if no state file exists or the process is no longer running. /// - public static async Task LoadStateByPidAsync(int pid, CancellationToken cancellationToken = default) + public static Task LoadStateByPidAsync(int pid, CancellationToken cancellationToken = default) { - return await LoadStateFromFileAsync(GetInstanceStateFilePath(pid), cancellationToken); + return LoadStateFromFileAsync(GetInstanceStateFilePath(pid), cancellationToken); } /// diff --git a/DevProxy/packages.lock.json b/DevProxy/packages.lock.json index f91ed069..f0eb17a6 100644 --- a/DevProxy/packages.lock.json +++ b/DevProxy/packages.lock.json @@ -35,12 +35,12 @@ }, "Microsoft.VisualStudio.Threading": { "type": "Direct", - "requested": "[18.7.23, )", - "resolved": "18.7.23", - "contentHash": "IiK1otNipjvDIk8SClYwOP1uRZLpVA3luVMKSTPhhjhxqv2pp8/tzfLy/IB7HW+voeEodCTHh0q9LbLIBdGNKA==", + "requested": "[18.12.1, )", + "resolved": "18.12.1", + "contentHash": "2+fsNegeifo4xVC8z4xJuWgr8H+GRjKuEk5gJT6HM0iujWkaLQ1Helaa8LWnXVKq/9e9Sqvefu4iacaQhB7RXA==", "dependencies": { - "Microsoft.VisualStudio.Threading.Analyzers": "18.7.23", - "Microsoft.VisualStudio.Threading.Only": "18.7.23", + "Microsoft.VisualStudio.Threading.Analyzers": "18.12.1", + "Microsoft.VisualStudio.Threading.Only": "18.12.1", "Microsoft.VisualStudio.Validation": "17.13.22" } }, @@ -233,13 +233,13 @@ }, "Microsoft.VisualStudio.Threading.Analyzers": { "type": "Transitive", - "resolved": "18.7.23", - "contentHash": "dyj6z8m+LFjpeH69hdnciCcRCmD0YgMlvuQEywiEshjqj/blgQ+PuWX8Vd5gkWQFoBN4e+TFxx6DvGNSv/gIKg==" + "resolved": "18.12.1", + "contentHash": "sQt7NpnselT1gP1a7bTfhmfHYV0jbavst/8mOoWTMSjXhXzWPssqgBoIwrxNsgJUa7XQzD2raSRMAFfmlepxNw==" }, "Microsoft.VisualStudio.Threading.Only": { "type": "Transitive", - "resolved": "18.7.23", - "contentHash": "iOaVAQLPt1KxFyYqZqKxqNu8BgQUiPLNeT8XhX+549eWaGw49e1MxjlkjTIBwvlfrU4lPp+Nm99oRpmsgN7RJw==", + "resolved": "18.12.1", + "contentHash": "2i4Gy3X3M0W7KM9ZfAQBH0C5xEPXfy3JpgH8DPPkGcIe0bSEbuG1cIJlxlq2COGf8NeKGmUWRQOI1OjDVDndZg==", "dependencies": { "Microsoft.VisualStudio.Validation": "17.13.22" }