1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-05 00:01:30 +01:00

[AC-1971] Add SwaggerUI to CORS policy (#3583)

* Allow SwaggerUI authorize requests if in development
This commit is contained in:
Thomas Rittson 2023-12-19 11:51:46 +10:00 committed by GitHub
parent c2d36cb28b
commit af7811ba9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -213,7 +213,11 @@ public class Startup
app.UseRouting();
// Add Cors
app.UseCors(policy => policy.SetIsOriginAllowed(o => CoreHelpers.IsCorsOriginAllowed(o, globalSettings))
app.UseCors(policy => policy.SetIsOriginAllowed(o =>
CoreHelpers.IsCorsOriginAllowed(o, globalSettings) ||
// If development - allow requests from the Swagger UI so it can authorize
(Environment.IsDevelopment() && o == globalSettings.BaseServiceUri.Api))
.AllowAnyMethod().AllowAnyHeader().AllowCredentials());
// Add current context