MicroSvcs_Security
Security
Auth architecture revolution
Single server cookie based auth

Multi server sticky session based auth
- Cons: - Sticky session binds a session to a server. If the server goes down or needs to be maintained. 
- Sticky session needs to store session data in load balancer. 
 
- Possible solutions: - Session synchronization by replicating across web servers 
- Store session data completely inside users' browser - Cons: Limited size of cookie 
 
- Store session data in a shared storage 
 

Auth Service and token
- Pros: - Encapsulate everything related with token issuing 
- Introduce the concept of token, which could be passed around between services 
 
- Cons: - Services need to implement the logic to validate the token. 
- All services need to talk to authSvc, which might become a performance bottleneck. 
- All requests need to be verified via auth service. 
 

Gateway and token
- Pros: - Gateway centralizes the logic of parsing userInfo. Only gateway need to validate the token with auth service. 
 
- Cons: - All requests need to be verified via auth service. Auth service needs to be maintained and scaled in a manageable way. 
 

Gateway and JWT
- Pros: - Compact and lightweight 
- Low pressure on Auth server 
- Simplify the implementation of auth server 
 
- Cons: - Could not invalidate a JWT token if it has been leaked 
- JWT might become big 
 

Microservices security architecture
External access token internal JWT token
- Cons: Still rely on gateway to switch access token with JWT token. 

Encrypted JWT token
- Pros: Stateless token 

External access token internal JWT token with token cache
- Most widely used in practice 

Identity proxy with backend services
- Identity-aware proxy is a reverse proxy that allows either public endpoints or checks credentials for protected endpoints. If the credential is not presented but required, redirect the user to an identity provider. e.g. k8s ingress controller, nginx, envoy, Pomerium, ory.sh/oathkeeper, etc. 
- Identity provider and manager is one or a few services that manage the user identity through certain workflows like sign in, forgot password, etc. e.g. ory.sh/kratos, keycloak 
- OAuth2 and OpenID Connect provider enables 3rd-party developers to integrate with your service. 
- Authorization service controls who can do what. 

Real world examples
Auth at Netflix
- A talk on InfoQ: https://www.infoq.com/presentations/netflix-user-identity/ 
- Access control at Netflix: https://netflixtechblog.com/consoleme-a-central-control-plane-for-aws-permissions-and-access-fd09afdd60a8 
- Netflix container security: https://netflixtechblog.com/evolving-container-security-with-linux-user-namespaces-afbe3308c082 
- Netflix detect credential leak: https://netflixtechblog.com/netflix-cloud-security-detecting-credential-compromise-in-aws-9493d6fd373a 
- Netflix viewing privacy: https://netflixtechblog.com/protecting-netflix-viewing-privacy-at-scale-39c675d88f45 
Tianpan.co
- https://tianpan.co/#big-picture-authn-authz-and-identity-management 
An excellent blogger
- https://medium.com/@chamod.14_80003/token-caching-wso2-api-manager-5c5b3d6ddd09 
- https://www.pingidentity.com/en/company/blog/posts/2021/ultimate-guide-token-based-authentication.html 
Last updated
Was this helpful?