将当前服务作为git.we965.cn的认证源

This commit is contained in:
ShaoHua
2025-12-29 03:32:26 +08:00
parent aea02022b4
commit 93f2eaf285
5 changed files with 50 additions and 4 deletions
@@ -10,6 +10,11 @@
"Demo_Swagger": {
"ClientId": "Demo_Swagger",
"RootUrl": "https://localhost:44322/"
},
"Demo_Git": {
"ClientId": "Demo_Git",
"ClientSecret": "88077533-3e06-4447-818d-29472e340a6e",
"RootUrl": "https://git.we965.cn"
}
}
}
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
@@ -113,6 +113,34 @@ public class OpenIddictDataSeedContributor : OpenIddictDataSeedContributorBase,
);
}
// Git Client
var gitClientId = configurationSection["Demo_Git:ClientId"];
if (!gitClientId.IsNullOrWhiteSpace())
{
var gitRootUrl = configurationSection["Demo_Git:RootUrl"]?.TrimEnd('/');
var gitClientSecret = configurationSection["Demo_Git:ClientSecret"];
await CreateOrUpdateApplicationAsync(
applicationType: OpenIddictConstants.ApplicationTypes.Web,
name: gitClientId!,
type: OpenIddictConstants.ClientTypes.Confidential,
consentType: OpenIddictConstants.ConsentTypes.Implicit,
displayName: "Git Application",
secret: gitClientSecret,
grantTypes: new List<string> {
OpenIddictConstants.GrantTypes.AuthorizationCode,
OpenIddictConstants.GrantTypes.RefreshToken
},
scopes: commonScopes,
redirectUris: new List<string> {
$"{gitRootUrl}/users/auth/openid_connect/callback",
$"{gitRootUrl}/user/oauth2/Abp.Demo/callback"
},
postLogoutRedirectUris: new List<string> { $"{gitRootUrl}" },
clientUri: gitRootUrl
);
}
}
}
@@ -85,6 +85,14 @@ public class DemoHttpApiHostModule : AbpModule
serverBuilder.SetIssuer(new Uri(configuration["AuthServer:Authority"]!));
});
}
else
{
// DEV ONLY: Allow Gitea to connect via HTTP without forcing HTTPS metadata
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
serverBuilder.UseAspNetCore().DisableTransportSecurityRequirement();
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
@@ -18,7 +18,7 @@
"Hua.Abp.Demo.HttpApi.Host": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:44322",
"applicationUrl": "https://localhost:44322;http://0.0.0.0:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
@@ -11,8 +11,8 @@
"Default": "Host=localhost;Port=5432;Database=Demo;User ID=postgres;Password=123456;"
},
"AuthServer": {
"Authority": "https://localhost:44322",
"RequireHttpsMetadata": true,
"Authority": "http://192.168.31.2:5000",
"RequireHttpsMetadata": false,
"SwaggerClientId": "Demo_Swagger",
"CertificatePassPhrase": "a8dad6bd-08cf-40f9-baaf-873686b50b75"
},
@@ -20,6 +20,11 @@
"WeGit": {
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret"
},
"Demo_Git": {
"ClientId": "Demo_Git",
"ClientSecret": "88077533-3e06-4447-818d-29472e340a6e",
"RootUrl": "https://git.we965.cn"
}
},
"StringEncryption": {