The payload model
The payload model is the model that is generated out of the JWT that we might receive. The model comes with the SimpleJWTMiddleware, so we do not need to define it ourselves here. The code is covering the same fields as the payload from our UMS from Chapter 7, Writing the User Service. Naturally, the JWT that the other service creates needs to correspond to what we are getting here. The SimpleJWTMiddleware will then call the verify function. Because we only need JWT for administrators in this service, we check the status of the user, and if it is not 1 (which means an admin user) we will throw an error. This is effectively protecting the service from any non-admin users changing products.
And that is it! We have created ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access