Enforcing authorization

Now that we can be sure that our JWT-based auth implementation is working as expected, we need to define some testable auth-based navigation patterns and access rules that will allow us to differentiate the logged-in user from the anonymous one, preventing the latter from either seeing and doing something that he shouldn't be allowed to. Needless to say, we need to handle them on the client side and also on the server side.

It's actually easy to do that, since we already have some Angular components that should be made accessible to authenticated users only and vice versa--along with the .NET Core controllers they use under the hood; let's see how we can pull off that task.

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.