Book Image

ASP.NET Core 2 and Vue.js

By : Stuart Ratcliffe
5 (1)
Book Image

ASP.NET Core 2 and Vue.js

5 (1)
By: Stuart Ratcliffe

Overview of this book

This book will walk you through the process of developing an e-commerce application from start to finish, utilizing an ASP.NET Core web API and Vue.js Single-Page Application (SPA) frontend. We will build the application using a featureslice approach, whereby in each chapter we will add the required frontend and backend changes to complete an entire feature. In the early chapters, we’ll keep things fairly simple to get you started, but by the end of the book, you’ll be utilizing some advanced concepts, such as server-side rendering and continuous integration and deployment. You will learn how to set up and configure a modern development environment for building ASP.NET Core web APIs and Vue.js SPA frontends.You will also learn about how ASP.NET Core differs from its predecessors, and how we can utilize those changes to our benefit. Finally, you will learn the fundamentals of building modern frontend applications using Vue.js, as well as some of the more advanced concepts, which can help make you more productive in your own applications in the future.
Table of Contents (15 chapters)

Extending the authentication endpoint with user roles

The current implementation of our authentication API endpoint already adds the users' roles to the JWT token in the form of claims. This is all we needed to do in order to support role-based authorization on the server side of the application, as ASP.NET Identity automatically decodes the JWT for us so that the claims we added are available on the HttpContext.User.Identity claims principle object.

However, on the client side of our application, those claims are still encoded into the JWT and we cannot access them without decoding it. This isn't a huge issue, and we could certainly bring in a new npm package that would be able to decode a JWT for us, but we don't really need to. Instead, what we'll do is return the list of roles a user is assigned to as part of the view model we send back to the client when...