添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
using IdentityService.Domain.Entities;
using IdentityService.Infrastructure;
using IM.InitCommon;
using Microsoft.AspNetCore.Identity;
namespace IdentityService.WebApi
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.ConfigureDbConfiguration();
builder.ConfigExtraServices();
// 2. 🌟 微软 Identity 终极注册组合拳
builder.Services.AddIdentityCore<User>(options =>
{
// 这里可以顺手配置一下密码规则,比如不需要大写字母、最小长度等
options.Password.RequireLowercase = false;
options.Password.RequireNonAlphanumeric = false;
options.Password.RequireUppercase = false;
options.Password.RequiredLength = 6;
})
.AddRoles<Role>()
.AddEntityFrameworkStores<UserDbContext>() // 👈 灵魂所在:自动向 DI 注入 IUserStore<User> 等几十个底层接口!
.AddUserManager<IdUserManager>() // 👈 告诉框架:不要用你默认的 UserManager,用我自定义的 IdUserManager
.AddRoleManager<RoleManager<Role>>()
.AddDefaultTokenProviders(); // 👈 顺带注册生成验证码/重置密码Token的服务
builder.Services.AddAllGrpcServer();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAppDefault();
app.MapControllers();
app.MapAllGrpcServer();
app.Run();
}
}
}