Skip to content

Instantly share code, notes, and snippets.

@trailmax
Created June 16, 2017 21:52
Show Gist options
  • Save trailmax/8dd0064e7a1a178a2060c1709e77fb64 to your computer and use it in GitHub Desktop.
Save trailmax/8dd0064e7a1a178a2060c1709e77fb64 to your computer and use it in GitHub Desktop.
AspNetPrincipalProxy
// Defers the use of runtime data after object graph construction
// see: https://www.cuttingedge.it/blogs/steven/pivot/entry.php?id=99
public sealed class AspNetPrincipalProxy : IPrincipal
{
public IIdentity Identity => User.Identity;
public bool IsInRole(string role) => User.IsInRole(role);
private IPrincipal User => HttpContext.Current.User;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment