diff --git a/README.md b/README.md index 098b9c3..f05599c 100644 --- a/README.md +++ b/README.md @@ -73,5 +73,5 @@ sudo cp -a src/isnd/bin/Release/net10.0/publish/* /srv/www/isnd sudo systemctl start isnd # MAJ du client sudo cp -a src/isn/bin/Release/net10.0/* /usr/local/lib/isn -sudo chown -R root:root /usr/local/lib/isn +sudo chown -R root.root /usr/local/lib/isn ```` diff --git a/src/isnd/Controllers/AccountController.cs b/src/isnd/Controllers/AccountController.cs index 9774f30..e367166 100644 --- a/src/isnd/Controllers/AccountController.cs +++ b/src/isnd/Controllers/AccountController.cs @@ -29,22 +29,14 @@ namespace isnd.Controllers IAuthenticationSchemeProvider schemeProvider, SignInManager signInManager, UserManager userManager, - IOptions startupAdminListConfig, - RoleManager roleManager - ) + IOptions startupAdminListConfig ) { _schemeProvider = schemeProvider; _signInManager = signInManager; _userManager = userManager; _startupAdminList = startupAdminListConfig.Value; - var roles = roleManager.Roles.ToList(); - if (!roles.Any(r => r.Name == IsndConstants.AdministratorRoleName)) - { - var role = new IdentityRole(IsndConstants.AdministratorRoleName); - roleManager.CreateAsync(role).GetAwaiter().GetResult(); - } } - + /// /// Entry point into the login workflow /// @@ -248,10 +240,10 @@ namespace isnd.Controllers [Authorize] public async Task GetAdminrole() { - string userEmail = User.FindFirstValue(ClaimTypes.Email); - if (_startupAdminList.Users.Contains(userEmail)) + string username = User.FindFirstValue(ClaimTypes.NameIdentifier); + if (_startupAdminList.Users.Contains(username)) { - var user = await _userManager.FindByEmailAsync(userEmail); + var user = await _userManager.FindByNameAsync(username); var roles = await _userManager.GetRolesAsync(user); if (!roles.Contains(IsndConstants.AdministratorRoleName)) { diff --git a/src/isnd/Entities/SmtpSettings.cs b/src/isnd/Entities/SmtpSettings.cs index 3d2ae1d..5a4a861 100644 --- a/src/isnd/Entities/SmtpSettings.cs +++ b/src/isnd/Entities/SmtpSettings.cs @@ -2,30 +2,11 @@ namespace isnd.Entities { public class SmtpSettings { - /** - * The SMTP server host. - */ - public string Host {get; set;} - - /** - * The SMTP server port. - */ + public string Server {get; set;} public int Port {get; set;} - /** - * The name of the sender. - */ public string SenderName {get; set;} - /** - * The email address of the sender. - */ - public string SenderEmail {get; set;} - /** - * The username for SMTP authentication. - */ + public string SenderEMail {get; set;} public string UserName {get; set;} - /** - * The password for SMTP authentication. - */ public string Password {get; set;} } } \ No newline at end of file diff --git a/src/isnd/Migrations/20260705174847_net10.Designer.cs b/src/isnd/Migrations/20260705174847_net10.Designer.cs deleted file mode 100644 index 75e320c..0000000 --- a/src/isnd/Migrations/20260705174847_net10.Designer.cs +++ /dev/null @@ -1,458 +0,0 @@ -// -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; - -#nullable disable - -namespace isndhost.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20260705174847_net10")] - partial class net10 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "10.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - - modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.Property("ValidityPeriodInDays") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("ApiKeys"); - }); - - modelBuilder.Entity("isnd.Data.ApplicationUser", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("AccessFailedCount") - .HasColumnType("integer"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("boolean"); - - b.Property("FullName") - .HasColumnType("text"); - - b.Property("LockoutEnabled") - .HasColumnType("boolean"); - - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("PhoneNumber") - .HasColumnType("text"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); - - b.Property("SecurityStamp") - .HasColumnType("text"); - - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex"); - - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("isnd.Data.PackageVersion", b => - { - b.Property("FullString") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("CommitNId") - .HasColumnType("bigint"); - - b.Property("IsPrerelease") - .HasColumnType("boolean"); - - b.Property("Major") - .HasColumnType("integer"); - - b.Property("Minor") - .HasColumnType("integer"); - - b.Property("PackageId") - .IsRequired() - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); - - b.Property("Patch") - .HasColumnType("integer"); - - b.Property("Revision") - .HasColumnType("integer"); - - b.Property("Type") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("FullString"); - - b.HasIndex("CommitNId"); - - b.HasIndex("PackageId"); - - b.ToTable("PackageVersions"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Commit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("TimeStamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.ToTable("Commits"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Package", b => - { - b.Property("Id") - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); - - b.Property("CommitNId") - .HasColumnType("bigint"); - - b.Property("CommitTimeStamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Description") - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); - - b.Property("OwnerId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Public") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("CommitNId"); - - b.HasIndex("OwnerId"); - - b.ToTable("Packages"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => - { - b.HasOne("isnd.Data.ApplicationUser", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("isnd.Data.PackageVersion", b => - { - b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") - .WithMany("Versions") - .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("isnd.Data.Packages.Package", "Package") - .WithMany("Versions") - .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("LatestCommit"); - - b.Navigation("Package"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Package", b => - { - b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") - .WithMany() - .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("isnd.Data.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("LatestVersion"); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Commit", b => - { - b.Navigation("Versions"); - }); - - modelBuilder.Entity("isnd.Data.Packages.Package", b => - { - b.Navigation("Versions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/isnd/Migrations/20260705174847_net10.cs b/src/isnd/Migrations/20260705174847_net10.cs deleted file mode 100644 index 56789db..0000000 --- a/src/isnd/Migrations/20260705174847_net10.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace isndhost.Migrations -{ - /// - public partial class net10 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - table: "Commits", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); - - migrationBuilder.AlterColumn( - name: "Id", - table: "AspNetUserClaims", - type: "integer", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); - - migrationBuilder.AlterColumn( - name: "Id", - table: "AspNetRoleClaims", - type: "integer", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - table: "Commits", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - table: "AspNetUserClaims", - type: "integer", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - table: "AspNetRoleClaims", - type: "integer", - nullable: false, - oldClrType: typeof(int), - oldType: "integer") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - } - } -} diff --git a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs index 1dba50c..7d8c883 100644 --- a/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/isnd/Migrations/ApplicationDbContextModelSnapshot.cs @@ -6,8 +6,6 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using isnd.Data; -#nullable disable - namespace isndhost.Migrations { [DbContext(typeof(ApplicationDbContext))] @@ -17,161 +15,23 @@ namespace isndhost.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "10.0.9") + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.1.14-servicing-32113") .HasAnnotation("Relational:MaxIdentifierLength", 63); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => - { - b.Property("Id") - .HasColumnType("text"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); - - b.Property("Name") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("NormalizedName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("AspNetRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("RoleId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetRoleClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("text"); - - b.Property("ClaimValue") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserClaims", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("ProviderKey") - .HasColumnType("text"); - - b.Property("ProviderDisplayName") - .HasColumnType("text"); - - b.Property("UserId") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("AspNetUserLogins", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("RoleId") - .HasColumnType("text"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("AspNetUserRoles", (string)null); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => - { - b.Property("UserId") - .HasColumnType("text"); - - b.Property("LoginProvider") - .HasColumnType("text"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Value") - .HasColumnType("text"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("AspNetUserTokens", (string)null); - }); - modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b => { b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); + .ValueGeneratedOnAdd(); - b.Property("CreationDate") - .HasColumnType("timestamp with time zone"); + b.Property("CreationDate"); - b.Property("Name") - .HasColumnType("text"); + b.Property("Name"); b.Property("UserId") - .IsRequired() - .HasColumnType("text"); + .IsRequired(); - b.Property("ValidityPeriodInDays") - .HasColumnType("integer"); + b.Property("ValidityPeriodInDays"); b.HasKey("Id"); @@ -183,125 +43,63 @@ namespace isndhost.Migrations modelBuilder.Entity("isnd.Data.ApplicationUser", b => { b.Property("Id") - .HasColumnType("text"); + .ValueGeneratedOnAdd(); - b.Property("AccessFailedCount") - .HasColumnType("integer"); + b.Property("AccessFailedCount"); b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("text"); + .IsConcurrencyToken(); b.Property("Email") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasMaxLength(256); - b.Property("EmailConfirmed") - .HasColumnType("boolean"); + b.Property("EmailConfirmed"); - b.Property("FullName") - .HasColumnType("text"); + b.Property("FullName"); - b.Property("LockoutEnabled") - .HasColumnType("boolean"); + b.Property("LockoutEnabled"); - b.Property("LockoutEnd") - .HasColumnType("timestamp with time zone"); + b.Property("LockoutEnd"); b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasMaxLength(256); b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasMaxLength(256); - b.Property("PasswordHash") - .HasColumnType("text"); + b.Property("PasswordHash"); - b.Property("PhoneNumber") - .HasColumnType("text"); + b.Property("PhoneNumber"); - b.Property("PhoneNumberConfirmed") - .HasColumnType("boolean"); + b.Property("PhoneNumberConfirmed"); - b.Property("SecurityStamp") - .HasColumnType("text"); + b.Property("SecurityStamp"); - b.Property("TwoFactorEnabled") - .HasColumnType("boolean"); + b.Property("TwoFactorEnabled"); b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); + .HasMaxLength(256); b.HasKey("Id"); b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); + .HasName("EmailIndex"); b.HasIndex("NormalizedUserName") .IsUnique() - .HasDatabaseName("UserNameIndex"); + .HasName("UserNameIndex"); - b.ToTable("AspNetUsers", (string)null); - }); - - modelBuilder.Entity("isnd.Data.PackageVersion", b => - { - b.Property("FullString") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.Property("CommitNId") - .HasColumnType("bigint"); - - b.Property("IsPrerelease") - .HasColumnType("boolean"); - - b.Property("Major") - .HasColumnType("integer"); - - b.Property("Minor") - .HasColumnType("integer"); - - b.Property("PackageId") - .IsRequired() - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); - - b.Property("Patch") - .HasColumnType("integer"); - - b.Property("Revision") - .HasColumnType("integer"); - - b.Property("Type") - .HasMaxLength(256) - .HasColumnType("character varying(256)"); - - b.HasKey("FullString"); - - b.HasIndex("CommitNId"); - - b.HasIndex("PackageId"); - - b.ToTable("PackageVersions"); + b.ToTable("AspNetUsers"); }); modelBuilder.Entity("isnd.Data.Packages.Commit", b => { b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); + .ValueGeneratedOnAdd(); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Action"); - b.Property("Action") - .HasColumnType("integer"); - - b.Property("TimeStamp") - .HasColumnType("timestamp with time zone"); + b.Property("TimeStamp"); b.HasKey("Id"); @@ -311,25 +109,20 @@ namespace isndhost.Migrations modelBuilder.Entity("isnd.Data.Packages.Package", b => { b.Property("Id") - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); + .ValueGeneratedOnAdd() + .HasMaxLength(1024); - b.Property("CommitNId") - .HasColumnType("bigint"); + b.Property("CommitNId"); - b.Property("CommitTimeStamp") - .HasColumnType("timestamp with time zone"); + b.Property("CommitTimeStamp"); b.Property("Description") - .HasMaxLength(1024) - .HasColumnType("character varying(1024)"); + .HasMaxLength(1024); b.Property("OwnerId") - .IsRequired() - .HasColumnType("text"); + .IsRequired(); - b.Property("Public") - .HasColumnType("boolean"); + b.Property("Public"); b.HasKey("Id"); @@ -340,55 +133,145 @@ namespace isndhost.Migrations 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("Revision"); + + 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.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) + 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.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) + 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.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) + 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.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) - .WithMany() - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.Property("UserId"); - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.Property("RoleId"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles"); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.HasOne("isnd.Data.ApplicationUser", null) - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + 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 => @@ -396,29 +279,7 @@ namespace isndhost.Migrations b.HasOne("isnd.Data.ApplicationUser", "User") .WithMany() .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("isnd.Data.PackageVersion", b => - { - b.HasOne("isnd.Data.Packages.Commit", "LatestCommit") - .WithMany("Versions") - .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("isnd.Data.Packages.Package", "Package") - .WithMany("Versions") - .HasForeignKey("PackageId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("LatestCommit"); - - b.Navigation("Package"); + .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("isnd.Data.Packages.Package", b => @@ -426,28 +287,70 @@ namespace isndhost.Migrations b.HasOne("isnd.Data.Packages.Commit", "LatestVersion") .WithMany() .HasForeignKey("CommitNId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .OnDelete(DeleteBehavior.Cascade); b.HasOne("isnd.Data.ApplicationUser", "Owner") .WithMany() .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("LatestVersion"); - - b.Navigation("Owner"); + .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("isnd.Data.Packages.Commit", b => + modelBuilder.Entity("isnd.Data.PackageVersion", b => { - b.Navigation("Versions"); + 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("isnd.Data.Packages.Package", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { - b.Navigation("Versions"); + 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/Services/EmailSender.cs b/src/isnd/Services/EmailSender.cs index 7f3d1fd..31b85e7 100644 --- a/src/isnd/Services/EmailSender.cs +++ b/src/isnd/Services/EmailSender.cs @@ -4,7 +4,6 @@ using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.Extensions.Options; using Microsoft.AspNetCore.Hosting; using MailKit.Net.Smtp; -using MailKit.Security; using MimeKit; using System; @@ -37,26 +36,14 @@ namespace isnd.Services { try { var message = new MimeMessage(); - message.From.Add(new MailboxAddress(Options.SenderName, Options.SenderEmail)); - message.To.Add(new MailboxAddress(name ?? email, email)); + message.From.Add(new MailboxAddress(Options.SenderName, Options.SenderEMail)); + message.To.Add(new MailboxAddress(name??email, email)); message.Body = new TextPart("html") { Text = body }; using (var client = new SmtpClient()) { - client.ServerCertificateValidationCallback = (s,c,h,e) => true; - if (Options.Port > 0) - { - await client.ConnectAsync(Options.Host, Options.Port, SecureSocketOptions.Auto); - } - else - { - await client.ConnectAsync(Options.Host); - } - - if (!string.IsNullOrWhiteSpace(Options.UserName)) - { - await client.AuthenticateAsync(Options.UserName, Options.Password); - } - + client.ServerCertificateValidationCallback = (s,c,h,e)=>true; + await client.ConnectAsync(Options.Server); + await client.AuthenticateAsync(Options.UserName, Options.Password); await client.SendAsync(message); await client.DisconnectAsync(true); } diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 2238cf1..9ef1a52 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -53,7 +53,7 @@ namespace isnd { var smtpSettingsconf = Configuration.GetSection("Smtp"); var isndSettingsconf = Configuration.GetSection("Isn"); - var adminStartupListConf = Configuration.GetSection("AdminStartupList"); + var adminStartupListConf = Configuration.GetSection("AdminList"); services.Configure(options => { diff --git a/src/isnd/appsettings.json b/src/isnd/appsettings.json index 06ba611..ba98409 100644 --- a/src/isnd/appsettings.json +++ b/src/isnd/appsettings.json @@ -16,7 +16,7 @@ }, "AllowedHosts": "*", "Smtp": { - "Host": "", + "Server": "", "Port": 25, "SenderName": "", "SenderEmail": ""