mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-09 13:28:39 +00:00
Rewrite captcha system (#754)
Rewrite captcha and remove many unused directives
This commit is contained in:
parent
aefecc7b12
commit
3aa9033b67
36 changed files with 101 additions and 111 deletions
|
@ -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 =>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue