Reader small image

You're reading from  Hands-On Enterprise Java Microservices with Eclipse MicroProfile

Product typeBook
Published inAug 2019
Reading LevelExpert
PublisherPackt
ISBN-139781838643102
Edition1st Edition
Languages
Right arrow
Authors (6):
Cesar Saavedra
Cesar Saavedra
author image
Cesar Saavedra

Cesar Saavedra has been working in the IT industry since 1990 and holds a Master of Science degree in Computer Science and a Master of Business Administration. He has worked as a developer, consultant, technical seller, and technical marketer throughout his career. He currently does technical product marketing for Red Hat JBoss Enterprise Application Platform (EAP), Eclipse MicroProfile, OpenJDK, Quarkus and Jakarta EE. He also manages the technical marketing for the runtimes, integration, BPM and rules management portfolio, and works closely with engineering and product management on thought leadership. Cesar has authored white papers, eBooks, and blogposts, and has been a conference and webinar speaker presenting to customers and partners.
Read more about Cesar Saavedra

Heiko W. Rupp
Heiko W. Rupp
author image
Heiko W. Rupp

Heiko W. Rupp is an open source enthusiast working for more than a decade at Red Hat in the area of middleware monitoring and management. In this role he has been project lead of the RHQ and Hawkular monitoring systems and has also been contributing to various other projects like Kiali. Currently he helps defining the next way of Java Microservices with his work on Eclipse MicroProfile. As such he is the spec lead of the Eclipse MicroProfile Metrics effort and also contributing to other specifications. Heiko has written the first German book about JBossAS and one of the first German books on EJB3. He lives with his family in Stuttgart, Germany.
Read more about Heiko W. Rupp

Jeff Mesnil
Jeff Mesnil
author image
Jeff Mesnil

Jeff Mesnil is employed by Red Hat as a Senior Software Engineer and currently, works for JBoss, Red Hat's middleware division, on the WildFly and JBoss EAP application servers. He is a member of the core team in charge of developing the internals of the application servers and lead its messaging subsystem (which provides the JMS API). Previously, he contributed to the HornetQ messaging broker that was integrated into WildFly and EAP. He is a proponent of Open Source development and all the code he writes either professionally or privately is available under Open Source licenses, these days, it is mostly hosted on GitHub. He has a keen interest on messaging systems and wrote several Open Source libraries related to messaging.
Read more about Jeff Mesnil

Pavol Loffay
Pavol Loffay
author image
Pavol Loffay

Pavol Loffay is Senior Software Engineer at Red Hat. Pavol is working on observability tools for microservice architectures. He is mostly involved in the tracing domain, where he is an active committer on the Jaeger and OpenTracing projects. He is also a member of the OpenTracing Specification Council (OTSC) and a lead for the MicroProfile-OpenTracing specification. He has authored many blog posts and presented at several conferences. In his free time, Pavol likes to climb mountains and ski steep slopes in the Alps.
Read more about Pavol Loffay

Antoine Sabot-Durand
Antoine Sabot-Durand
author image
Antoine Sabot-Durand

Antoine Sabot-Durand is a Java Champion who works for Red Hat where he leads the Java EE, now Jakarta EE CDI spec. He is also involved in various projects linked to the CDI ecosystem, MicroProfile, and Jakarta EE. He is also Member of Devoxx France committee. He lives in France with his wife and 3 kids.
Read more about Antoine Sabot-Durand

Scott Stark
Scott Stark
author image
Scott Stark

Scott Stark started in chemical engineering, got steered into parallel computers as part of his Ph.D. work, and then made software his career, starting with a stint in finance/wall street. He then got into open source with the fledgling JBoss company, working on the application server and Java EE. He has worked with microkernel efforts, IoT efforts, standards, Jakarta EE, Eclipse MicroProfile and Quarkus. He lives in the Pacific Northwest with his wife.
Read more about Scott Stark

View More author details
Right arrow

MicroProfile Health Check and JWT Propagation

In this chapter, we will introduce the MicroProfile Health Check and JSON Web Token (JWT) Propagation projects. The Health Check project is concerned with exposing the application-defined health to the outside world, and JWT Propagation is concerned with defining an interoperable security token and use of that token in an application. In this chapter, you will learn the concerns that these specifications address, their constructs, and how to use them in your application. The code snippets throughout this chapter are for reference only. If you would like a working code version of this specification, please refer to Chapter 8, A Working Eclipse MicroProfile Code Sample.

We will cover the following topics:

  • What a health check is
  • How MicroProfile Health Check exposes the health check endpoint and the format of a query to that endpoint...

Technical requirements

Understanding health checks and how MicroProfile handles them

In cloud-native architectures, health checks are used to determine whether a computing node is alive and ready to perform work. The concept of readiness describes the state when containers start up or roll over (that is, redeployment). During this time, the cloud platform needs to ensure that no network traffic is routed to that instance before it is ready to perform work.

Liveness, on the other hand, describes the state of a running container; that is, can it still respond to requests? If either the liveness or readiness states are seen as invalid, the computing node will be discarded (terminated or shut down) and eventually replaced by another, healthy, instance.

Health checks are an essential contract with the orchestration framework and scheduler of the cloud platform. The check procedures are provided by the application...

