0
0
Microservicessystem_design~12 mins

Role-based access control in Microservices - Architecture Diagram

Choose your learning style9 modes available
System Overview - Role-based access control

This system manages user permissions based on their roles. It ensures users can only access resources allowed by their assigned roles. The system must be scalable, secure, and support multiple microservices enforcing access control consistently.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+----------------+       +---------------------+
| Auth Service   |<----->| Role Management      |
| (Token Issuer) |       | Service              |
+----------------+       +---------------------+
        |
        v
+----------------+
| Microservice A |
+----------------+
        |
        v
+----------------+
| Database       |
+----------------+

Cache (Redis) connected to Auth Service and Role Management Service for fast role lookup
Components
User
actor
End user who sends requests with credentials
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Entry point that routes requests to appropriate microservices and enforces initial authentication
Auth Service
service
Authenticates users and issues tokens containing role claims
Role Management Service
service
Manages roles and permissions, provides role data to other services
Microservice A
service
Business logic service that enforces role-based access control on requests
Database
database
Stores user data, roles, permissions, and application data
Cache
cache
Stores role and permission data for fast access to reduce database load
Request Flow - 18 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayAuth Service
Auth ServiceCache
CacheAuth Service
Auth ServiceRole Management Service
Role Management ServiceDatabase
DatabaseRole Management Service
Role Management ServiceCache
Role Management ServiceAuth Service
Auth ServiceAPI Gateway
API GatewayMicroservice A
Microservice AAuth Service
Microservice ADatabase
DatabaseMicroservice A
Microservice AAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Cache
Impact:Role and permission lookups become slower as requests go directly to the database, increasing latency and load on the database.
Mitigation:System continues to function correctly by querying Role Management Service and database. Cache can be restored or replaced without downtime.
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for issuing tokens containing user roles?
AAPI Gateway
BAuth Service
CRole Management Service
DLoad Balancer
Design Principle
This architecture demonstrates separation of concerns by isolating authentication, role management, and business logic into distinct microservices. It uses caching to improve performance and scalability while ensuring secure role-based access control across services.