Skip to content

Commit

Permalink
auth nuked
Browse files Browse the repository at this point in the history
  • Loading branch information
stone-w4tch3r committed Jun 26, 2024
1 parent 52f2240 commit 85215b7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
1 change: 0 additions & 1 deletion server/SuperchartBackend/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace SuperchartBackend;

[ApiController]
[BasicAuth]
[EnableCors]
[Route("[controller]/[action]")]
public class ChartsController(Service service) : ControllerBase
Expand Down
31 changes: 0 additions & 31 deletions server/SuperchartBackend/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,13 @@
builder.Services.AddScoped<Repository>();
builder.Services.AddScoped<ChartNameHandler>();

builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(
// options.AddPolicy("AllowAll",
b =>
{
b.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddOpenApiDocument(ConfigureOpenApiDocs);
builder.Services.AddScoped<SwaggerBasicAuthMiddleware>();

var app = builder.Build();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.Use(async (context, next) =>
{
if (context.Request.Method == "OPTIONS")
{
context.Response.Headers.Append("Access-Control-Allow-Origin", "*");
context.Response.Headers.Append("Access-Control-Allow-Headers", "Content-Type, Authorization");
context.Response.Headers.Append("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
context.Response.StatusCode = 200;
await context.Response.CompleteAsync();
}
else
{
await next();
}
});

app.UseCors();
app.MapControllers();
app.UseMiddleware<SwaggerBasicAuthMiddleware>();
app.UseOpenApi();
Expand Down

0 comments on commit 85215b7

Please sign in to comment.