Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
ASP.NET Core 2 and Angular 5

You're reading from   ASP.NET Core 2 and Angular 5 Full-stack web development with .NET Core and Angular

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788293600
Length 550 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Valerio De Sanctis Valerio De Sanctis
Author Profile Icon Valerio De Sanctis
Valerio De Sanctis
Jürgen Gutsch Jürgen Gutsch
Author Profile Icon Jürgen Gutsch
Jürgen Gutsch
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Ready 2. Backend with .NET Core FREE CHAPTER 3. Frontend with Angular 4. Data Model with Entity Framework Core 5. Client-Server Interactions 6. Style Sheets and UI Layout 7. Forms and Data Validation 8. Authentication and Authorization 9. Advanced Topics 10. Finalization and Deployment

Implementing JWT authentication


In order to handle JWT-based token authentication, we need to properly set up the ASP.NET Core Identity service to ensure that it will handle these tasks:

  • Generate a JWT token upon each username/password POST request coming from our clients
  • Validate any JWT token coming with HTTP requests by looking at the headers of the request itself

That said, the first thing to do is define the required steps we need to take care of:

  1. Add and configure the authentication service in the Startup.cs file.

  2. Update the appsettings.json and appsettings.Development.json files to store the required JWT security information (issuer and security key).

  3. Create a TokenController that will accept POST requests carrying the user credentials (username and password), validate them, and generate JWT tokens accordingly.

  4. Create an Angular LoginComponent with a Model-Driven login form to allow our users to perform the login.

  5. Create an Angular AuthService that will handle login/logout and store the JWT...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image