diff --git a/src/isn/isn.csproj b/src/isn/isn.csproj index 89e48d6..110a1bc 100644 --- a/src/isn/isn.csproj +++ b/src/isn/isn.csproj @@ -2,7 +2,6 @@ Exe netcoreapp2.1 - linux-x64 nuget_cli 45b74c62-05bc-4603-95b4-3e80ae2fdf50 1.0.5 @@ -19,7 +18,6 @@ - diff --git a/src/isnd/Migrations/20220926205013_revision.Designer.cs b/src/isnd/Migrations/20220926205013_revision.Designer.cs new file mode 100644 index 0000000..04c9ea2 --- /dev/null +++ b/src/isnd/Migrations/20220926205013_revision.Designer.cs @@ -0,0 +1,358 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using isnd.Data; + +namespace isndhost.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20220926205013_revision")] + partial class revision + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.1.14-servicing-32113") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CreationDate"); + + b.Property("Name"); + + b.Property("UserId") + .IsRequired(); + + b.Property("ValidityPeriodInDays"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("ApiKeys"); + }); + + modelBuilder.Entity("isnd.Data.ApplicationUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AccessFailedCount"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Email") + .HasMaxLength(256); + + b.Property("EmailConfirmed"); + + b.Property("FullName"); + + b.Property("LockoutEnabled"); + + b.Property("LockoutEnd"); + + b.Property("NormalizedEmail") + .HasMaxLength(256); + + b.Property("NormalizedUserName") + .HasMaxLength(256); + + b.Property("PasswordHash"); + + b.Property("PhoneNumber"); + + b.Property("PhoneNumberConfirmed"); + + b.Property("SecurityStamp"); + + b.Property("TwoFactorEnabled"); + + b.Property("UserName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasName("UserNameIndex"); + + b.ToTable("AspNetUsers"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Commit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Action"); + + b.Property("TimeStamp"); + + b.HasKey("Id"); + + b.ToTable("Commits"); + }); + + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(1024); + + b.Property("CommitNId"); + + b.Property("CommitTimeStamp"); + + b.Property("Description") + .HasMaxLength(1024); + + b.Property("OwnerId") + .IsRequired(); + + b.Property("Public"); + + b.HasKey("Id"); + + b.HasIndex("CommitNId"); + + b.HasIndex("OwnerId"); + + b.ToTable("Packages"); + }); + + modelBuilder.Entity("isnd.Data.PackageVersion", b => + { + b.Property("FullString") + .ValueGeneratedOnAdd() + .HasMaxLength(256); + + b.Property("CommitNId"); + + b.Property("IsPrerelease"); + + b.Property("Major"); + + b.Property("Minor"); + + b.Property("PackageId") + .IsRequired() + .HasMaxLength(1024); + + b.Property("Patch"); + + b.Property("Type") + .HasMaxLength(256); + + b.HasKey("FullString"); + + b.HasIndex("CommitNId"); + + b.HasIndex("PackageId"); + + b.ToTable("PackageVersions"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken(); + + b.Property("Name") + .HasMaxLength(256); + + b.Property("NormalizedName") + .HasMaxLength(256); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasName("RoleNameIndex"); + + b.ToTable("AspNetRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("RoleId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClaimType"); + + b.Property("ClaimValue"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider"); + + b.Property("ProviderKey"); + + b.Property("ProviderDisplayName"); + + b.Property("UserId") + .IsRequired(); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId"); + + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId"); + + b.Property("LoginProvider"); + + b.Property("Name"); + + b.Property("Value"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens"); + }); + + modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => + { + b.HasOne("isnd.Data.ApplicationUser", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("isnd.Data.Packages.Package", b => + { + b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") + .WithMany() + .HasForeignKey("CommitNId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("isnd.Data.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("isnd.Data.PackageVersion", b => + { + b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") + .WithMany("Versions") + .HasForeignKey("CommitNId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("isnd.Data.Packages.Package", "Package") + .WithMany("Versions") + .HasForeignKey("PackageId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("isnd.Data.ApplicationUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("isnd.Data.ApplicationUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("isnd.Data.ApplicationUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("isnd.Data.ApplicationUser") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/isnd/Migrations/20220926205013_revision.cs b/src/isnd/Migrations/20220926205013_revision.cs new file mode 100644 index 0000000..9682408 --- /dev/null +++ b/src/isnd/Migrations/20220926205013_revision.cs @@ -0,0 +1,17 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace isndhost.Migrations +{ + public partial class revision : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs index 663adfa..9640b93 100644 --- a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs @@ -92,7 +92,7 @@ namespace isndhost.Migrations b.ToTable("AspNetUsers"); }); - modelBuilder.Entity("isnd.Data.Catalog.Commit", b => + modelBuilder.Entity("isnd.Data.Packages.Commit", b => { b.Property("Id") .ValueGeneratedOnAdd(); @@ -106,7 +106,7 @@ namespace isndhost.Migrations b.ToTable("Commits"); }); - modelBuilder.Entity("isnd.Data.Package", b => + modelBuilder.Entity("isnd.Data.Packages.Package", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -280,9 +280,9 @@ namespace isndhost.Migrations .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("isnd.Data.Package", b => + modelBuilder.Entity("isnd.Data.Packages.Package", b => { - b.HasOne("isnd.Data.Catalog.Commit", "LatestVersion") + b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") .WithMany() .HasForeignKey("CommitNId") .OnDelete(DeleteBehavior.Cascade); @@ -295,12 +295,12 @@ namespace isndhost.Migrations modelBuilder.Entity("isnd.Data.PackageVersion", b => { - b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit") + b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") .WithMany("Versions") .HasForeignKey("CommitNId") .OnDelete(DeleteBehavior.Cascade); - b.HasOne("isnd.Data.Package", "Package") + b.HasOne("isnd.Data.Packages.Package", "Package") .WithMany("Versions") .HasForeignKey("PackageId") .OnDelete(DeleteBehavior.Cascade); diff --git a/src/isnd/Program.cs b/src/isnd/Program.cs index d9f5f74..9b0ba1d 100644 --- a/src/isnd/Program.cs +++ b/src/isnd/Program.cs @@ -14,13 +14,12 @@ namespace isnd { public static void Main(string[] args) { - var builder = CreateBuilder(args); - builder.Build().Run(); + BuildWebHost(args).Run(); } - public static IWebHostBuilder CreateBuilder(string[] args) => + public static IWebHost BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup() - ; + .Build(); } } diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 7a4189c..b583243 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -1,8 +1,11 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; +using Microsoft.Extensions.Hosting; using isnd.Data; using isnd.Interfaces; using isnd.Services; @@ -14,8 +17,6 @@ using Unleash; using Microsoft.Extensions.Options; using isnd.Helpers; using Microsoft.IdentityModel.Tokens; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; namespace isnd { @@ -50,13 +51,7 @@ namespace isnd .AddSignInManager() .AddDefaultUI() .AddDefaultTokenProviders(); -/* - services.Configure(options => - { - options.ForwardedHeaders = - ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; - }); -*/ + services.AddMvc(); services.AddDataProtection(); @@ -83,17 +78,20 @@ namespace isnd throw new System.Exception("No unleash client ApiUrl"); if (config.Value.ClientApiKey==null) throw new System.Exception("No unleash client ClientApiKey"); - return s.GetRequiredService().CreateUnleahClient(config.Value); + return s.GetRequiredService().CreateUnleahClient(config.Value); }); services.AddAuthentication("Bearer") .AddJwtBearer("Bearer", options => { + options.Authority = "https://localhost:5001"; + options.TokenValidationParameters = new TokenValidationParameters { ValidateAudience = false }; }); + } @@ -103,30 +101,23 @@ namespace isnd // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, - IHostingEnvironment env, + Microsoft.AspNetCore.Hosting.IHostingEnvironment env, ApplicationDbContext dbContext) { - // app.UseForwardedHeaders(); - // app.UseDeveloperExceptionPage(); - // app.UseHttpsRedirection(); - if (env.IsDevelopment()) { - app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); - } else { app.UseExceptionHandler("/Home/Error"); + app.UseHsts(); dbContext.Database.Migrate(); } - - _ = app - .UseStaticFiles() - .UseAuthentication() - .UseMvc(routes => + + // app.UseHttpsRedirection(); + app.UseStatusCodePages().UseStaticFiles().UseAuthentication().UseMvc(routes => { routes.MapRoute( name: "default",