Compare commits
2 Commits
bcde4178df
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5c8ef2cb3a | |||
| b4f70ad250 |
@@ -11,16 +11,19 @@ using Microsoft.EntityFrameworkCore;
|
||||
using ProjecThing.Models.CodeTable;
|
||||
using ProjecThing.Models.Invoice;
|
||||
using ProjecThing.Models.Project;
|
||||
using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
|
||||
|
||||
namespace ProjecThing.Data
|
||||
{
|
||||
public class ApplicationDbContext : IdentityDbContext<IdentityApplicationUser, IdentityApplicationRole, int>
|
||||
public class ApplicationDbContext : IdentityDbContext<IdentityApplicationUser, IdentityApplicationRole, int>, IDataProtectionKeyContext
|
||||
{
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public DbSet<DataProtectionKey> DataProtectionKeys { get; set; }
|
||||
|
||||
public DbSet<CodeTableEmployee> CodeTableEmployees { get; set; }
|
||||
public DbSet<CodeTableCountry> CodeTableCountries { get; set; }
|
||||
public DbSet<CodeTableCompany> CodeTableCompanies { get; set; }
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="1a7bd1ae-19dc-41de-be2e-e64403f82159" version="1">
|
||||
<creationDate>2023-05-03T13:10:54.373874Z</creationDate>
|
||||
<activationDate>2023-05-03T13:10:54.3012762Z</activationDate>
|
||||
<expirationDate>2023-08-01T13:10:54.3012762Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>XH/o1Q8fiukfCP8g46LJBJFVfKBnyVaJbhxdHEkP5bz7PXW0B+CsFIZidzz7++eyDlSb1lujrTnV09rlymVgzw==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="28c82385-e3fb-4bf5-8766-a65a4b53144e" version="1">
|
||||
<creationDate>2026-01-18T08:17:33.3724528Z</creationDate>
|
||||
<activationDate>2026-01-18T08:17:33.3012191Z</activationDate>
|
||||
<expirationDate>2026-04-18T08:17:33.3012191Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>WP+gZd5AUHUD8ugsMeP7EyB+VcsXYXij8TlutwS00Gj2Ts90aZCwhR3w1jtp2MGDslVjz3nMv2q3Sch7sq8v/w==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="3a2d4d5b-9fae-481e-b902-3e50890e2386" version="1">
|
||||
<creationDate>2024-01-19T06:26:18.9245244Z</creationDate>
|
||||
<activationDate>2024-01-19T06:26:18.7792911Z</activationDate>
|
||||
<expirationDate>2024-04-18T06:26:18.7792911Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>/4+zhF8eds5CwXoyfLX2NaJGRHLGr8zZ3HJEcZRG96k79WEp4iEwwvBBXHXo5uzCpyUsKkQFYlFYPyGakaPDZg==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="69f0890e-0f11-4830-98f4-f90d319c3479" version="1">
|
||||
<creationDate>2022-09-15T10:28:17.7415146Z</creationDate>
|
||||
<activationDate>2022-09-15T10:28:17.6715335Z</activationDate>
|
||||
<expirationDate>2022-12-14T10:28:17.6715335Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>c0QLoDfbPViGBz5zbImP5OxjcO34Bd/ZcyluZGJiisyrbiTv/fZJ8ikCxndCXHgj3gsQuggpaQ1R+B3r004bjQ==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="8d2d17f3-b4d1-4d3a-8b04-b97c5891f86b" version="1">
|
||||
<creationDate>2024-04-17T04:50:38.7033373Z</creationDate>
|
||||
<activationDate>2024-04-18T06:26:18.7792911Z</activationDate>
|
||||
<expirationDate>2024-07-16T04:50:38.5659371Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>I7t95L6HyZyzBOTzFlrz1J65fmo3X8Zj+iczrahxe0fVKadUcyFNjQeUsen/PKFzzWEMo/ZqfOXvXe3/uFcG2g==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="a3a38e55-9b11-4763-ad5f-f2a0b6e4174e" version="1">
|
||||
<creationDate>2023-10-11T11:07:58.675531Z</creationDate>
|
||||
<activationDate>2023-10-11T11:07:58.5733682Z</activationDate>
|
||||
<expirationDate>2024-01-09T11:07:58.5733682Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>GttplD47GNt2crkvytrDIMf6VRXoJ5CnYo30D51I7E+R6VLCT39/F8K0FYPTgiS2qqy3kfFu99304BeaU/vAiA==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="a73bf233-a73e-4b4f-a9be-00eb859c8481" version="1">
|
||||
<creationDate>2022-12-18T10:15:30.3394683Z</creationDate>
|
||||
<activationDate>2022-12-18T10:15:30.2779454Z</activationDate>
|
||||
<expirationDate>2023-03-18T10:15:30.2779454Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>VbcP3gI3GitBCLI9x3Y2e23HKce5cGyqJoUrjxV0WuCUWbBPNNDS0qoxjhKi7AdFRCth3RFI7yFr6eISjh/t4w==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="b71cc079-14ad-4082-8ae8-df61e7444549" version="1">
|
||||
<creationDate>2026-05-06T11:57:13.5764649Z</creationDate>
|
||||
<activationDate>2026-05-06T11:57:13.5007041Z</activationDate>
|
||||
<expirationDate>2026-08-04T11:57:13.5007041Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>a+UYgy/b/D7Mo7CNoIj9n7IGGVidnOJUBQEVf+reT9WL55CKdv5Poxua12yRI2nOBB9K0cj+8dz0aYtv9w4rfg==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="c6ca39e6-90a4-4a6c-82c1-57940171c341" version="1">
|
||||
<creationDate>2022-03-12T19:39:19.0684887Z</creationDate>
|
||||
<activationDate>2022-03-12T19:39:18.9942222Z</activationDate>
|
||||
<expirationDate>2022-06-10T19:39:18.9942222Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>JnNSZOrRvnv0Lz/Mxj3YQAE3fA8nqs3Kb3JKoB9u2sniq1LpASc7DyHGtr0PUWHKr+BYg9d/2ffjqdYSH16J9Q==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="dab2bc0e-f8d3-4ece-961d-c70c843695f5" version="1">
|
||||
<creationDate>2022-06-13T06:09:02.7441532Z</creationDate>
|
||||
<activationDate>2022-06-13T06:09:02.6344071Z</activationDate>
|
||||
<expirationDate>2022-09-11T06:09:02.6344071Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>koptjvQgnCMR8h3jm6BOt496AgU8mzyvqRST9hHM6yLzQdgvCu+J1Si2+TwhMaQiLef6XHCryl0U+qGQ6Bzg6A==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key id="e803459e-6187-453a-92e2-246643ca1beb" version="1">
|
||||
<creationDate>2025-07-18T03:36:53.332167Z</creationDate>
|
||||
<activationDate>2025-07-18T03:36:53.2539748Z</activationDate>
|
||||
<expirationDate>2025-10-16T03:36:53.2539748Z</expirationDate>
|
||||
<descriptor deserializerType="Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel.AuthenticatedEncryptorDescriptorDeserializer, Microsoft.AspNetCore.DataProtection, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60">
|
||||
<descriptor>
|
||||
<encryption algorithm="AES_256_CBC" />
|
||||
<validation algorithm="HMACSHA256" />
|
||||
<masterKey p4:requiresEncryption="true" xmlns:p4="http://schemas.asp.net/2015/03/dataProtection">
|
||||
<!-- Warning: the key below is in an unencrypted form. -->
|
||||
<value>dvPmRFK1RknKgQ74zgbcJgxSjN+LpaD4ch2GfGpz1CiTymQOdtOjD+wIv/dtG62IaBfeB5+By3/i3EpBCKtLHg==</value>
|
||||
</masterKey>
|
||||
</descriptor>
|
||||
</descriptor>
|
||||
</key>
|
||||
2542
ProjecThing/Migrations/20260622141620_AddDataProtectionKeys.Designer.cs
generated
Normal file
2542
ProjecThing/Migrations/20260622141620_AddDataProtectionKeys.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ProjecThing.Migrations
|
||||
{
|
||||
public partial class AddDataProtectionKeys : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DataProtectionKeys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||
FriendlyName = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Xml = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DataProtectionKeys", x => x.Id);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "DataProtectionKeys");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// <auto-generated />
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ProjecThing.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using ProjecThing.Data;
|
||||
|
||||
#nullable disable
|
||||
|
||||
@@ -19,6 +19,130 @@ namespace ProjecThing.Migrations
|
||||
.HasAnnotation("ProductVersion", "6.0.1")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FriendlyName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Xml")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("DataProtectionKeys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleClaim");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleFk");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("IdentityRoleClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserClaim");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("IdentityUserClaims", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("IdentityUserLogins", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleFk");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("IdentityUserRoles", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("IdentityUserTokens", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ProjecThing.Models.CodeTable.CodeTableCompany", b =>
|
||||
{
|
||||
b.Property<int>("IdCompany")
|
||||
@@ -1549,109 +1673,53 @@ namespace ProjecThing.Migrations
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleClaim");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleFk");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("IdentityRoleClaims", (string)null);
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserClaim");
|
||||
|
||||
b.Property<string>("ClaimType")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("ClaimValue")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("IdentityUserClaims", (string)null);
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderKey")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("ProviderDisplayName")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.HasKey("LoginProvider", "ProviderKey");
|
||||
|
||||
b.HasIndex("UserId");
|
||||
|
||||
b.ToTable("IdentityUserLogins", (string)null);
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Property<int>("RoleId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdRoleFk");
|
||||
|
||||
b.HasKey("UserId", "RoleId");
|
||||
|
||||
b.HasIndex("RoleId");
|
||||
|
||||
b.ToTable("IdentityUserRoles", (string)null);
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("IdUserFk");
|
||||
|
||||
b.Property<string>("LoginProvider")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<string>("Value")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.HasKey("UserId", "LoginProvider", "Name");
|
||||
|
||||
b.ToTable("IdentityUserTokens", (string)null);
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ProjecThing.Models.CodeTable.CodeTableCompany", b =>
|
||||
@@ -2273,57 +2341,6 @@ namespace ProjecThing.Migrations
|
||||
b.Navigation("Company");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<int>", b =>
|
||||
{
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<int>", b =>
|
||||
{
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<int>", b =>
|
||||
{
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationRole", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("RoleId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<int>", b =>
|
||||
{
|
||||
b.HasOne("ProjecThing.Models.IdentityApplicationUser", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ProjecThing.Models.CodeTable.CodeTableCompany", b =>
|
||||
{
|
||||
b.Navigation("CompanyDepartement");
|
||||
|
||||
@@ -1,16 +1,31 @@
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using ProjecThing.Data;
|
||||
using ProjecThing.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Security;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NLog;
|
||||
using NLog.Web;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
namespace ProjecThing
|
||||
{
|
||||
@@ -21,35 +36,223 @@ namespace ProjecThing
|
||||
//var logger = NLog.LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
//logger.Debug("INIT");
|
||||
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Configure NLog
|
||||
builder.Logging.ClearProviders();
|
||||
builder.Logging.AddConsole();
|
||||
builder.Host.UseNLog();
|
||||
|
||||
builder.Services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
|
||||
//builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
//{
|
||||
// options.KnownProxies.Add(IPAddress.Parse("192.168.111.78"));
|
||||
//});
|
||||
|
||||
// Database connection
|
||||
string connectionString = builder.Configuration.GetConnectionString("DataConnection");
|
||||
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
||||
//builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataConnection")));
|
||||
|
||||
// Session
|
||||
builder.Services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromHours(3);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
options.Cookie.MaxAge = TimeSpan.FromHours(3);
|
||||
});
|
||||
|
||||
// JWT
|
||||
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
|
||||
{
|
||||
options.SaveToken = true;
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = "ProjecThing",
|
||||
ValidAudience = "Android",
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("!Appli$cation#9999#!"))
|
||||
};
|
||||
});
|
||||
|
||||
// Identity
|
||||
builder.Services.AddIdentity<IdentityApplicationUser, IdentityApplicationRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
|
||||
|
||||
builder.Services.AddRazorPages(options =>
|
||||
{
|
||||
//options.Conventions.AddPageRoute("/Administration/Users", "/AdministrationUsers");
|
||||
}).AddRazorRuntimeCompilation();
|
||||
|
||||
//builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
//{
|
||||
// options.ForwardedHeaders =
|
||||
// ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
// options.KnownProxies.Add(IPAddress.Parse("192.168.111.78"));
|
||||
// //options.ForwardedForHeaderName = "X-Forwarded-For-My-Custom-Header-Name";
|
||||
//});
|
||||
|
||||
builder.Services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");
|
||||
|
||||
builder.Services.Configure<IdentityOptions>(options =>
|
||||
{
|
||||
// Password settings
|
||||
options.Password.RequireDigit = true;
|
||||
options.Password.RequireLowercase = true;
|
||||
options.Password.RequireNonAlphanumeric = true;
|
||||
options.Password.RequireUppercase = true;
|
||||
options.Password.RequiredLength = 8;
|
||||
options.Password.RequiredUniqueChars = 1;
|
||||
|
||||
// Lockout settings
|
||||
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
|
||||
options.Lockout.MaxFailedAccessAttempts = 3;
|
||||
options.Lockout.AllowedForNewUsers = true;
|
||||
|
||||
// User settings
|
||||
options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
options.User.RequireUniqueEmail = true;
|
||||
});
|
||||
|
||||
builder.Services.ConfigureApplicationCookie(options =>
|
||||
{
|
||||
// Cookie
|
||||
options.Cookie.MaxAge = TimeSpan.FromHours(3);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.SlidingExpiration = true;
|
||||
options.Cookie.SecurePolicy = CookieSecurePolicy.None;//Samo unencripted na locas
|
||||
|
||||
options.LoginPath = $"/User/Login";
|
||||
options.LogoutPath = $"/User/Logout";
|
||||
options.AccessDeniedPath = $"/";
|
||||
options.ExpireTimeSpan = TimeSpan.FromHours(3);//Povecano na 15min
|
||||
});
|
||||
|
||||
builder.Services.AddDistributedMemoryCache();
|
||||
|
||||
builder.Services.Configure<IISOptions>(options =>
|
||||
{
|
||||
options.AutomaticAuthentication = false;
|
||||
});
|
||||
|
||||
//builder.Services.AddDataProtection().SetApplicationName("ProjecThing").PersistKeysToFileSystem(new DirectoryInfo(@"Keys/"));
|
||||
|
||||
builder.Services.AddDataProtection()
|
||||
.SetApplicationName("ProjecThing")
|
||||
.PersistKeysToDbContext<ApplicationDbContext>()
|
||||
.AddKeyManagementOptions(options =>
|
||||
{
|
||||
options.NewKeyLifetime = new TimeSpan(365, 0, 0, 0);
|
||||
options.AutoGenerateKeys = true;
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Apply migrations in production
|
||||
#if !DEBUG
|
||||
ApplyMigrations(app);
|
||||
#endif
|
||||
|
||||
// ===== Configure Middleware Pipeline =====
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
//app.UseForwardedHeaders();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
//app.UseForwardedHeaders();
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(
|
||||
webBuilder =>
|
||||
{
|
||||
webBuilder.ConfigureLogging(logging =>
|
||||
{
|
||||
logging.ClearProviders();
|
||||
logging.AddConsole();
|
||||
}).UseNLog();
|
||||
//app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
//{
|
||||
// ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
//});
|
||||
|
||||
#if !DEBUG
|
||||
webBuilder.UseKestrel(opts =>
|
||||
{
|
||||
var appServices = opts.ApplicationServices;
|
||||
//opts.Listen(IPAddress.Parse("192.168.1.150"), 80);
|
||||
//opts.Listen(IPAddress.Parse("192.168.1.150"), 443, o => o.UseHttps(h => { h.UseLettuceEncrypt(appServices); }));
|
||||
|
||||
//opts.Listen(IPAddress.Parse("192.168.111.77"), 5005);
|
||||
opts.Listen(IPAddress.Parse("192.168.178.205"), 5005);//novi server
|
||||
opts.Listen(IPAddress.Loopback, port: 8081);
|
||||
//opts.ListenLocalhost(4433, opts => opts.UseHttps());
|
||||
opts.ListenLocalhost(5005);
|
||||
//opts.ListenLocalhost(5005, opts => opts.UseHttps());
|
||||
});
|
||||
#endif
|
||||
webBuilder.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
var defaultCulture = new CultureInfo("sl-SI");
|
||||
var localizationOptions = new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture(defaultCulture),
|
||||
SupportedCultures = new List<CultureInfo> { defaultCulture },
|
||||
SupportedUICultures = new List<CultureInfo> { defaultCulture }
|
||||
};
|
||||
app.UseRequestLocalization(localizationOptions);
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseCookiePolicy();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseSession();
|
||||
|
||||
app.MapRazorPages();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
//CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
private static void ApplyMigrations(IHost app)
|
||||
{
|
||||
using var scope = app.Services.CreateScope();
|
||||
var dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||
|
||||
// Check and apply pending migrations
|
||||
var pendingMigrations = dbContext.Database.GetPendingMigrations();
|
||||
if (pendingMigrations.Any())
|
||||
{
|
||||
Console.WriteLine("Applying pending migrations...");
|
||||
dbContext.Database.Migrate();
|
||||
Console.WriteLine("Migrations applied successfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("No pending migrations found.");
|
||||
}
|
||||
}
|
||||
|
||||
// public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args).ConfigureWebHostDefaults(
|
||||
// webBuilder =>
|
||||
// {
|
||||
// webBuilder.ConfigureLogging(logging =>
|
||||
// {
|
||||
// logging.ClearProviders();
|
||||
// logging.AddConsole();
|
||||
// }).UseNLog();
|
||||
|
||||
//#if !DEBUG
|
||||
// webBuilder.UseKestrel(opts =>
|
||||
// {
|
||||
// var appServices = opts.ApplicationServices;
|
||||
// //opts.Listen(IPAddress.Parse("192.168.1.150"), 80);
|
||||
// //opts.Listen(IPAddress.Parse("192.168.1.150"), 443, o => o.UseHttps(h => { h.UseLettuceEncrypt(appServices); }));
|
||||
|
||||
// //opts.Listen(IPAddress.Parse("192.168.111.77"), 5005);
|
||||
// opts.Listen(IPAddress.Parse("192.168.178.205"), 5005);//novi server
|
||||
// opts.Listen(IPAddress.Loopback, port: 8081);
|
||||
// //opts.ListenLocalhost(4433, opts => opts.UseHttps());
|
||||
// opts.ListenLocalhost(5005);
|
||||
// //opts.ListenLocalhost(5005, opts => opts.UseHttps());
|
||||
// });
|
||||
//#endif
|
||||
// webBuilder.UseContentRoot(Directory.GetCurrentDirectory());
|
||||
// webBuilder.UseStartup<Startup>();
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
|
||||
<StartupObject>ProjecThing.Program</StartupObject>
|
||||
<UserSecretsId>26f134e2-3bc7-4885-b726-e8a92f2abb2e</UserSecretsId>
|
||||
@@ -23,6 +23,7 @@
|
||||
<TypeScriptCompile Remove="node_modules\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Keys\" />
|
||||
<Folder Include="Migrations\" />
|
||||
<Folder Include="Properties\PublishProfiles\" />
|
||||
<Folder Include="Properties\ServiceDependencies\" />
|
||||
@@ -30,13 +31,14 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ClosedXML" Version="0.95.4" />
|
||||
<PackageReference Include="Htmx" Version="0.0.15" />
|
||||
<PackageReference Include="Htmx.TagHelpers" Version="0.0.15" />
|
||||
<PackageReference Include="LettuceEncrypt" Version="1.1.2" />
|
||||
<PackageReference Include="MailKit" Version="3.6.0" />
|
||||
<PackageReference Include="ClosedXML" Version="0.105.0" />
|
||||
<PackageReference Include="Htmx" Version="1.12.0" />
|
||||
<PackageReference Include="Htmx.TagHelpers" Version="1.12.0" />
|
||||
<PackageReference Include="LettuceEncrypt" Version="1.3.3" />
|
||||
<PackageReference Include="MailKit" Version="4.17.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
|
||||
@@ -58,9 +60,9 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore" Version="6.0.1" />
|
||||
<PackageReference Include="NLog" Version="4.7.14" />
|
||||
<PackageReference Include="NLog.Config" Version="4.7.14" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
|
||||
<PackageReference Include="NLog" Version="6.1.3" />
|
||||
<PackageReference Include="NLog.Config" Version="4.7.15" />
|
||||
<PackageReference Include="NLog.Web.AspNetCore" Version="6.1.3" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.1" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,197 +0,0 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.HttpsPolicy;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using ProjecThing.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Connections;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using ProjecThing.Data;
|
||||
using Microsoft.AspNetCore.Authentication.Negotiate;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
|
||||
namespace ProjecThing
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.Configure<CookiePolicyOptions>(options =>
|
||||
{
|
||||
options.CheckConsentNeeded = context => true;
|
||||
options.MinimumSameSitePolicy = SameSiteMode.None;
|
||||
});
|
||||
|
||||
//services.Configure<ForwardedHeadersOptions>(options =>
|
||||
//{
|
||||
// options.KnownProxies.Add(IPAddress.Parse("192.168.111.78"));
|
||||
//});
|
||||
|
||||
// Database connection
|
||||
string connectionString = Configuration.GetConnectionString("DataConnection");
|
||||
services.AddDbContext<ApplicationDbContext>(options => options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)));
|
||||
//services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataConnection")));
|
||||
|
||||
// Session
|
||||
services.AddSession(options =>
|
||||
{
|
||||
options.IdleTimeout = TimeSpan.FromHours(3);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.Cookie.IsEssential = true;
|
||||
options.Cookie.MaxAge = TimeSpan.FromHours(3);
|
||||
});
|
||||
|
||||
// JWT
|
||||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme).AddJwtBearer(options =>
|
||||
{
|
||||
options.SaveToken = true;
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
ValidateIssuer = true,
|
||||
ValidateAudience = true,
|
||||
ValidateLifetime = true,
|
||||
ValidateIssuerSigningKey = true,
|
||||
ValidIssuer = "ProjecThing",
|
||||
ValidAudience = "Android",
|
||||
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("!Appli$cation#9999#!"))
|
||||
};
|
||||
});
|
||||
|
||||
// Identity
|
||||
services.AddIdentity<IdentityApplicationUser, IdentityApplicationRole>().AddEntityFrameworkStores<ApplicationDbContext>().AddDefaultTokenProviders();
|
||||
|
||||
services.AddRazorPages(options =>
|
||||
{
|
||||
//options.Conventions.AddPageRoute("/Administration/Users", "/AdministrationUsers");
|
||||
}).AddRazorRuntimeCompilation();
|
||||
|
||||
//services.Configure<ForwardedHeadersOptions>(options =>
|
||||
//{
|
||||
// options.ForwardedHeaders =
|
||||
// ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
// options.KnownProxies.Add(IPAddress.Parse("192.168.111.78"));
|
||||
// //options.ForwardedForHeaderName = "X-Forwarded-For-My-Custom-Header-Name";
|
||||
//});
|
||||
|
||||
services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");
|
||||
|
||||
services.Configure<IdentityOptions>(options =>
|
||||
{
|
||||
// Password settings
|
||||
options.Password.RequireDigit = true;
|
||||
options.Password.RequireLowercase = true;
|
||||
options.Password.RequireNonAlphanumeric = true;
|
||||
options.Password.RequireUppercase = true;
|
||||
options.Password.RequiredLength = 8;
|
||||
options.Password.RequiredUniqueChars = 1;
|
||||
|
||||
// Lockout settings
|
||||
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
|
||||
options.Lockout.MaxFailedAccessAttempts = 3;
|
||||
options.Lockout.AllowedForNewUsers = true;
|
||||
|
||||
// User settings
|
||||
options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
options.User.RequireUniqueEmail = true;
|
||||
});
|
||||
|
||||
services.ConfigureApplicationCookie(options =>
|
||||
{
|
||||
// Cookie
|
||||
options.Cookie.MaxAge = TimeSpan.FromHours(3);
|
||||
options.Cookie.HttpOnly = true;
|
||||
options.SlidingExpiration = true;
|
||||
options.Cookie.SecurePolicy = CookieSecurePolicy.None;//Samo unencripted na locas
|
||||
|
||||
options.LoginPath = $"/User/Login";
|
||||
options.LogoutPath = $"/User/Logout";
|
||||
options.AccessDeniedPath = $"/";
|
||||
options.ExpireTimeSpan = TimeSpan.FromHours(3);//Povecano na 15min
|
||||
});
|
||||
|
||||
services.AddDistributedMemoryCache();
|
||||
|
||||
services.Configure<IISOptions>(options =>
|
||||
{
|
||||
options.AutomaticAuthentication = false;
|
||||
});
|
||||
|
||||
services.AddDataProtection().SetApplicationName("ProjecThing").PersistKeysToFileSystem(new DirectoryInfo(@"Keys/"));
|
||||
|
||||
//services.AddHttpsRedirection(options =>
|
||||
//{
|
||||
// options.RedirectStatusCode = (int)HttpStatusCode.PermanentRedirect;
|
||||
// options.HttpsPort = 443;
|
||||
//});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
//app.UseForwardedHeaders();
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseExceptionHandler("/Error");
|
||||
//app.UseForwardedHeaders();
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
//app.UseForwardedHeaders(new ForwardedHeadersOptions
|
||||
//{
|
||||
// ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
|
||||
//});
|
||||
|
||||
|
||||
var defaultCulture = new CultureInfo("sl-SI");
|
||||
var localizationOptions = new RequestLocalizationOptions
|
||||
{
|
||||
DefaultRequestCulture = new RequestCulture(defaultCulture),
|
||||
SupportedCultures = new List<CultureInfo> { defaultCulture },
|
||||
SupportedUICultures = new List<CultureInfo> { defaultCulture }
|
||||
};
|
||||
app.UseRequestLocalization(localizationOptions);
|
||||
|
||||
//app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseCookiePolicy();
|
||||
|
||||
app.UseRouting();
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseSession();
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapRazorPages();
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user