Skip to content

Commit e10b523

Browse files
feat: Update authorization for public access on maps and change log controllers; enhance documentation for clarity
1 parent 2407195 commit e10b523

4 files changed

Lines changed: 31 additions & 13 deletions

File tree

src/XtremeIdiots.Portal.Web/ApiControllers/MapsController.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
namespace XtremeIdiots.Portal.Web.ApiControllers;
1313

1414
/// <summary>
15-
/// API controller for maps data operations
15+
/// API controller for maps data operations. The public map list endpoint
16+
/// (<c>GetMapListAjax</c>) is anonymous and projects only public-safe map
17+
/// metadata. Admin-only endpoints (e.g. <c>GetMapVotesAjax</c>, which exposes
18+
/// player usernames and IDs) carry their own explicit [Authorize] — each
19+
/// action opts in to its own auth posture rather than inheriting from the
20+
/// class.
1621
/// </summary>
17-
[Authorize(Policy = AuthPolicies.MapRotations_Read)]
1822
[Route("Maps")]
1923
public class MapsController(
2024
IRepositoryApiClient repositoryApiClient,
@@ -31,6 +35,7 @@ public class MapsController(
3135
/// <param name="cancellationToken">Cancellation token for the async operation</param>
3236
/// <returns>JSON data formatted for DataTables consumption</returns>
3337
[HttpPost("GetMapListAjax/{id?}")]
38+
[AllowAnonymous]
3439
[ValidateAntiForgeryToken]
3540
public async Task<IActionResult> GetMapListAjax(GameType? id, CancellationToken cancellationToken = default)
3641
{
@@ -97,11 +102,13 @@ public async Task<IActionResult> GetMapListAjax(GameType? id, CancellationToken
97102
}
98103

99104
/// <summary>
100-
/// Provides paginated map vote data for DataTables Ajax requests
105+
/// Provides paginated map vote data for DataTables Ajax requests (admin-only;
106+
/// the payload exposes player usernames and IDs).
101107
/// </summary>
102108
/// <param name="cancellationToken">Cancellation token for the async operation</param>
103109
/// <returns>JSON data formatted for DataTables consumption</returns>
104110
[HttpPost("GetMapVotesAjax")]
111+
[Authorize(Policy = AuthPolicies.MapRotations_Read)]
105112
[ValidateAntiForgeryToken]
106113
public async Task<IActionResult> GetMapVotesAjax(CancellationToken cancellationToken = default)
107114
{

src/XtremeIdiots.Portal.Web/Controllers/ChangeLogController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
namespace XtremeIdiots.Portal.Web.Controllers;
99

1010
/// <summary>
11-
/// Controller for accessing and managing application change logs
11+
/// Public change log page. Surfaces portal development activity (commits, PRs,
12+
/// build status) sourced directly from GitHub's public REST API via
13+
/// client-side fetches — no portal backend data is returned from this
14+
/// controller.
1215
/// </summary>
13-
[Authorize]
16+
[AllowAnonymous]
1417
public class ChangeLogController(
1518
TelemetryClient telemetryClient,
1619
ILogger<ChangeLogController> logger,

src/XtremeIdiots.Portal.Web/Controllers/HomeController.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
using Microsoft.AspNetCore.Authorization;
33
using Microsoft.AspNetCore.Mvc;
44
using MX.Observability.ApplicationInsights.Auditing;
5-
using XtremeIdiots.Portal.Web.Auth.Constants;
65

76
namespace XtremeIdiots.Portal.Web.Controllers;
87

98
/// <summary>
10-
/// Handles the main dashboard and home page functionality
9+
/// Handles the public landing / home page. The content is a public marketing
10+
/// page (community links, public server list via view component, donation block)
11+
/// and must remain reachable without authentication.
1112
/// </summary>
12-
[Authorize]
13+
[AllowAnonymous]
1314
public class HomeController(
1415
TelemetryClient telemetryClient,
1516
ILogger<HomeController> logger,
@@ -19,10 +20,10 @@ public class HomeController(
1920
// No additional dependencies required for current actions
2021

2122
/// <summary>
22-
/// Displays the main dashboard for authenticated users
23+
/// Displays the public landing page
2324
/// </summary>
2425
/// <param name="cancellationToken">Cancellation token for the async operation</param>
25-
/// <returns>Dashboard view with user-specific content</returns>
26+
/// <returns>Landing page view</returns>
2627
[HttpGet]
2728
public IActionResult Index(CancellationToken cancellationToken = default)
2829
{

src/XtremeIdiots.Portal.Web/Controllers/MapsController.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
namespace XtremeIdiots.Portal.Web.Controllers;
1111

1212
/// <summary>
13-
/// Provides map browsing, search, and image retrieval functionality
13+
/// Provides map browsing, search, and image retrieval. The public map browsing
14+
/// endpoints (<c>Index</c>, <c>GameIndex</c>, <c>MapImage</c>) are anonymous —
15+
/// they expose only public map metadata and imagery. Admin-only actions
16+
/// (e.g. <c>VoteLog</c>) carry their own explicit [Authorize] — each action
17+
/// opts in to its own auth posture rather than inheriting from the class.
1418
/// </summary>
1519
/// <remarks>
1620
/// Initializes a new instance of the MapsController
@@ -19,7 +23,6 @@ namespace XtremeIdiots.Portal.Web.Controllers;
1923
/// <param name="telemetryClient">Client for tracking telemetry data</param>
2024
/// <param name="logger">Logger instance for this controller</param>
2125
/// <param name="configuration">Application configuration</param>
22-
[Authorize(Policy = AuthPolicies.MapRotations_Read)]
2326
public class MapsController(
2427
IRepositoryApiClient repositoryApiClient,
2528
TelemetryClient telemetryClient,
@@ -34,6 +37,7 @@ public class MapsController(
3437
/// <param name="cancellationToken">Cancellation token for the async operation</param>
3538
/// <returns>Maps index view</returns>
3639
[HttpGet]
40+
[AllowAnonymous]
3741
public async Task<IActionResult> Index(CancellationToken cancellationToken = default)
3842
{
3943
return await ExecuteWithErrorHandlingAsync(() => Task.FromResult<IActionResult>(View()), nameof(Index)).ConfigureAwait(false);
@@ -46,6 +50,7 @@ public async Task<IActionResult> Index(CancellationToken cancellationToken = def
4650
/// <param name="cancellationToken">Cancellation token for the async operation</param>
4751
/// <returns>Maps index view with game type filter applied</returns>
4852
[HttpGet]
53+
[AllowAnonymous]
4954
public async Task<IActionResult> GameIndex(GameType? id, CancellationToken cancellationToken = default)
5055
{
5156
return await ExecuteWithErrorHandlingAsync(() =>
@@ -63,6 +68,7 @@ public async Task<IActionResult> GameIndex(GameType? id, CancellationToken cance
6368
/// <param name="cancellationToken">Cancellation token for the async operation</param>
6469
/// <returns>Redirect to map image URI or default no-image placeholder</returns>
6570
[HttpGet]
71+
[AllowAnonymous]
6672
public async Task<IActionResult> MapImage(GameType gameType, string mapName, CancellationToken cancellationToken = default)
6773
{
6874
return await ExecuteWithErrorHandlingAsync(async () =>
@@ -88,11 +94,12 @@ public async Task<IActionResult> MapImage(GameType gameType, string mapName, Can
8894
}
8995

9096
/// <summary>
91-
/// Displays the map vote log/audit page
97+
/// Displays the map vote log/audit page (admin-only)
9298
/// </summary>
9399
/// <param name="cancellationToken">Cancellation token for the async operation</param>
94100
/// <returns>Vote log view</returns>
95101
[HttpGet]
102+
[Authorize(Policy = AuthPolicies.MapRotations_Read)]
96103
public async Task<IActionResult> VoteLog(CancellationToken cancellationToken = default)
97104
{
98105
return await ExecuteWithErrorHandlingAsync(() => Task.FromResult<IActionResult>(View()), nameof(VoteLog)).ConfigureAwait(false);

0 commit comments

Comments
 (0)