From aea02022b46e5472e7df2e868aa006de3e503871 Mon Sep 17 00:00:00 2001 From: ShaoHua <345265198@qqcom> Date: Mon, 29 Dec 2025 01:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=81=E8=AE=B8=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E5=A4=96=E9=83=A8=E6=BA=90=E7=99=BB=E5=BD=95=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E7=AB=99=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vercel/project.json | 1 + .../DemoHttpApiHostModule.cs | 34 +++++++++++++++++++ .../Hua.Abp.Demo.HttpApi.Host.csproj | 3 +- .../appsettings.json | 6 ++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .vercel/project.json diff --git a/.vercel/project.json b/.vercel/project.json new file mode 100644 index 0000000..812014f --- /dev/null +++ b/.vercel/project.json @@ -0,0 +1 @@ +{"neverMindDeployCard":true} \ No newline at end of file diff --git a/src/Hua.Abp.Demo.HttpApi.Host/DemoHttpApiHostModule.cs b/src/Hua.Abp.Demo.HttpApi.Host/DemoHttpApiHostModule.cs index ab2b4a5..432f9ba 100644 --- a/src/Hua.Abp.Demo.HttpApi.Host/DemoHttpApiHostModule.cs +++ b/src/Hua.Abp.Demo.HttpApi.Host/DemoHttpApiHostModule.cs @@ -1,4 +1,5 @@ using System; +using System.Threading.Tasks; using System.Collections.Generic; using System.IO; using System.Linq; @@ -123,6 +124,39 @@ public class DemoHttpApiHostModule : AbpModule private void ConfigureAuthentication(ServiceConfigurationContext context) { context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme); + + var configuration = context.Services.GetConfiguration(); + context.Services.AddAuthentication() + .AddOpenIdConnect("WeGit", "Login with WeGit", options => + { + options.Authority = "https://git.we965.cn"; + options.ClientId = configuration["Authentication:WeGit:ClientId"]!; + options.ClientSecret = configuration["Authentication:WeGit:ClientSecret"]!; + options.ResponseType = "code"; + + // Gitea specific scopes or defaults + options.Scope.Add("openid"); + options.Scope.Add("profile"); + options.Scope.Add("email"); + + // Ensure HTTPS + options.RequireHttpsMetadata = true; + options.SaveTokens = true; + + // Handle events if needed, e.g. mapping claims + options.Events.OnTokenValidated = async context => + { + // You might need to map specific claims here if Gitea returns non-standard ones + await Task.CompletedTask; + }; + + // Bypass SSL certificate validation (DEV ONLY) + options.BackchannelHttpHandler = new System.Net.Http.HttpClientHandler + { + ServerCertificateCustomValidationCallback = System.Net.Http.HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + }); + context.Services.Configure(options => { options.IsDynamicClaimsEnabled = true; diff --git a/src/Hua.Abp.Demo.HttpApi.Host/Hua.Abp.Demo.HttpApi.Host.csproj b/src/Hua.Abp.Demo.HttpApi.Host/Hua.Abp.Demo.HttpApi.Host.csproj index 0dc36dc..ebebfac 100644 --- a/src/Hua.Abp.Demo.HttpApi.Host/Hua.Abp.Demo.HttpApi.Host.csproj +++ b/src/Hua.Abp.Demo.HttpApi.Host/Hua.Abp.Demo.HttpApi.Host.csproj @@ -1,4 +1,4 @@ - + @@ -19,6 +19,7 @@ + diff --git a/src/Hua.Abp.Demo.HttpApi.Host/appsettings.json b/src/Hua.Abp.Demo.HttpApi.Host/appsettings.json index 4f09c03..0d00351 100644 --- a/src/Hua.Abp.Demo.HttpApi.Host/appsettings.json +++ b/src/Hua.Abp.Demo.HttpApi.Host/appsettings.json @@ -16,6 +16,12 @@ "SwaggerClientId": "Demo_Swagger", "CertificatePassPhrase": "a8dad6bd-08cf-40f9-baaf-873686b50b75" }, + "Authentication": { + "WeGit": { + "ClientId": "your-client-id", + "ClientSecret": "your-client-secret" + } + }, "StringEncryption": { "DefaultPassPhrase": "xleACjIr9Lbh6yNy" }} \ No newline at end of file