Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Claims Transformation and Authorization Policy in ASP.NET Core

$
0
0

please have a look at this url first https://weblogs.asp.net/imranbaloch/claims-transformation-and-authorization-policy-in-aspnet5-mvc6

public virtual Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
{
if (principal.Identity.IsAuthenticated)
{
// get this from cache or db
var country = "Pakistan";
(principal.Identity as ClaimsIdentity).AddClaim(new Claim("Nationality", country));
}
return Task.FromResult(principal);
}

when TransformAsync() will be called.......how to use it ?

[Authorize(Policy = "MustBePakistani")]
	public IActionResult Message()
	{
	    return Content("Hi Pakistani");
	}

when Message action will be called then how asp.net mvc system will be able to understand what is user's nationality.....is it pakistani or indian ?

guide me how does it work. thanks


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>