How bmf-san/poc-opa-access-control-system works
Main Components
• External Clients: Representing users or services sending requests.
• Policy Enforcement Point (PEP): Acts as a reverse proxy (see cmd/pep and its corresponding Dockerfile) that intercepts requests from external clients.
• Policy Decision Point (PDP): This is the component that evaluates OPA policies (found in cmd/pdp along with Rego policy files such as main.rego, rbac.rego). It decides whether a request is permitted.
• Application Service (Employee): The business application (cmd/employee) that actually processes requests once authorization is granted.
• Policy Information Point (PIP): Although briefly mentioned through cmd/pip, it can be treated as an additional service for providing or integrating supplemental policy information.
• Databases: There are two primary database components—one for employee data (docs/db/employee, postgres/employee) and one for PRP data (docs/db/prp, postgres/prp)—storing resources like roles, permissions, and user details.
Out Relationships & Workflow
• The client initiates a request (HTTP) that first reaches the PEP service.
• The PEP intercepts the request, performs initial validation (e.g., checking for the “X-User-ID” header), and then consults the PDP for an access decision by sending data for policy evaluation.
• The PDP uses the Rego policies to compute whether the request should be allowed.
• If permitted, the request is forwarded from the PEP to the Employee service. Otherwise, an appropriate error (403 or 400) is returned.
• Optionally, PIP may be involved if additional policy data or context is required.
• Both the Employee and PRP databases are referenced: the Employee database supports the business service, while the PRP database likely holds configuration for roles, permissions, and resource access mappings.
Architectural Patterns & Design Principles
• Separation of Concerns: Business logic is separated from authorization logic.
• Proxy-based Enforcement: The use of a dedicated PEP that intercepts and enforces policies before reaching the main application.
• Microservices: Each service (employee, pdp, pep, pip) is built, tested, and deployed independently, using Docker containers and managed via Docker Compose.
• Centralized Policy Management: All policy-related concerns are handled by PDP and defined using Rego, aiding versioning and centralized rule management.
Final Recommendations
• Client ➔ PEP (validates headers and routes requests)
• PEP ➔ PDP (for policy decision)
• PDP ➔ PEP (returns decision)
• PEP ➔ Employee Service (for valid requests)