I have an API that uses Identity Server 4 for User Authentication based on JWT Bearer Access Token.
Now when I Pass in the access_token
in my request header I can view the User Details in the User Object in the Controller.
But if I try to access the System.Security.Claims.ClaimsPrincipal
in my DAL it is different to my logged in user.
This is how I configured Authentication for Identity Server 4 in my Web Project Startup.cs
In ConfigureServices -
services.AddAuthentication("Bearer").AddIdentityServerAuthentication(opt =>
{
opt.Authority = "http://auth......";
opt.RequireHttpsMetadata = true;
opt.ApiName = "API_NAME";
opt.NameClaimType = "username";
});
In Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
#region Identity Server Config
// Setup Identity Server Options for this API -
app.UseAuthentication();
#endregion Identity Server Config
.....
}
How do I access my logged in Identity Server user in the DAL?