diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Data/General/AppCookie.cs | 9 | ||||
| -rw-r--r-- | src/Data/Static/AppCookies.cs | 13 | ||||
| -rw-r--r-- | src/Data/Static/AppJsonSettings.cs | 2 | ||||
| -rw-r--r-- | src/IOL.WebApi.Template.csproj | 6 | ||||
| -rw-r--r-- | src/Startup.cs | 6 |
5 files changed, 29 insertions, 7 deletions
diff --git a/src/Data/General/AppCookie.cs b/src/Data/General/AppCookie.cs new file mode 100644 index 0000000..afa876f --- /dev/null +++ b/src/Data/General/AppCookie.cs @@ -0,0 +1,9 @@ +namespace IOL.WebApi.Template.Data.General +{ + public sealed record AppCookie + { + public string Name { get; init; } + public string Description { get; init; } + public bool Required { get; init; } + } +} diff --git a/src/Data/Static/AppCookies.cs b/src/Data/Static/AppCookies.cs new file mode 100644 index 0000000..3bb8ff9 --- /dev/null +++ b/src/Data/Static/AppCookies.cs @@ -0,0 +1,13 @@ +using IOL.WebApi.Template.Data.General; + +namespace IOL.WebApi.Template.Data.Static +{ + public static class AppCookies + { + public static AppCookie Session => new() { + Name = "IOL.WebApi.Template_session", + Description = "This cookie is required to keep track of you when you log in.", + Required = false + }; + } +} diff --git a/src/Data/Static/AppJsonSettings.cs b/src/Data/Static/AppJsonSettings.cs index 8aad1ba..dd26588 100644 --- a/src/Data/Static/AppJsonSettings.cs +++ b/src/Data/Static/AppJsonSettings.cs @@ -7,7 +7,7 @@ namespace IOL.WebApi.Template.Data.Static { public static class AppJsonSettings { - public static Action<JsonOptions> Value { get; } = options => { + public static Action<JsonOptions> Default { get; } = options => { options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve; options.JsonSerializerOptions.PropertyNameCaseInsensitive = true; options.JsonSerializerOptions.NumberHandling = JsonNumberHandling.AllowReadingFromString; diff --git a/src/IOL.WebApi.Template.csproj b/src/IOL.WebApi.Template.csproj index 5fc7513..98bb747 100644 --- a/src/IOL.WebApi.Template.csproj +++ b/src/IOL.WebApi.Template.csproj @@ -6,12 +6,12 @@ <ItemGroup> <PackageReference Include="EFCore.NamingConventions" Version="5.0.2" /> - <PackageReference Include="IOL.Helpers" Version="1.0.4" /> - <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5"> + <PackageReference Include="IOL.Helpers" Version="1.1.1" /> + <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.5.1" /> + <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" /> <PackageReference Include="Serilog.AspNetCore" Version="4.1.0" /> </ItemGroup> diff --git a/src/Startup.cs b/src/Startup.cs index a3a7009..8ad5b07 100644 --- a/src/Startup.cs +++ b/src/Startup.cs @@ -30,7 +30,7 @@ namespace IOL.WebApi.Template services.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo(AppPaths.DataProtectionKeys.HostPath)); - services.Configure(AppJsonSettings.Value); + services.Configure(AppJsonSettings.Default); services.AddDbContext<AppDbContext>(options => { options.UseNpgsql("Server={DB_HOST};Port={DB_PORT};Database={DB_NAME};User Id={DB_USER};Password={DB_PASSWORD}".UnicornFormatWithEnvironment(Configuration), @@ -45,14 +45,14 @@ namespace IOL.WebApi.Template services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { - options.Cookie.Name = ""; + options.Cookie.Name = AppCookies.Session.Name; options.Cookie.SameSite = SameSiteMode.Strict; options.Cookie.HttpOnly = true; options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; }); services.AddControllers() - .AddJsonOptions(AppJsonSettings.Value); + .AddJsonOptions(AppJsonSettings.Default); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. |