Using JSON Web Token Propagation in MicroProfile

A JSON Web Token (JWT) is a common format for carrying security information that is used by many different web-based security protocols. However, there is a lack of standardization around exactly what the contents of the JWT are and what security algorithms are used with signed JWTs. The MicroProfile JWT (MP-JWT) Propagation project specification looked at the OpenID Connect (OIDC)-based (http://openid.net/connect/) JWT (https://tools.ietf.org/html/rfc7519) specifications and built upon those to define a set of requirements to promote interoperability of JWTs for use in MicroProfile-based microservices, along with APIs to access information from the JWTs.

For a description of how OIDC and JWT work, including how an application/microservice intercepts bearer tokens, please refer to the Basic Client Implementer's Guide at http...

Summary

In this chapter, we learned about the MicroProfile Health Check and JWT Propagation projects. You should now understand what a health check is and how to add application-specific checks, known as procedures. These allow your microservice to describe its non-trivial health requirements in a cloud environment. You should also understand how JWTs can be used to provide an authentication and authorization capability on top of your microservices to control access to your endpoints. You should also understand how content from the JWT can be used to augment your microservice in user-specific ways.

The next chapter will introduce the MicroProfile Metrics and OpenTracing features. These allow your microservices to provide additional information regarding common and application metrics and to trace the interactions between microservices.

...

Questions

  1. Is the MP-HC wire format useful in all environments?
  2. Can an MP-HC response contain arbitrary properties?
  3. What if my application has different types of services that need to report health status?
  4. What is a JWT?
  5. What is a claim?
  6. Are there restrictions on what can be in a JWT?
  7. What is/are the main step(s) in authenticating a JWT?
  8. Beyond the security annotations, how might we perform an authorization check using JWTs?
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Enterprise Java Microservices with Eclipse MicroProfile
Published in: Aug 2019Publisher: PacktISBN-13: 9781838643102
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.
undefined
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 $15.99/month. Cancel anytime

Authors (6)

author image
Cesar Saavedra

Cesar Saavedra has been working in the IT industry since 1990 and holds a Master of Science degree in Computer Science and a Master of Business Administration. He has worked as a developer, consultant, technical seller, and technical marketer throughout his career. He currently does technical product marketing for Red Hat JBoss Enterprise Application Platform (EAP), Eclipse MicroProfile, OpenJDK, Quarkus and Jakarta EE. He also manages the technical marketing for the runtimes, integration, BPM and rules management portfolio, and works closely with engineering and product management on thought leadership. Cesar has authored white papers, eBooks, and blogposts, and has been a conference and webinar speaker presenting to customers and partners.
Read more about Cesar Saavedra

author image
Heiko W. Rupp

Heiko W. Rupp is an open source enthusiast working for more than a decade at Red Hat in the area of middleware monitoring and management. In this role he has been project lead of the RHQ and Hawkular monitoring systems and has also been contributing to various other projects like Kiali. Currently he helps defining the next way of Java Microservices with his work on Eclipse MicroProfile. As such he is the spec lead of the Eclipse MicroProfile Metrics effort and also contributing to other specifications. Heiko has written the first German book about JBossAS and one of the first German books on EJB3. He lives with his family in Stuttgart, Germany.
Read more about Heiko W. Rupp

author image
Jeff Mesnil

Jeff Mesnil is employed by Red Hat as a Senior Software Engineer and currently, works for JBoss, Red Hat's middleware division, on the WildFly and JBoss EAP application servers. He is a member of the core team in charge of developing the internals of the application servers and lead its messaging subsystem (which provides the JMS API). Previously, he contributed to the HornetQ messaging broker that was integrated into WildFly and EAP. He is a proponent of Open Source development and all the code he writes either professionally or privately is available under Open Source licenses, these days, it is mostly hosted on GitHub. He has a keen interest on messaging systems and wrote several Open Source libraries related to messaging.
Read more about Jeff Mesnil

author image
Pavol Loffay

Pavol Loffay is Senior Software Engineer at Red Hat. Pavol is working on observability tools for microservice architectures. He is mostly involved in the tracing domain, where he is an active committer on the Jaeger and OpenTracing projects. He is also a member of the OpenTracing Specification Council (OTSC) and a lead for the MicroProfile-OpenTracing specification. He has authored many blog posts and presented at several conferences. In his free time, Pavol likes to climb mountains and ski steep slopes in the Alps.
Read more about Pavol Loffay

author image
Antoine Sabot-Durand

Antoine Sabot-Durand is a Java Champion who works for Red Hat where he leads the Java EE, now Jakarta EE CDI spec. He is also involved in various projects linked to the CDI ecosystem, MicroProfile, and Jakarta EE. He is also Member of Devoxx France committee. He lives in France with his wife and 3 kids.
Read more about Antoine Sabot-Durand

author image
Scott Stark

Scott Stark started in chemical engineering, got steered into parallel computers as part of his Ph.D. work, and then made software his career, starting with a stint in finance/wall street. He then got into open source with the fledgling JBoss company, working on the application server and Java EE. He has worked with microkernel efforts, IoT efforts, standards, Jakarta EE, Eclipse MicroProfile and Quarkus. He lives in the Pacific Northwest with his wife.
Read more about Scott Stark