backend metrics implementation
This commit is contained in:
parent
a4ed1a5956
commit
62c22d057b
69 changed files with 494 additions and 3834 deletions
|
|
@ -8,6 +8,9 @@ public static class ConfigurationExtensions
|
|||
{
|
||||
configuration.Sources.Clear();
|
||||
configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
return configuration.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
|
||||
configuration.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
|
||||
configuration.AddEnvironmentVariables();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Vaitr.Network" Version="2024.1.8" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -16,43 +16,29 @@ namespace Insight.Infrastructure;
|
|||
|
||||
public static partial class ServiceExtensions
|
||||
{
|
||||
public static IServiceCollection AddTokenServices(this IServiceCollection services, IConfiguration configuration)
|
||||
public static WebApplicationBuilder AddDefaults(this WebApplicationBuilder builder)
|
||||
{
|
||||
var options = new Models.TokenOptions(
|
||||
key: configuration.GetValue<string?>(Appsettings.Jwt.Key) ?? throw new Exception($"{Appsettings.Jwt.Key} value not set (appsettings)"),
|
||||
expires: configuration.GetValue<int?>(Appsettings.Jwt.Exp) ?? throw new Exception($"{Appsettings.Jwt.Exp} value not set (appsettings)"),
|
||||
audience: configuration.GetValue<Uri?>(Appsettings.Jwt.Audience) ?? throw new Exception($"{Appsettings.Jwt.Audience} value not set (appsettings)"),
|
||||
issuer: configuration.GetValue<Uri?>(Appsettings.Jwt.Issuer) ?? throw new Exception($"{Appsettings.Jwt.Issuer} value not set (appsettings)"));
|
||||
|
||||
services.AddSingleton(options);
|
||||
services.AddTransient<TokenService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddProxyServices(this IServiceCollection services)
|
||||
{
|
||||
// add before routing
|
||||
services.Configure<ForwardedHeadersOptions>(options =>
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddRoutingServices(this IServiceCollection services)
|
||||
{
|
||||
// add after proxy
|
||||
services.AddRouting(options =>
|
||||
builder.Services.AddRouting(options =>
|
||||
{
|
||||
options.LowercaseUrls = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddIdentityServices(this IServiceCollection services, IConfiguration configuration)
|
||||
public static WebApplicationBuilder AddApiDefaults(this WebApplicationBuilder builder)
|
||||
{
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddIdentity(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var connectionString = configuration.GetValue<string?>(Appsettings.Mongo.ConnectionString) ?? throw new Exception($"{Appsettings.Mongo.ConnectionString} value not set (appsettings)");
|
||||
|
||||
|
|
@ -67,6 +53,20 @@ public static partial class ServiceExtensions
|
|||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddTokenServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var options = new Models.TokenOptions(
|
||||
key: configuration.GetValue<string?>(Appsettings.Jwt.Key) ?? throw new Exception($"{Appsettings.Jwt.Key} value not set (appsettings)"),
|
||||
expires: configuration.GetValue<int?>(Appsettings.Jwt.Exp) ?? throw new Exception($"{Appsettings.Jwt.Exp} value not set (appsettings)"),
|
||||
audience: configuration.GetValue<Uri?>(Appsettings.Jwt.Audience) ?? throw new Exception($"{Appsettings.Jwt.Audience} value not set (appsettings)"),
|
||||
issuer: configuration.GetValue<Uri?>(Appsettings.Jwt.Issuer) ?? throw new Exception($"{Appsettings.Jwt.Issuer} value not set (appsettings)"));
|
||||
|
||||
services.AddSingleton(options);
|
||||
services.AddTransient<TokenService>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// REWRITE TO COOKIE ONLY FOR WEB
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.1.2" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ public static class ConfigurationExtensions
|
|||
{
|
||||
configuration.Sources.Clear();
|
||||
configuration.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||
return configuration.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
|
||||
configuration.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: true, reloadOnChange: true);
|
||||
configuration.AddEnvironmentVariables();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,7 @@ public static partial class ServiceExtensions
|
|||
return services.AddSingleton(provider => provider.GetRequiredService<MongoClient>().GetDatabase(Settings.Database));
|
||||
}
|
||||
|
||||
public static IServiceCollection AddInfrastructureServices(this IServiceCollection services)
|
||||
public static IServiceCollection AddIdentityServices(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IdentityService>();
|
||||
services.AddTransient<AuthenticatorService>();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.23.1" />
|
||||
<PackageReference Include="Vaitr.Scheduler" Version="2023.12.15.1" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue