Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions DevProxy/ApiSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ public static string[] GetAllowedOrigins(IConfiguration configuration)
return origins;
}

public static async Task CheckOriginAsync(HttpContext context, Func<Task> next, string[] allowedOrigins)
public static Task CheckOriginAsync(HttpContext context, Func<Task> 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) =>
Expand Down Expand Up @@ -118,7 +118,7 @@ public static async Task<HttpClient> CreateClientAsync(ProxyInstanceState state,
}
}

public static async Task AuthenticateAsync(HttpContext context, Func<Task> next)
public static Task AuthenticateAsync(HttpContext context, Func<Task> next)
{
var authorization = context.Request.Headers.Authorization.ToString();
const string prefix = "Bearer ";
Expand All @@ -129,10 +129,10 @@ public static async Task AuthenticateAsync(HttpContext context, Func<Task> 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();
}
}
2 changes: 1 addition & 1 deletion DevProxy/DevProxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.12" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.23.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="18.7.23" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="18.12.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="OpenTelemetry" Version="1.19.1" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.19.1" />
Expand Down
8 changes: 4 additions & 4 deletions DevProxy/State/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ public static string GenerateLogFilePath()
/// <summary>
/// Saves the state of a running detached instance to a per-PID state file.
/// </summary>
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);
}

/// <summary>
Expand All @@ -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.
/// </summary>
public static async Task<ProxyInstanceState?> LoadStateByPidAsync(int pid, CancellationToken cancellationToken = default)
public static Task<ProxyInstanceState?> LoadStateByPidAsync(int pid, CancellationToken cancellationToken = default)
{
return await LoadStateFromFileAsync(GetInstanceStateFilePath(pid), cancellationToken);
return LoadStateFromFileAsync(GetInstanceStateFilePath(pid), cancellationToken);
}

/// <summary>
Expand Down
18 changes: 9 additions & 9 deletions DevProxy/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down Expand Up @@ -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"
}
Expand Down
Loading