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