ASP.NET Core policy-based authorisation using JSON Web Tokens

Introduction In this post, I am going to demonstrate how JSON Web Tokens (JWTs) can be used in conjunction with ASP.NET Core's new policy-based authorisation model to easily control user access to your Web API controllers and methods. Note: this is a very long tutorial so if you are comfortable working through source code and figuring things out for yourself …

Issuing and authenticating JWT tokens in ASP.NET Core WebAPI – Part II

Introduction This post is the second part of an example of how you can issue JWT tokens with ASP.NET Core 1 and automatically control access to bearers through the simple application of an [Authorize] attribute (specifically focusing on claims-based authorisation using ASP.NET Core MVC's policy features) in a Web API project. Part I addressed how you could issue the …

Issuing and authenticating JWT tokens in ASP.NET Core WebAPI – Part I

Introduction If you'd like to see an example of how you can issue JWT tokens with ASP.NET Core 1 and automatically control access to bearers through the simple application of an [Authorize] attribute (specifically focusing on claims-based authorisation using ASP.NET Core MVC's policy features) in a Web API project, then you are in the right place! …

Mocking DependencyResolver

This may be known to some of you, but I’d never had to do this before, so I thought I’d share. I had some MVC 4 code that explicitly calls the System DependencyResolver (the application uses Unity for dependency injection) to retrieve a service: https://gist.github.com/williamhallatt/751e26ee1ed64b51ea1648eff776c56a Mocking (in this case) the ISomeOtherService is obviously a trivial matter …