|
@@ -1,4 +1,7 @@
|
|
|
+using System.IdentityModel.Tokens.Jwt;
|
|
|
using Identity.Host;
|
|
|
+using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
+using Microsoft.IdentityModel.Tokens;
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
var services = builder.Services;
|
|
@@ -7,8 +10,23 @@ var services = builder.Services;
|
|
|
builder.Services.AddControllersWithViews();
|
|
|
|
|
|
services
|
|
|
- .RegisterIds4()
|
|
|
- .AddAuthentication();
|
|
|
+ .RegisterIds4();
|
|
|
+//.AddAuthentication();
|
|
|
+
|
|
|
+JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
|
|
|
+services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
|
+ .AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, d =>
|
|
|
+ {
|
|
|
+ d.Authority = "http://localhost:50200";
|
|
|
+ d.RequireHttpsMetadata = false;
|
|
|
+ d.TokenValidationParameters = new TokenValidationParameters
|
|
|
+ {
|
|
|
+ ValidateAudience = false
|
|
|
+ };
|
|
|
+ //d.Audience = "hotline_api";
|
|
|
+ });
|
|
|
+
|
|
|
+services.AddSwaggerGen();
|
|
|
|
|
|
var app = builder.Build();
|
|
|
|
|
@@ -17,12 +35,20 @@ if (!app.Environment.IsDevelopment())
|
|
|
{
|
|
|
app.UseExceptionHandler("/Home/Error");
|
|
|
}
|
|
|
+
|
|
|
+//if (app.Environment.IsDevelopment())
|
|
|
+//{
|
|
|
+app.UseSwagger();
|
|
|
+app.UseSwaggerUI();
|
|
|
+//}
|
|
|
+
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
app.UseIdentityServer();
|
|
|
|
|
|
+app.UseAuthentication();
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
app.MapControllerRoute(
|