Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building Microservices with Micronaut®

You're reading from   Building Microservices with Micronaut® A quick-start guide to building high-performance reactive microservices for Java developers

Arrow left icon
Product type Paperback
Published in Sep 2021
Publisher Packt
ISBN-13 9781800564237
Length 362 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Zack Dawood Zack Dawood
Author Profile Icon Zack Dawood
Zack Dawood
Nirmal Singh Nirmal Singh
Author Profile Icon Nirmal Singh
Nirmal Singh
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Preface 1. Section 1: Core Concepts and Basics
2. Chapter 1: Getting Started with Microservices Using the Micronaut Framework FREE CHAPTER 3. Section 2: Microservices Development
4. Chapter 2: Working on Data Access 5. Chapter 3: Working on RESTful Web Services 6. Chapter 4: Securing the Microservices 7. Chapter 5: Integrating Microservices Using Event-Driven Architecture 8. Section 3: Microservices Testing
9. Chapter 6: Testing Microservices 10. Section 4: Microservices Deployment
11. Chapter 7: Handling Microservice Concerns 12. Chapter 8: Deploying Microservices 13. Section 5: Microservices Maintenance
14. Chapter 9: Distributed Logging, Tracing, and Monitoring 15. Section 6: IoT with Micronaut and Closure
16. Chapter 10: IoT with Micronaut 17. Chapter 11: Building Enterprise-Grade Microservices 18. Assessment 19. Other Books You May Enjoy

Using JWT authentication to secure the service endpoints

In token-based authentication, the user state is stored at the client side. When a client logs in to the server, the server encrypts the user data into a token with a secret and sends it back to the client. Any subsequent user requests must have this token set in the request header. The server retrieves the token, validates the authenticity, and resumes the user session:

Figure 4.9 – Token-based authentication

As shown in the preceding diagram, in a token-based authentication strategy, the client does the heavy lifting of keeping track of the session in the JSON web token. A client must provide a valid token to resume the session.

To learn how to secure a microservice using token-based authentication, we will work on a hands-on pet-clinic microservice. To begin, we will set up a third-party identity provider using Keycloak. In the next section, we will set up Keycloak locally.

Setting up...

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 €18.99/month. Cancel anytime