Remove admin key support; admin must be authenticated
This commit is contained in:
@@ -235,14 +235,10 @@ internal static class EndpointHelpers
|
||||
return uri.Scheme is "http" or "https";
|
||||
}
|
||||
|
||||
public static async Task<bool> IsAdmin(HttpContext ctx, AppDbContext db, IConfiguration config)
|
||||
public static async Task<bool> IsAdmin(HttpContext ctx, AppDbContext db)
|
||||
{
|
||||
var player = await GetAuthenticatedPlayer(ctx, db);
|
||||
if (player?.IsAdmin == true) return true;
|
||||
|
||||
var provided = ctx.Request.Headers["X-Admin-Key"].FirstOrDefault();
|
||||
var expected = config["ADMIN_PASSWORD"];
|
||||
return !string.IsNullOrWhiteSpace(expected) && provided == expected;
|
||||
return player?.IsAdmin == true;
|
||||
}
|
||||
|
||||
public static AppState NewAppState() => new()
|
||||
|
||||
Reference in New Issue
Block a user