pull/2238/head
Yunus Emre Kalkan 6 years ago
commit e29c495798

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
@ -52,14 +55,6 @@ namespace BackendAdminAppGateway.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -94,6 +89,22 @@ namespace BackendAdminAppGateway.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseSwagger();
app.UseSwaggerUI(options =>
{

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
@ -41,14 +44,6 @@ namespace InternalGateway.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -83,6 +78,22 @@ namespace InternalGateway.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseSwagger();
app.UseSwaggerUI(options =>
{

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using Ocelot.DependencyInjection;
@ -39,14 +42,6 @@ namespace PublicWebSiteGateway.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -81,6 +76,22 @@ namespace PublicWebSiteGateway.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseSwagger();
app.UseSwaggerUI(options =>
{

@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
@ -57,14 +60,6 @@ namespace BloggingService.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -113,6 +108,22 @@ namespace BloggingService.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
@ -44,14 +47,6 @@ namespace IdentityService.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -95,6 +90,22 @@ namespace IdentityService.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>

@ -1,4 +1,7 @@
using Microsoft.AspNetCore.Builder;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.DependencyInjection;
using ProductManagement;
@ -46,14 +49,6 @@ namespace ProductService.Host
options.Authority = configuration["AuthServer:Authority"];
options.ApiName = configuration["AuthServer:ApiName"];
options.RequireHttpsMetadata = false;
//TODO: Should create an extension method for that (may require to create a new ABP package depending on the IdentityServer4.AccessTokenValidation)
//options.InboundJwtClaimTypeMap["sub"] = AbpClaimTypes.UserId;
//options.InboundJwtClaimTypeMap["role"] = AbpClaimTypes.Role;
//options.InboundJwtClaimTypeMap["email"] = AbpClaimTypes.Email;
//options.InboundJwtClaimTypeMap["email_verified"] = AbpClaimTypes.EmailVerified;
//options.InboundJwtClaimTypeMap["phone_number"] = AbpClaimTypes.PhoneNumber;
//options.InboundJwtClaimTypeMap["phone_number_verified"] = AbpClaimTypes.PhoneNumberVerified;
//options.InboundJwtClaimTypeMap["name"] = AbpClaimTypes.UserName;
});
context.Services.AddSwaggerGen(options =>
@ -97,6 +92,22 @@ namespace ProductService.Host
app.UseVirtualFiles();
app.UseRouting();
app.UseAuthentication();
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.UseAbpRequestLocalization(); //TODO: localization?
app.UseSwagger();
app.UseSwaggerUI(options =>

Loading…
Cancel
Save