Identity and Access Management. Part 5: Microservices

Ishan Dhar
5 min readJul 21, 2023

--

In part 1 of this series we understood Authentication and Authorization.
In part 2 we understood “Identity Federation, Authentication Broker, and Identity Providers”.
In part 3 we understood about common Protocols.
In part 4we understood about API Authorization

Now lets talk about few concepts that are improtant if you have a Microservices type architecture.

Microservices and Identity & Authorization

In a microservices architecture, where applications are divided into smaller, independently deployable services, handling identity and authorization can be approached in different ways. Here are considerations and approaches related to identity and authorization within the context of microservices:

  1. Centralized Identity Provider: In many microservices architectures, it is common to have a centralized identity provider that manages user authentication, identity, and access control. This central identity provider acts as a single source of truth for user information, roles, and permissions. Applications reach out to the identity provider to authenticate users and obtain authorization decisions.
  • Benefits of a Centralized Identity Provider:
  • Single Point of Control: A centralized identity provider allows for centralized control over user management, roles, and permissions. Changes can be made in one place and propagate to all services.
  • Consistency: Having a single identity provider ensures consistent authentication and authorization policies across services, reducing the risk of inconsistencies or security gaps.
  • Simplified User Management: User management tasks, such as account creation, password resets, or role updates, can be handled in one place, simplifying administration and reducing duplication.
  • Examples of Centralized Identity Providers:
  • Keycloak: Keycloak is an open-source identity provider that supports various protocols such as OpenID Connect and SAML 2.0. It provides features like user authentication, authorization, and centralized user management.
  • Okta: Okta is a cloud-based identity provider that offers comprehensive identity and access management services, including authentication, single sign-on (SSO), and user lifecycle management.

2. Distributed User Databases: Alternatively, each microservice can have its own user database that contains user information, roles, and permissions specific to that service. This approach allows services to operate independently and reduces dependencies on a central identity provider.

Benefits of Distributed User Databases:

  • Service Isolation: Each service has autonomy over its user management, allowing for independent scaling and maintenance.
  • Reduced Dependencies: Microservices can operate even if the central identity provider is unavailable or experiencing issues.
  • Performance Optimization: By having local user databases, services can query user information more efficiently without relying on remote calls.

Considerations for Distributed User Databases:

  • Data Synchronization: Ensuring consistency and synchronization of user data across different microservices can be challenging. Care must be taken to update and synchronize user information appropriately.
  • Increased Complexity: Managing multiple user databases introduces additional complexity in terms of data consistency, backup, and recovery processes.

3. Hybrid Approach: A hybrid approach combines elements of both centralized and distributed approaches. A central identity provider handles user authentication, authorization, and overall user management, while individual microservices store additional service-specific information or permissions.

Benefits of a Hybrid Approach:

  • Centralized Control: The central identity provider ensures consistent authentication and global policies, while microservices have control over their specific service-related data or permissions.
  • Flexibility: Microservices can have specialized user attributes or permissions specific to their functionality, while still benefiting from centralized authentication and basic authorization decisions.

Considerations for a Hybrid Approach:

  • Data Consistency: Ensuring data consistency and synchronization between the central identity provider and microservices’ local databases can be challenging and requires careful design and synchronization mechanisms.
  • Complexity: The hybrid approach introduces additional complexity in managing the integration between the central identity provider and microservices’ user databases.

The choice between a centralized identity provider or distributed user databases depends on the specific requirements, scalability needs, and complexity trade-offs of the microservices architecture. Centralized identity providers offer simplicity, consistency, and centralized control but may introduce dependencies and potential performance bottlenecks. Distributed user databases offer service autonomy and performance optimization but may require additional effort to synchronize and manage user data across services.

Policy Enforcement

Policy Enforcement refers to the process of enforcing access control policies and ensuring that they are applied consistently and accurately within an organization’s systems and applications. It involves validating user requests, evaluating the defined policies, and making access decisions based on the policy rules. Policy enforcement can occur within the application itself or through external mechanisms. Here’s an elaboration on application-level and external policy enforcement:

  1. Application-Level Policy Enforcement: In application-level policy enforcement, access control policies are implemented directly within the application’s code or configuration. The application itself handles the evaluation of policies and determines whether to allow or deny access to specific resources or functionalities. This approach offers fine-grained control over access decisions, as policies can be tailored to the specific requirements of the application. Application-level policy enforcement is typically implemented through frameworks or libraries that provide access control mechanisms.
  • Example: Within a web application, the code might include authorization rules that check a user’s role or permissions before granting access to certain pages or features. The application would handle the evaluation of these rules and enforce the access control policies accordingly.

2. External Policy Enforcement: In external policy enforcement, access control policies are managed and enforced by an external component or service. This decouples the access control logic from the application, allowing for centralized management and enforcement of policies across multiple applications or services. External policy enforcement typically involves a separate policy enforcement point, such as an API gateway, reverse proxy, or dedicated policy enforcement service.
Example: An organization may employ an API gateway that acts as a centralized entry point for API requests. The API gateway evaluates access control policies, such as checking OAuth 2.0 tokens or API key validity, and enforces policies such as rate limiting, authentication, and authorization before forwarding the request to the appropriate backend service.

It’s worth noting that application-level and external policy enforcement are not mutually exclusive and can be used together. In some cases, organizations may employ a hybrid approach, with certain policies enforced within the application itself, while others are managed and enforced externally. The choice of policy enforcement approach depends on factors such as the complexity of the access control requirements, the scale of the system, and the need for centralized policy management and enforcement.

--

--