API key protection

This commit is contained in:
Paul Schneider 2026-07-05 21:18:37 +01:00
commit 38bb7e40ef
7 changed files with 143 additions and 19 deletions

View file

@ -31,12 +31,12 @@ namespace isnd.Controllers
try
{
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
string apiKey = Request.Headers["X-NuGet-ApiKey"][0];
string apiKey = Request.Headers["X-NuGet-ApiKey"].FirstOrDefault() ?? string.Empty;
ViewData["versionId"] = typeof(PackagesController).Assembly.FullName;
var files = new List<string>();
ViewData["files"] = files;
var clearkey = protector.Unprotect(apiKey);
var clearkey = ApiKeyProtector.UnprotectWithFallback(protector, apiKey);
var apikey = dbContext.ApiKeys.SingleOrDefault(k => k.Id == clearkey);
if (apikey == null)
{