Skip to content
Open
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
276 changes: 203 additions & 73 deletions OcStockAPI/Controllers/TestController.cs

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions OcStockAPI/Controllers/TrackedStocksController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ namespace OcStockAPI.Controllers
[ApiController]
[Route("api/[controller]")]
[Produces("application/json")]
[Authorize] // Require authentication for all endpoints
[SwaggerTag("Tracked stocks management - requires authentication")]
#if DEBUG
[AllowAnonymous] // Development: Allow anonymous access for testing
#else
[Authorize] // Production: Require authentication
#endif
Comment on lines +12 to +16
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using #if DEBUG for conditional authentication is problematic because DEBUG is a compilation flag, not a runtime environment check. This means the code behavior depends on how the application was compiled, not where it's deployed. A DEBUG build deployed to production would still allow anonymous access. Use builder.Environment.IsDevelopment() instead for proper runtime environment detection, consistent with how it's used elsewhere in the codebase (e.g., Program.cs).

Suggested change
#if DEBUG
[AllowAnonymous] // Development: Allow anonymous access for testing
#else
[Authorize] // Production: Require authentication
#endif
[Authorize] // Require authentication; allow anonymous access in development via middleware configuration

Copilot uses AI. Check for mistakes.
[SwaggerTag("Tracked stocks management")]
public class TrackedStocksController : ControllerBase
{
private readonly ITrackedStockService _trackedStockService;
Expand Down
3 changes: 0 additions & 3 deletions OcStockAPI/DataContext/DpapiDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using OcStockAPI.Entities;
using OcStockAPI.Entities.Settings;
using OcStockAPI.Entities.Identity;

namespace OcStockAPI.DataContext
{
Expand Down
2 changes: 0 additions & 2 deletions OcStockAPI/DataContext/OcStockDbContextFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace OcStockAPI.DataContext;

Expand Down
100 changes: 0 additions & 100 deletions OcStockAPI/Middleware/SuperKeyAuthenticationMiddleware.cs

This file was deleted.

4 changes: 0 additions & 4 deletions OcStockAPI/OcStockAPI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,4 @@
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="9.0.5" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

</Project>
Loading
Loading