Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass decoded JWT payload to micro services

We are changing our application authentification architecture to switch to Json Web Token.

Actually, incoming requests first pass through an API Gateway that dispatch requests to various micro services of our stack.

The authentification and verification of the JWT passed in each request is done in the Gateway.

After authentification what would you do with the JWT ?

  1. Pass it 'as it' to the subsequent micro services ?
  2. Decode it in the gateway and only pass the decoded payload to the services ?

I see pro and cons in both solutions:

  1. Pro: we keep a standard Authentification http header all the way. Cons: We have to decode the token in each service.

  2. Pro: Token is already decoded and directly usable in services. Cons: We must use a non standard http header to pass the decoded payload.

Is there any 'standard' way in that situation ?

What's your opinion ?

Thanks !

like image 436
Clement Avatar asked Nov 14 '25 15:11

Clement


1 Answers

Pass JWT as is. Overhead of decoding is negligible but you make your system a bit more secure in case your gateway is bypassed for some reason. Or maybe you decide in the future to directly communicate with your microservices.

like image 80
Konstantin Gusev Avatar answered Nov 17 '25 10:11

Konstantin Gusev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!