You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using DS.WMS.OpenAuth;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// Add services to the container.
|
|
|
|
builder.Services.AddControllers();
|
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
builder.Services.AddEndpointsApiExplorer();
|
|
// builder.Services.AddSwaggerGen();
|
|
builder.Services.AddIdentityServer()
|
|
.AddDeveloperSigningCredential()
|
|
.AddInMemoryIdentityResources(Config.IdentityResources)
|
|
.AddInMemoryClients(Config.Clients)
|
|
.AddInMemoryApiScopes(Config.ApiScopes)
|
|
.AddInMemoryApiResources(Config.ApiResources) //.AddResourceOwnerValidator<MyResourceOwnerPasswordValidator>() //这句可以打开自主验证登录用户
|
|
// .AddTestUsers(new List<IdentityServer4.Test.TestUser>())
|
|
//.AddProfileService<MyProfileService>()
|
|
// .AddAspNetIdentity<ApplicationUser>()
|
|
.AddTestUsers(new List<IdentityServer4.Test.TestUser>
|
|
{
|
|
new IdentityServer4.Test.TestUser
|
|
{
|
|
SubjectId="10001",
|
|
Username ="port",
|
|
Password ="!qweH%"
|
|
// SubjectId="123",
|
|
// Username = "alice",
|
|
// Password = "alice",
|
|
// Claims = new List<Claim>() {
|
|
// new Claim(JwtClaimTypes.Role, "superadmin"),
|
|
// new Claim(JwtClaimTypes.Role, "admin")
|
|
// }
|
|
}
|
|
})
|
|
;
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
// if (app.Environment.IsDevelopment())
|
|
// {
|
|
// app.UseSwagger();
|
|
// app.UseSwaggerUI();
|
|
// }
|
|
app.MapGet("/", () => "Hello World!");
|
|
// app.UseHttpsRedirection();
|
|
app.UseIdentityServer();
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllers();
|
|
|
|
app.Run(); |