This commit is contained in:
Paul Schneider
2021-08-15 01:50:07 +01:00
parent 5f0dfee768
commit ae114c68db
26 changed files with 99 additions and 38 deletions

View File

@ -21,18 +21,18 @@ namespace isn.Controllers
public class ApiKeysController : Controller
{
private readonly ApplicationDbContext dbContext;
private readonly NugetSettings nugetSettings;
private readonly IsndSettings isndSettings;
private readonly UserManager<ApplicationUser> _userManager;
private readonly IDataProtector protector;
public ApiKeysController(ApplicationDbContext dbContext,
IOptions<NugetSettings> nugetSettingsOptions,
IOptions<IsndSettings> isndSettingsOptions,
IDataProtectionProvider provider,
UserManager<ApplicationUser> userManager)
{
this.dbContext = dbContext;
this.nugetSettings = nugetSettingsOptions.Value;
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
this.isndSettings = isndSettingsOptions.Value;
protector = provider.CreateProtector(isndSettings.ProtectionTitle);
_userManager = userManager;
}
@ -59,7 +59,7 @@ namespace isn.Controllers
{
string userid = User.FindFirstValue(ClaimTypes.NameIdentifier);
IQueryable<ApiKey> userKeys = GetUserKeys();
if (userKeys.Count() >= nugetSettings.MaxUserKeyCount)
if (userKeys.Count() >= isndSettings.MaxUserKeyCount)
{
ModelState.AddModelError(null, "Maximum key count reached");
return View();

View File

@ -71,7 +71,7 @@ namespace isn.Controllers
pkgid = reader.GetId();
version = reader.GetVersion();
string pkgidpath = Path.Combine(_nugetSettings.PackagesRootDir,
string pkgidpath = Path.Combine(_isndSettings.PackagesRootDir,
pkgid);
pkgpath = Path.Combine(pkgidpath, version.ToFullString());
string name = $"{pkgid}-{version}.nupkg";

View File

@ -32,7 +32,7 @@ namespace isn.Controllers
private readonly ILogger<PackagesController> _logger;
private readonly IDataProtector _protector;
private readonly NugetSettings _nugetSettings;
private readonly IsndSettings _isndSettings;
readonly ApplicationDbContext _dbContext;
private readonly PackageManager _packageManager;
private readonly IUnleash _unleashĈlient;
@ -40,13 +40,13 @@ namespace isn.Controllers
public PackagesController(
ILoggerFactory loggerFactory,
IDataProtectionProvider provider,
IOptions<NugetSettings> nugetOptions,
IOptions<IsndSettings> isndOptions,
IUnleash unleashĈlient,
ApplicationDbContext dbContext)
{
_logger = loggerFactory.CreateLogger<PackagesController>();
_nugetSettings = nugetOptions.Value;
_protector = provider.CreateProtector(_nugetSettings.ProtectionTitle);
_isndSettings = isndOptions.Value;
_protector = provider.CreateProtector(_isndSettings.ProtectionTitle);
_dbContext = dbContext;
_packageManager = new PackageManager(dbContext);
_unleashĈlient = unleashĈlient;
@ -158,7 +158,7 @@ namespace isn.Controllers
[FromRoute] string id, [FromRoute] string lower,
[FromRoute] string idf, [FromRoute] string lowerf)
{
var pkgpath = Path.Combine(_nugetSettings.PackagesRootDir,
var pkgpath = Path.Combine(_isndSettings.PackagesRootDir,
id, lower, $"{id}-{lower}.nupkg"
);
@ -180,7 +180,7 @@ namespace isn.Controllers
[FromRoute][SafeName][Required] string idf,
[FromRoute][SafeName][Required] string lowerf)
{
var pkgpath = Path.Combine(_nugetSettings.PackagesRootDir,
var pkgpath = Path.Combine(_isndSettings.PackagesRootDir,
id, lower, $"{id}.nuspec");
FileInfo pkgfi = new FileInfo(pkgpath);

View File

@ -1,6 +1,6 @@
namespace isn.Entities
{
public class NugetSettings
public class IsndSettings
{
public string ProtectionTitle {get; set;}
public string PackagesRootDir {get; set;}

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210424155323_init")]

View File

@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class init : Migration
{

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210502153508_api-keys")]

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class apikeys : Migration
{

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210508012908_ApkiKey.CreationDate")]

View File

@ -1,7 +1,7 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class ApkiKeyCreationDate : Migration
{

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210516060430_packages")]

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class packages : Migration
{

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210522194803_packageVersionKey")]

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class packageVersionKey : Migration
{

View File

@ -7,7 +7,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210621214109_version-types")]

View File

@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
public partial class versiontypes : Migration
{

View File

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isn.Data;
namespace nugethost.Migrations
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot

View File

@ -74,8 +74,8 @@ namespace isn
// _unleashĈlient = env.CreateUnleahClient(unleashClientSettings.Value);
var smtpSettingsconf = Configuration.GetSection("Smtp");
services.Configure<SmtpSettings>(smtpSettingsconf);
var nugetSettingsconf = Configuration.GetSection("Nuget");
services.Configure<NugetSettings>(nugetSettingsconf);
var isndSettingsconf = Configuration.GetSection("Nuget");
services.Configure<IsndSettings>(isndSettingsconf);
var adminStartupListConf = Configuration.GetSection("AdminList");
services.Configure<AdminStartupList>(adminStartupListConf);
var unleashConf = Configuration.GetSection("Unleash");