2020-01-10 08:33:13 -05:00
|
|
|
|
using AspNetCoreRateLimit;
|
2019-07-23 16:38:49 -04:00
|
|
|
|
using Bit.Core.Utilities;
|
2017-05-05 16:05:34 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Identity;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2017-05-05 16:05:34 -04:00
|
|
|
|
public class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2022-05-20 15:24:59 -04:00
|
|
|
|
CreateHostBuilder(args)
|
|
|
|
|
|
.Build()
|
|
|
|
|
|
.Run();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Host
|
2017-10-06 12:18:16 -04:00
|
|
|
|
.CreateDefaultBuilder(args)
|
2021-04-09 09:48:43 -04:00
|
|
|
|
.ConfigureCustomAppConfiguration(args)
|
2020-01-10 08:33:13 -05:00
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
webBuilder.UseStartup<Startup>();
|
|
|
|
|
|
webBuilder.ConfigureLogging((hostingContext, logging) =>
|
2022-09-26 15:22:02 -04:00
|
|
|
|
logging.AddSerilog(hostingContext, (e, globalSettings) =>
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-01-10 08:33:13 -05:00
|
|
|
|
var context = e.Properties["SourceContext"].ToString();
|
2022-09-26 15:22:02 -04:00
|
|
|
|
if (context.Contains(typeof(IpRateLimitMiddleware).FullName))
|
2019-07-23 16:38:49 -04:00
|
|
|
|
{
|
2022-09-26 15:22:02 -04:00
|
|
|
|
return e.Level >= globalSettings.MinLogLevel.IdentitySettings.IpRateLimit;
|
2020-01-10 08:33:13 -05:00
|
|
|
|
}
|
2019-07-23 16:38:49 -04:00
|
|
|
|
|
2023-11-20 16:32:23 -05:00
|
|
|
|
if (context.Contains("Duende.IdentityServer.Validation.TokenValidator") ||
|
|
|
|
|
|
context.Contains("Duende.IdentityServer.Validation.TokenRequestValidator"))
|
2020-01-10 08:33:13 -05:00
|
|
|
|
{
|
2022-09-26 15:22:02 -04:00
|
|
|
|
return e.Level >= globalSettings.MinLogLevel.IdentitySettings.IdentityToken;
|
2020-01-10 08:33:13 -05:00
|
|
|
|
}
|
2019-07-23 16:38:49 -04:00
|
|
|
|
|
2022-09-26 15:22:02 -04:00
|
|
|
|
return e.Level >= globalSettings.MinLogLevel.IdentitySettings.Default;
|
2020-01-10 08:33:13 -05:00
|
|
|
|
}));
|
2022-05-20 15:24:59 -04:00
|
|
|
|
});
|
2017-05-05 16:05:34 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|