Import march-2020-03-10 from private repo (scrubbed 2026-05-27)

Targets Rec Room 2020.03.10 client (also serves 2020.03.06).

Re-import after adding:
- DorkNet.ClientMod/dorknet-clientmod.json.template — config schema
  the launcher's manifest-driven patcher renders into UserData/.
- tools/build-patcher-zip.ps1 — produces dorknet-clientpatch-{key}.zip
  for v1-march-* Release uploads.
- .github/workflows/release.yml — on tag push publishes both
  dorknet-server-march_2020_03_10-win-x64.zip and
  dorknet-clientpatch-march_2020_03_10.zip as Release assets.

Same scrub rules as december; tools/build-patcher-zip.ps1 added to
the maintainer-side allow-list so it survives.
This commit is contained in:
Alexa
2026-05-27 01:06:12 +03:00
commit d471b418b9
389 changed files with 104767 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.EntityFrameworkCore;
using DorkNet.Server.Data;
namespace DorkNet.Server.Auth;
/// <summary>
/// Action / controller filter that 403s any request whose
/// JWT-resolved player doesn't have <c>IsAdmin == true</c>. Does not
/// itself authenticate — pair it with <c>[Authorize]</c> to ensure a
/// valid bearer is present before this runs.
///
/// Usage:
/// <code>
/// [Authorize]
/// [AdminOnly]
/// [Route("api/admin/v1")]
/// public class AdminController { ... }
/// </code>
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
public class AdminOnlyAttribute : Attribute, IAsyncAuthorizationFilter
{
public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
{
// AuthorizationFilterContext.HttpContext is always populated and
// exposes the same ClaimsPrincipal a controller would see, so
// there's no reason to round-trip through IHttpContextAccessor
// (which isn't even registered in this app's DI container — the
// earlier lookup crashed every admin request with
// "No service for type IHttpContextAccessor has been registered").
if (ControllerBaseExtensions.CurrentPlayerId(context.HttpContext.User) is not long id)
{
// No JWT → defer to [Authorize]'s 401.
context.Result = new UnauthorizedResult();
return;
}
var db = context.HttpContext.RequestServices
.GetRequiredService<DorkNetDbContext>();
var isAdmin = await db.Players
.Where(p => p.Id == id)
.Select(p => p.IsAdmin)
.FirstOrDefaultAsync();
if (!isAdmin)
context.Result = new ForbidResult();
}
}