broken/ef
Paul Schneider 3 years ago
parent 5de53a3cba
commit 476d35ae8a
270 changed files with 477 additions and 401 deletions

16
.gitignore vendored

@ -1,11 +1,9 @@
/packages/
/bin/
/obj/
test/nuget.host.tests/bin/
test/nuget.host.tests/obj
src/appled/bin/
src/appled/obj/
src/applec/obj
src/applec/bin
src/isnd/bin/
src/isnd/obj/
src/isn/obj
src/isn/bin
.vscode/launch.json
src/applec/.vscode/
src/isn/.vscode/
test/isnd.tests/obj/
test/isnd.tests/bin/

@ -22,7 +22,7 @@ publish:
stage: deploy
artifacts:
paths:
- src/appled/bin/Release/netcoreapp2.1/publish/
- src/isnd/bin/Release/netcoreapp2.1/publish/
when: always
script:
- dotnet publish --configuration Release
@ -37,7 +37,7 @@ deploy-to-gitlab:
- dotnet nuget add source --name gitlab --username gitlab+deploy-token-2 --password
$CI_JOB_TOKEN --store-password-in-clear-text "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json"
- dotnet nuget push src/*/bin/Release/*.nupkg -s gitlab
deploy-to-apple:
deploy-to-isn:
stage: deploy
artifacts:
paths:
@ -45,11 +45,11 @@ deploy-to-apple:
when: always
script:
- dotnet pack --configuration Release --no-restore
- cd src/applec
- cd src/isn
- dotnet run push -s $NUGETSOURCE -k $NUGETSOURCEAPIKEY ../*/bin/Release/*.nupkg
environment:
name: production
url: https://apple.pschneider.fr
url: https://isn.pschneider.fr
stages:
- test
- deploy

@ -31,7 +31,7 @@
"command": "msbuild",
"type": "process",
"args": [
"src/applec",
"src/isn",
"/p:Configuration=Debug",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
@ -71,7 +71,7 @@
"command": "dotnet",
"type": "process",
"args": [
"${workspaceFolder}/bin/Debug/netcoreapp2.1/appled.dll"
"${workspaceFolder}/bin/Debug/netcoreapp2.1/isnd.dll"
],
"problemMatcher": "$msCompile"
},
@ -80,7 +80,7 @@
"command": "dotnet",
"type": "process",
"args": [
"bin/Debug/netcoreapp2.1/appled.dll",
"bin/Debug/netcoreapp2.1/isnd.dll",
"/property:GenerateFullPaths=true",
"/restore"
],

@ -4,10 +4,10 @@
dotnet user-secrets set ConnectionStrings:DefaultConnection "Server=<lame-pgserver>;Port=<lame-pgport>;Database=<lame-dbname>;Username=<lame-dbusername>;Password=<lame-dbpass>;"
appled&
isnd&
# get an api-key from <http://localhost:5000/ApkKeys>
applec push -k <lame-api-key> -s http://localhost:5000/packages your-lame-versionned.nupkg
isn push -k <lame-api-key> -s http://localhost:5000/packages your-lame-versionned.nupkg
````

@ -61,7 +61,7 @@ start() {
else
cd $ROOT
log_daemon_msg "Starting service $NAME for user $WWW_USER"
if ! start-stop-daemon -SbmCv -u $WWW_USER -p $PIDFILE -d $ROOT -g www-data -x /usr/bin/dotnet appled.dll run > "${LOGDIR}/kestrel-${NAME}.log"
if ! start-stop-daemon -SbmCv -u $WWW_USER -p $PIDFILE -d $ROOT -g www-data -x /usr/bin/dotnet isnd.dll run > "${LOGDIR}/kestrel-${NAME}.log"
then
log_daemon_msg "Could not start $NAME : $?, see ${LOGDIR}/kestrel-${NAME}.log"
log_end_msg 2

@ -5,13 +5,13 @@ VisualStudioVersion = 16.6.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{3C312E42-9A47-4BED-8265-A405FCA6AFFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nuget.host.tests", "test\nuget.host.tests\nuget.host.tests.csproj", "{9D758F00-17FF-433D-B088-F9C2D97C9BD1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isnd.tests", "test\isnd.tests\isnd.tests.csproj", "{9D758F00-17FF-433D-B088-F9C2D97C9BD1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E8A2DF68-847A-4D88-B002-64FB666F696C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "appled", "src\appled\appled.csproj", "{468DB0E4-6221-4E01-BEFF-F452865E59C1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isnd", "src\isnd\isnd.csproj", "{468DB0E4-6221-4E01-BEFF-F452865E59C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "applec", "src\applec\applec.csproj", "{910E800A-59AE-46C4-B7C7-879986179246}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "isn", "src\isn\isn.csproj", "{910E800A-59AE-46C4-B7C7-879986179246}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

@ -1,7 +0,0 @@
{
"msbuild": {
"Configuration": "Debug",
"CscToolPath": "/usr/bin",
"CscToolExe": "csc"
}
}

@ -1,68 +0,0 @@
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
namespace nuget_cli
{
public class HttpClientServerQueryHandler
{
internal async Task UploadFilesToServerAsync(
PushReport report, Uri uri,
FileInfo fi, string apikey)
{
try
{
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
using (var formdata = new MultipartFormDataContent("NKdKd9Yk"))
{
using (HttpClient client = new HttpClient())
{
var dispo = new ContentDispositionHeaderValue("file")
{
FileName = fi.Name,
CreationDate = fi.CreationTime,
DispositionType = "form-data",
Size = fi.Length,
ModificationDate = fi.LastAccessTime
};
Stream fileStream = fi.OpenRead();
var streamcontent = new StreamContent(fileStream);
streamcontent.Headers.ContentDisposition = dispo;
formdata.Add(streamcontent, "file", fi.Name);
client.BaseAddress = uri;
HttpRequestMessage put = new HttpRequestMessage(HttpMethod.Put, uri)
{
Content = formdata
};
put.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
put.Headers.Add("X-NuGet-ApiKey", apikey);
put.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.SendAsync(put);
response.EnsureSuccessStatusCode();
report.StatusCode = response.StatusCode.ToString();
var respstream = await response.Content.ReadAsStreamAsync();
var sr = new StreamReader(respstream);
report.Message = await sr.ReadToEndAsync();
}
}
}
catch (Exception rex)
{
report.Message = rex.Message;
report.StatusCode = "internal error";
report.OK = false;
Console.Error.WriteLine(rex.Message);
}
}
}
}

@ -1,3 +0,0 @@
@using nuget_host.Data
@using nuget_host.ViewModels
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

File diff suppressed because one or more lines are too long

@ -1,8 +0,0 @@
/*!
* Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]){color:inherit;text-decoration:none}a:not([href]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -2,6 +2,6 @@ namespace nuget_cli
{
internal static class Constants
{
internal const string ClientVersion = "applec v1.0";
internal const string ClientVersion = "isn v1.0";
}
}

@ -107,9 +107,9 @@ namespace nuget_cli
catch (OptionException e)
{
// output some error message
Console.Write("applec: ");
Console.Write("isn: ");
Console.WriteLine(e.Message);
Console.WriteLine("Try `applec --help' for more information.");
Console.WriteLine("Try `isn --help' for more information.");
return 2;
}

Binary file not shown.

@ -9,6 +9,7 @@
<ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.1"/>
<PackageReference Include="unleash.client" Version="1.6.1" />
<Reference Include="System.Net.Http" Version="4.0.0"/>
</ItemGroup>
</Project>

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Authorization;
namespace nuget_host.Authorization
namespace isn.Authorization
{
internal class ValidApiKeyRequirement : IAuthorizationRequirement
{

@ -1,7 +1,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace nuget_host.Authorization
namespace isn.Authorization
{
internal class ValidApiKeyRequirementHandler : AuthorizationHandler<ValidApiKeyRequirement>
{

@ -1,4 +1,4 @@
namespace nuget_host
namespace isn
{
public static class Constants
{

@ -7,14 +7,14 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using nuget_host.Data;
using nuget_host.Data.Roles;
using isn.Data;
using isn.Data.Roles;
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
namespace nuget_host.Controllers
namespace isn.Controllers
{
[AllowAnonymous]
public class AccountController : Controller

@ -10,13 +10,12 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using nuget_host.Data;
using nuget_host.Entities;
using nuget_host.Data;
using nuget_host.Data.ApiKeys;
using isn.Data;
using isn.Entities;
using isn.Data.ApiKeys;
namespace nuget_host.Controllers
namespace isn.Controllers
{
[Authorize]
public class ApiKeysController : Controller

@ -2,12 +2,14 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using nuget_host.Entities;
using nuget_host.Data;
using isn.Entities;
using isn.Data;
using System.Linq;
using nuget_host.ViewModels;
using isn.ViewModels;
using Unleash.ClientFactory;
using Unleash;
namespace nuget_host.Controllers
namespace isn.Controllers
{
public class HomeController : Controller
{
@ -32,7 +34,8 @@ namespace nuget_host.Controllers
public IActionResult Index()
{
return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages.Count()
PkgCount = _dbContext.Packages.Count(),
UnleashClient = Startup.UnleashĈlient
});
}

@ -1,9 +1,9 @@
using System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using nuget_host.Data;
using isn.Data;
namespace nuget_host.Controllers
namespace isn.Controllers
{
public class NewUpdateController : Controller

@ -4,10 +4,10 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using nuget_host.Data;
using nuget_host.ViewModels;
using isn.Data;
using isn.ViewModels;
namespace nuget_host
namespace isn
{
[AllowAnonymous]
public class PackageVersionController : Controller

@ -11,10 +11,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NuGet.Packaging.Core;
using NuGet.Versioning;
using nuget_host.Data;
using nuget_host.Helpers;
using isn.Data;
using isn.Helpers;
namespace nuget_host.Controllers
namespace isn.Controllers
{
public partial class PackagesController
@ -43,7 +43,7 @@ namespace nuget_host.Controllers
{
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
$"nuget_host-{Guid.NewGuid()}.nupkg");
$"isn-{Guid.NewGuid()}.nupkg");
using (FileStream fw = new FileStream(initpath, FileMode.Create))
{
@ -69,6 +69,7 @@ namespace nuget_host.Controllers
var types = reader.GetPackageTypes();
pkgid = reader.GetId();
version = reader.GetVersion();
string pkgidpath = Path.Combine(nugetSettings.PackagesRootDir,
pkgid);
pkgpath = Path.Combine(pkgidpath, version.ToFullString());

@ -8,22 +8,33 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NuGet.Versioning;
using nuget_host.Data;
using nuget_host.Entities;
using isn.Data;
using isn.Entities;
using Unleash.ClientFactory;
using Unleash;
using System.Collections.Generic;
using isnd.Services;
namespace nuget_host.Controllers
namespace isn.Controllers
{
[AllowAnonymous]
public partial class PackagesController : Controller
{
const int maxTake = 100;
const string _pkgRootPrefix = "~/package";
const string defaultSemVer = "2.0.0";
private readonly Resource[] ressources;
private readonly ILogger<PackagesController> logger;
private readonly IDataProtector protector;
private readonly NugetSettings nugetSettings;
ApplicationDbContext dbContext;
private PackageManager packageManager;
public PackagesController(
PackageManager packageManager,
ILoggerFactory loggerFactory,
IDataProtectionProvider provider,
IOptions<NugetSettings> nugetOptions,
@ -33,39 +44,18 @@ namespace nuget_host.Controllers
nugetSettings = nugetOptions.Value;
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
this.dbContext = dbContext;
this.packageManager = packageManager;
ressources = packageManager.GetResources(Startup.UnleashĈlient).ToArray();
}
const string defaultSemVer = "2.0.0";
// dotnet add . package -s http://localhost:5000/packages applec
// packages/FindPackagesById()?id='applec'&semVerLevel=2.0.0
// dotnet add . package -s http://localhost:5000/packages isn
// packages/FindPackagesById()?id='isn'&semVerLevel=2.0.0
// Search
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
private readonly Resource[] ressources = {
new Resource {
id = "package/index.json",
type ="SearchAutocompleteService/3.5.0",
comment = "Auto complete service"
},
new Resource {
id = "package/index.json",
type ="SearchQueryService/3.5.0",
comment = "Search Query service"
},
new Resource {
id = "package",
type ="PackagePublish/2.0.0",
comment = "Package Publish service"
},
new Resource {
id = "package",
type = "PackageBaseAddress/3.0.0",
comment = "Package Base Address service"
}
};
const string _pkgRootPrefix = "~/package";
[HttpGet("~/index.json")]
public IActionResult ApiIndex()
{
@ -92,51 +82,11 @@ namespace nuget_host.Controllers
}
if (ModelState.IsValid)
{
var scope = dbContext.Packages
.Include(p => p.Versions)
.Where(
p => (CamelCaseMatch(p.Id, q) || SeparatedByMinusMatch(p.Id, q))
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease))
&& (packageType == null || p.Versions.Any(v => v.Type == packageType))
);
var result = new
{
totalHits = scope.Count(),
data = scope.OrderBy(p => p.Id)
.Skip(skip).Take(take).ToArray()
};
return Ok(result);
return Ok(packageManager.SearchByName(q,skip,take,prerelease,packageType));
}
return BadRequest(new { error = ModelState });
}
protected static bool CamelCaseMatch(string id, string q)
{
// Assert.False (q==null);
string query = q;
if (query.Length == 0) return false;
while (id.Length > 0)
{
int i = 0;
while (id.Length > i && char.IsLower(id[i])) i++;
if (i == 0) break;
id = id.Substring(i);
if (id.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
protected static bool SeparatedByMinusMatch(string id, string q)
{
foreach (var part in id.Split('-'))
{
if (part.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
const int maxTake = 100;
// GET /autocomplete?id=nuget.protocol&prerelease=true
[HttpGet(_pkgRootPrefix + "/autocomplete")]
public IActionResult AutoComplete(
@ -152,18 +102,8 @@ namespace nuget_host.Controllers
ModelState.AddModelError("take", "Maximum exceeded");
return BadRequest(ModelState);
}
var scope = dbContext.PackageVersions.Where(
v => v.PackageId == id
&& (prerelease || !v.IsPrerelease)
&& (packageType == null || v.Type == packageType)
)
.OrderBy(v => v.FullString);
return Ok(new
{
data = scope.Select(v => v.FullString)
.Skip(skip).Take(take).ToArray(),
totalHits = scope.Count()
});
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
}
// TODO GET {@id}/{LOWER_ID}/index.json
// LOWER_ID URL string yes The package ID, lowercased
@ -192,18 +132,8 @@ namespace nuget_host.Controllers
}
return Ok(new
{
// TODO stocker MetaData plutôt que FullString en base,
// et en profiter pour corriger ce listing
versions =
dbContext.PackageVersions.Where(
v => v.PackageId == id
&& (prerelease || !v.IsPrerelease)
&& (packageType == null || v.Type == packageType)
&& (parsedVersion.CompareTo(new SemanticVersion(v.Major, v.Minor, v.Patch)) < 0)
)
.OrderBy(v => v.FullString)
.Select(v => v.FullString)
.Skip(skip).Take(take).ToArray()
versions = packageManager.GetVersions(
id, parsedVersion, prerelease, packageType, skip, take)
});
}

@ -1,4 +1,4 @@
namespace nuget_host.Controllers
namespace isn.Controllers
{
internal class Resource
{

@ -2,7 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace nuget_host.Controllers
namespace isn.Controllers
{
internal class SafeNameAttribute : ValidationAttribute
{

@ -4,7 +4,7 @@
using System;
namespace nuget_host.Data
namespace isn.Data
{
public class AccountOptions
{

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
namespace nuget_host.Data
namespace isn.Data
{
public class ExternalProvider
{

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
namespace nuget_host.Data
namespace isn.Data
{
public class LoggedOutViewModel
{

@ -4,7 +4,7 @@
using System.ComponentModel.DataAnnotations;
namespace nuget_host.Data
namespace isn.Data
{
public class LoginInputModel
{

@ -6,7 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace nuget_host.Data
namespace isn.Data
{
public class LoginViewModel : LoginInputModel
{

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
namespace nuget_host.Data
namespace isn.Data
{
public class LogoutInputModel
{

@ -2,7 +2,7 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
namespace nuget_host.Data
namespace isn.Data
{
public class LogoutViewModel : LogoutInputModel
{

@ -3,7 +3,7 @@
namespace nuget_host.Data
namespace isn.Data
{
public class RedirectViewModel
{

@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace nuget_host.Data
namespace isn.Data
{
public class RegisterViewModel
{

@ -2,7 +2,7 @@ using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class ApiKey
{

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class ApiKeyViewModel
{

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class CreateModel
{

@ -1,4 +1,4 @@
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class DeleteModel
{

@ -1,4 +1,4 @@
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class DetailModel : ApiKeyViewModel
{

@ -1,4 +1,4 @@
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class EditModel
{

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace nuget_host.Data.ApiKeys
namespace isn.Data.ApiKeys
{
public class IndexModel
{

@ -4,10 +4,10 @@ using System.Text;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using nuget_host.Data;
using nuget_host.Data.ApiKeys;
using isn.Data;
using isn.Data.ApiKeys;
namespace nuget_host.Data
namespace isn.Data
{
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Identity;
namespace nuget_host.Data
namespace isn.Data
{
// Add profile data for application users by adding properties to the ApplicationUser class
public class ApplicationUser : IdentityUser

@ -1,6 +1,6 @@
using System;
namespace nuget_host.Data
namespace isn.Data
{
public class NewReleaseInfo
{

@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace nuget_host.Data
namespace isn.Data
{
public class Package
{

@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
namespace nuget_host.Data
namespace isn.Data
{
public class PackageVersion
{

@ -1,4 +1,4 @@
namespace nuget_host.Data.Roles
namespace isn.Data.Roles
{
public class AdminStartupList
{

@ -1,4 +1,4 @@
namespace nuget_host.Entities
namespace isn.Entities
{
public class NugetSettings
{

@ -1,4 +1,4 @@
namespace nuget_host.Entities
namespace isn.Entities
{
public class SmtpSettings
{

@ -0,0 +1,8 @@
namespace isnd.Entities
{
public class UnleashClientSettings
{
public string ClientApiKey { get; set; }
public string ApiUrl { get; set; }
}
}

@ -1,7 +1,7 @@
using System;
using Microsoft.AspNetCore.Mvc;
namespace nuget_host.Data
namespace isn.Data
{
public static class Extensions
{

@ -2,7 +2,7 @@ using System.Linq;
using System.Xml.Linq;
using NuGet.Packaging.Core;
namespace nuget_host.Helpers
namespace isn.Helpers
{
public static class NuspecCoreReaderHelpers
{

@ -1,7 +1,7 @@
using System.Threading.Tasks;
namespace nuget_host.Interfaces
namespace isn.Interfaces
{
public interface IMailer
{

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -190,7 +190,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -198,7 +198,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -211,7 +211,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -219,7 +219,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -143,7 +143,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -205,7 +205,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -213,7 +213,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -226,7 +226,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -234,15 +234,15 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -149,7 +149,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -211,7 +211,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -219,7 +219,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -232,7 +232,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -240,15 +240,15 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -149,7 +149,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -201,7 +201,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -218,7 +218,7 @@ namespace nugethost.Migrations
b.ToTable("Packages");
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("FullString")
.ValueGeneratedOnAdd()
@ -252,7 +252,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -260,7 +260,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -273,7 +273,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -281,31 +281,31 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "Owner")
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("nuget_host.Data.Package", "Package")
b.HasOne("isn.Data.Package", "Package")
.WithMany()
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -149,7 +149,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -201,7 +201,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -218,7 +218,7 @@ namespace nugethost.Migrations
b.ToTable("Packages");
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
@ -248,7 +248,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -256,7 +256,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -269,7 +269,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -277,31 +277,31 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "Owner")
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("nuget_host.Data.Package", "Package")
b.HasOne("isn.Data.Package", "Package")
.WithMany()
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -128,7 +128,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -149,7 +149,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -201,7 +201,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -219,7 +219,7 @@ namespace nugethost.Migrations
b.ToTable("Packages");
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
@ -252,7 +252,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -260,7 +260,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -273,7 +273,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -281,31 +281,31 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "Owner")
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("nuget_host.Data.Package", "Package")
b.HasOne("isn.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using nuget_host.Data;
using isn.Data;
namespace nugethost.Migrations
{
@ -126,7 +126,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -147,7 +147,7 @@ namespace nugethost.Migrations
b.ToTable("ApiKeys");
});
modelBuilder.Entity("nuget_host.Data.ApplicationUser", b =>
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -199,7 +199,7 @@ namespace nugethost.Migrations
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
@ -217,7 +217,7 @@ namespace nugethost.Migrations
b.ToTable("Packages");
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
@ -250,7 +250,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -258,7 +258,7 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -271,7 +271,7 @@ namespace nugethost.Migrations
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
@ -279,31 +279,31 @@ namespace nugethost.Migrations
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser")
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.ApiKeys.ApiKey", b =>
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "User")
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.Package", b =>
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("nuget_host.Data.ApplicationUser", "Owner")
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("nuget_host.Data.PackageVersion", b =>
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("nuget_host.Data.Package", "Package")
b.HasOne("isn.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);

@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace nuget_host
namespace isn
{
public class Program
{

@ -8,10 +8,10 @@ using MailKit.Net.Smtp;
using MimeKit;
using System;
using nuget_host.Interfaces;
using nuget_host.Entities;
using isn.Interfaces;
using isn.Entities;
namespace nuget_host.Services
namespace isn.Services
{
public class EmailSender : IEmailSender, IMailer
{

@ -0,0 +1,140 @@
using System.Collections.Generic;
using System.Linq;
using isn.Controllers;
using isn.Data;
using Microsoft.EntityFrameworkCore;
using NuGet.Versioning;
using Unleash;
namespace isnd.Services
{
public class PackageManager
{
ApplicationDbContext dbContext;
public PackageManager(ApplicationDbContext dbContext)
{
this.dbContext = dbContext;
}
public IndexResult SearchByName(string query,
int skip, int take,bool prerelease = false,
string packageType = null)
{
var scope = dbContext.Packages
.Include(p => p.Versions)
.Where(
p => (CamelCaseMatch(p.Id, query) || SeparatedByMinusMatch(p.Id, query))
&& (prerelease || p.Versions.Any(v => !v.IsPrerelease))
&& (packageType == null || p.Versions.Any(v => v.Type == packageType))
);
return new IndexResult
{
totalHits = scope.Count(),
data = scope.OrderBy(p => p.Id)
.Skip(skip).Take(take).ToArray()
};
}
public AutoCompleteResult AutoComplete (string id,
int skip, int take, bool prerelease = false,
string packageType = null)
{
var scope = dbContext.PackageVersions.Where(
v => v.PackageId == id
&& (prerelease || !v.IsPrerelease)
&& (packageType == null || v.Type == packageType)
)
.OrderBy(v => v.FullString);
return new AutoCompleteResult
{
totalHits = scope.Count(),
data = scope.Select(v => v.FullString)
.Skip(skip).Take(take).ToArray()
};
}
// TODO stocker MetaData plutôt que FullString en base,
// et en profiter pour corriger ce listing
public string[] GetVersions(
string id,
NuGetVersion parsedVersion,
bool prerelease = false,
string packageType = null,
int skip = 0,
int take = 25)
{
return dbContext.PackageVersions.Where(
v => v.PackageId == id
&& (prerelease || !v.IsPrerelease)
&& (packageType == null || v.Type == packageType)
&& (parsedVersion.CompareTo(new SemanticVersion(v.Major, v.Minor, v.Patch)) < 0)
)
.OrderBy(v => v.FullString)
.Select(v => v.FullString)
.Skip(skip).Take(take).ToArray();
}
protected static bool CamelCaseMatch(string id, string q)
{
// Assert.False (q==null);
string query = q;
if (query.Length == 0) return false;
while (id.Length > 0)
{
int i = 0;
while (id.Length > i && char.IsLower(id[i])) i++;
if (i == 0) break;
id = id.Substring(i);
if (id.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
protected static bool SeparatedByMinusMatch(string id, string q)
{
foreach (var part in id.Split('-'))
{
if (part.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
internal List<Resource> GetResources(IUnleash unleashClient)
{
var res = new List<Resource>();
if (unleashClient.IsEnabled("pkg-push"))
res.Add(
new Resource
{
id = "package",
type = "PackagePublish/2.0.0",
comment = "Package Publish service"
});
if (unleashClient.IsEnabled("pkg-get"))
res.Add(
new Resource
{
id = "package",
type = "PackageBaseAddress/3.0.0",
comment = "Package Base Address service"
});
if (unleashClient.IsEnabled("pkg-autocomplete"))
res.Add(
new Resource
{
id = "package/index.json",
type = "SearchAutocompleteService/3.5.0",
comment = "Auto complete service"
});
if (unleashClient.IsEnabled("pkg-search"))
res.Add(
new Resource
{
id = "package/index.json",
type = "SearchQueryService/3.5.0",
comment = "Search Query service"
});
return res;
}
}
}

@ -0,0 +1,16 @@
using isn.Data;
namespace isnd.Services
{
public class IndexResult
{
public int totalHits { get; set; }
public Package[] data { get; set; }
}
public class AutoCompleteResult
{
public int totalHits { get; set; }
public string[] data { get; set; }
}
}

@ -6,21 +6,28 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.UI.Services;
using Microsoft.Extensions.Hosting;
using nuget_host.Data;
using nuget_host.Interfaces;
using nuget_host.Services;
using nuget_host.Entities;
using nuget_host.Authorization;
using nuget_host.Data.Roles;
using isn.Data;
using isn.Interfaces;
using isn.Services;
using isn.Entities;
using isn.Authorization;
using isn.Data.Roles;
using Microsoft.AspNetCore.Authorization;
namespace nuget_host
using Unleash;
using System.Collections.Generic;
using System;
using Unleash.ClientFactory;
using isnd.Entities;
using Microsoft.Extensions.Options;
namespace isn
{
public class Startup
{
public Startup(IConfiguration config)
{
Configuration = config;
}
public IConfiguration Configuration { get; }
@ -64,11 +71,19 @@ namespace nuget_host
services.Configure<NugetSettings>(nugetSettingsconf);
var adminStartupListConf = Configuration.GetSection("AdminList");
services.Configure<AdminStartupList>(adminStartupListConf);
var unleashConf = Configuration.GetSection("Unleash");
services.Configure<UnleashClientSettings>(unleashConf);
services.Configure<MigrationsEndPointOptions>(o => o.Path = "~/migrate");
}
public static IUnleash UnleashĈlient { get; private set; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
public void Configure(IApplicationBuilder app,
Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
IOptions<UnleashClientSettings> unleashClientSettings,
ApplicationDbContext dbContext)
{
if (env.IsDevelopment())
@ -83,13 +98,20 @@ namespace nuget_host
dbContext.Database.Migrate();
}
app.UseStatusCodePages();
app.UseStaticFiles();
app.UseAuthentication();
var unleashSettings = new UnleashSettings
{
UnleashApi = new Uri(unleashClientSettings.Value.ApiUrl),
AppName = "isnd",
Environment = env.EnvironmentName,
CustomHttpHeaders = new Dictionary<string, string>
{
{ "Authorization", unleashClientSettings.Value.ClientApiKey }
}
};
UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
UnleashĈlient = unleashClientFactory.CreateClient(unleashSettings);
app.UseMvc(routes =>
app.UseStatusCodePages().UseStaticFiles().UseAuthentication().UseMvc(routes =>
{
routes.MapRoute(
name: "default",

@ -1,7 +1,11 @@
namespace nuget_host.ViewModels
using Unleash;
namespace isn.ViewModels
{
public class HomeIndexViewModel
{
public int PkgCount { get; set; }
public IUnleash UnleashClient;
}
}

@ -1,7 +1,7 @@
using System.Collections.Generic;
using nuget_host.Data;
using isn.Data;
namespace nuget_host.ViewModels
namespace isn.ViewModels
{
public class PackageVersionIndexViewModel
{

@ -1,5 +1,5 @@
@model nuget_host.Data.ApiKeys.CreateModel
@model isn.Data.ApiKeys.CreateModel
@{
ViewData["Title"] = "Create";

@ -1,5 +1,5 @@
@model nuget_host.Data.ApiKeys.DeleteModel
@model isn.Data.ApiKeys.DeleteModel
@{
ViewData["Title"] = "Delete";

@ -1,5 +1,5 @@
@model nuget_host.Data.ApiKeys.DetailModel
@model isn.Data.ApiKeys.DetailModel
@{
ViewData["Title"] = "Details";

@ -1,5 +1,5 @@
@model nuget_host.Data.ApiKeys.EditModel
@model isn.Data.ApiKeys.EditModel
@{
ViewData["Title"] = "Edit";

@ -1,5 +1,5 @@
@model nuget_host.Data.ApiKeys.IndexModel
@model isn.Data.ApiKeys.IndexModel
@{
ViewData["Title"] = "Index";

@ -1,13 +1,27 @@
@model HomeIndexViewModel
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<h1>
<img src="~/icon.jpg">
Welcome to Apple
Welcome to isn
</h1>
<strong>@Model.PkgCount identifiant(s) de paquet dans le SI</strong>
@{
if (Model.UnleashClient.IsEnabled("Demo"))
{
//do some magic
<p>Demo</p>
}
else
{
//do old boring stuff
<p>No demo (disabled)</p>
}
}
</div>

@ -1,4 +1,4 @@
@model nuget_host.Data.PackageVersion
@model isn.Data.PackageVersion
@{
ViewData["Title"] = "Delete";

@ -1,4 +1,4 @@
@model nuget_host.Data.PackageVersion
@model isn.Data.PackageVersion
@{
ViewData["Title"] = "Details";

Some files were not shown because too many files have changed in this diff Show More

Loading…