| | | 1 | | using Anichron.Infrastructure.Configuration; |
| | | 2 | | using System.IO.Abstractions; |
| | | 3 | | using System.Security.Cryptography; |
| | | 4 | | |
| | | 5 | | namespace Anichron.API.Infrastructure; |
| | | 6 | | |
| | | 7 | | public static class WebApplicationBuilderExtensions |
| | | 8 | | { |
| | | 9 | | extension(WebApplicationBuilder builder) |
| | | 10 | | { |
| | | 11 | | public WebApplicationBuilder AddAppConfiguration() |
| | 0 | 12 | | { |
| | 0 | 13 | | var iniPath = Path.Combine(builder.Environment.ContentRootPath, "configuration", "app.ini"); |
| | 0 | 14 | | new AppIniInitializer(new FileSystem()).EnsureUpToDate(iniPath, |
| | 0 | 15 | | [ |
| | 0 | 16 | | new IniEntry("Jwt", "Secret", () => Convert.ToBase64String(RandomNumberGenerator.GetBytes(64))), |
| | 0 | 17 | | new IniEntry("Jwt", "Issuer", () => "anichron-api"), |
| | 0 | 18 | | new IniEntry("Jwt", "Audience", () => "anichron-client"), |
| | 0 | 19 | | new IniEntry("Cors", "AllowedOrigins", () => string.Empty), |
| | 0 | 20 | | ]); |
| | 0 | 21 | | builder.Configuration.AddIniFile(iniPath, optional: false, reloadOnChange: false); |
| | 0 | 22 | | builder.Configuration.AddEnvironmentVariables(); |
| | 0 | 23 | | return builder; |
| | | 24 | | } |
| | | 25 | | } |
| | | 26 | | } |