Skip to content

Instantly share code, notes, and snippets.

@andineck
Last active January 20, 2024 21:20
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 15 You must be signed in to fork a gist
  • Save andineck/0ed33faf686560f71234 to your computer and use it in GitHub Desktop.
Save andineck/0ed33faf686560f71234 to your computer and use it in GitHub Desktop.
Authentication and Authorization Concepts for MicroServices

auth with microservices

Authorization and Authentication are hard. when you only have to implement them once (as you do within a monolith) instead of over and over again, it makes the developer happy :-), and maybe leads to less implementation failures.

When you have a bunch of microservices, this is something that has to be considered.

Implement it once or in every microservice, or something in between?

approach 1

do authentication and authorization in every microservice

pros

  • makes developer happy :)
  • less implementation errors
  • less risk of forgetting to handle at all
  • centrally defined and handled
  • smaller micro services
  • less repetition in the code in the micro services

cons

  • service can not have fine grained object permissions
  • all or nothing authorization
  • global auth bottleneck

approach 2

do authentication globally, and authorization in every microservice

pros

  • global authentication is easier to manage/control
  • fine grained object permissions are possible

cons

  • slightly more code in the micro services
  • needs some effort to have an overview what you can do with which permission

approach 3

do authentication in every microservice, and authorization globally

is listed only for completeness. it does not make sense -> worst of both worlds.

no fine grained object permissions and error prone and tedious repetitive authentication

approach 3

do authentication and authorization in every microservice

pros

  • fine grained object permissions are possible
  • different user authentication mechanisms are possible for different microservices

cons

  • error prone
  • many repetitions
  • bigger micro services
  • needs some effort to have an overview what you can do with which permission
  • no happy developer :-(

links

@memphys
Copy link

memphys commented Apr 7, 2016

Titles of the first and the last approaches are the same. I believe the first one is about doing it all globally. And there are two of "approach 3" :)

@nezygis
Copy link

nezygis commented Sep 3, 2016

approach 3 is mentioned twice...

@vmwinckler
Copy link

The Second "approach 3" is "approach 4".. ok but ... duplicated too:

approach 1 -> do authentication and authorization in every microservice
approach 3 -> do authentication and authorization in every microservice

@aehlke
Copy link

aehlke commented Oct 13, 2017

I think approach 1 is supposed to be "do authentication and authorization globally"

@nurgasemetey
Copy link

Approach 5
Istio proxy sidecar with JWT. No security code in microservices

@EtachGu
Copy link

EtachGu commented Jan 12, 2019

So, Which one is the best practices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment