I'm writing an aspnet core 2.0 application. Using a bearer token authentication I have the User
property inside the controller with the correct identity. How can I access the User
property or the ClaimPrincipal
in the separated .net standard project for business logic?
ASP.NET Core project:
//ASP.NET Core project
public class DocumentController : Controller
{
public IActionResult Index()
{
System.Security.Claims.ClaimsPrincipal cp = User;
/* check for claims in ClaimsPrincipal */
DocumentBL docBL = new DocumentBL();
docBL.BLmethodForDocument();
return View();
}
}
Separated .net standard project: BL.dll
My ASP.NET Core project depends on BL.dll
//Separated project: BL.dll
public class DocumentBL
{
public void BLmethodForDocument()
{
System.Security.Claims.ClaimsPrincipal cp = ???????????
/* check for claims in ClaimsPrincipal */
//rest of business logic...
}
}
How can I fix the BLmethodForDocument to work with current ClaimsPrincipal
WITHOUT passing it to the bl method as parameter (and WITHOUT passing it to the DocumentBL constructor)?
Can not use System.Security.Claims.ClaimsPrincipal.Current
nor System.Threading.Thread.CurrentPrincipal
they are always null.