Rewrite captcha system (#754)

Rewrite captcha and remove many unused directives
This commit is contained in:
Josh 2023-04-28 23:32:42 -05:00 committed by GitHub
commit 3aa9033b67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 101 additions and 111 deletions

View file

@ -1,8 +1,11 @@
using System.Globalization;
using System.Net;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Localization;
using LBPUnion.ProjectLighthouse.Middlewares;
using LBPUnion.ProjectLighthouse.Servers.Website.Captcha;
using LBPUnion.ProjectLighthouse.Servers.Website.Middlewares;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Localization;
@ -44,6 +47,20 @@ public class WebsiteStartup
services.AddDbContext<DatabaseContext>();
services.AddHttpClient<ICaptchaService, CaptchaService>("CaptchaAPI",
client =>
{
Uri captchaUri = ServerConfiguration.Instance.Captcha.Type switch
{
CaptchaType.HCaptcha => new Uri("https://hcaptcha.com"),
CaptchaType.ReCaptcha => new Uri("https://www.google.com/recaptcha/api/"),
_ => throw new ArgumentOutOfRangeException(nameof(client)),
};
client.BaseAddress = captchaUri;
client.Timeout = TimeSpan.FromSeconds(5);
client.DefaultRequestHeaders.Add("User-Agent", "Project Lighthouse");
});
services.Configure<ForwardedHeadersOptions>
(
options =>