|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Claims;
|
|
|
|
|
using IdentityModel;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Cors;
|
|
|
|
@ -170,6 +172,20 @@ namespace MyCompanyName.MyProjectName
|
|
|
|
|
{
|
|
|
|
|
app.UseMultiTenancy();
|
|
|
|
|
}
|
|
|
|
|
app.Use(async (ctx, next) =>
|
|
|
|
|
{
|
|
|
|
|
var currentPrincipalAccessor = ctx.RequestServices.GetRequiredService<ICurrentPrincipalAccessor>();
|
|
|
|
|
var map = new Dictionary<string, string>()
|
|
|
|
|
{
|
|
|
|
|
{ "sub", AbpClaimTypes.UserId },
|
|
|
|
|
{ "role", AbpClaimTypes.Role },
|
|
|
|
|
{ "email", AbpClaimTypes.Email },
|
|
|
|
|
//any other map
|
|
|
|
|
};
|
|
|
|
|
var mapClaims = currentPrincipalAccessor.Principal.Claims.Where(p => map.Keys.Contains(p.Type)).ToList();
|
|
|
|
|
currentPrincipalAccessor.Principal.AddIdentity(new ClaimsIdentity(mapClaims.Select(p => new Claim(map[p.Type], p.Value, p.ValueType, p.Issuer))));
|
|
|
|
|
await next();
|
|
|
|
|
});
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
app.UseAbpRequestLocalization();
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|