Building a Fail-Closed Authorization Decision Engine with Go, PostgreSQL, Tenant Isolation, and Auditable Policy Management
An Open-Source Software Engineering Case Study
Author: Soroush Neyestani
Version: v0.1.0
Release Date: November 2026
License: MIT
Category: Security Engineering / Backend Architecture / Authorization Systems
Technology Stack: Go 1.27.4, PostgreSQL 18.7, OpenAPI 3.1, GitHub Actions
Source Repository: RBAC/ABAC Policy Engine on GitHub
Official Release: v0.1.0
Executive Summary
Authorization is one of the most consequential responsibilities of a software system.
An application may authenticate a user correctly and still expose sensitive information if its authorization rules are incomplete, inconsistent, or incorrectly enforced.
The problem becomes more complex when permissions depend on multiple factors: a user's role, the requested action, the target resource, the resource's classification, and the tenant to which it belongs.
A manager may be permitted to view confidential reports within one organization but must not automatically gain access to equivalent reports belonging to another organization.
Role-Based Access Control alone does not necessarily capture these restrictions.
Attribute-Based Access Control can express additional conditions, but it also introduces challenges involving trust, rule precedence, missing attributes, invalid policies, and changing authorization state.
To explore these challenges, I developed RBAC/ABAC Policy Engine, an open-source authorization decision engine implemented with Go 1.27.4 and PostgreSQL 18.7.
The project combines role-based permissions and typed attribute conditions within an explicitly fail-closed evaluation model.
Its fundamental principle is simple:
Access must be denied unless a valid, applicable authorization policy grants it.
The implementation includes:
- Role-Based Access Control (RBAC).
- Attribute-Based Access Control (ABAC).
- Typed equality and inequality conditions.
- Deny-by-default evaluation.
- Explicit DENY precedence.
- Tenant-scoped authorization.
- Trusted role and resource-attribute retrieval.
- Versioned policy management.
- Atomic policy activation and audit recording.
- Optimistic concurrency protection for policy updates.
- A versioned HTTP API documented with OpenAPI 3.1.
- Automated unit and PostgreSQL integration tests.
- Fuzz testing and Go race detection.
- Reproducible local authorization benchmarks.
- A public, checksum-verified source release.
The public v0.1.0 distribution passed 14 automated tests, including six PostgreSQL integration tests, along with 21 reported subtests, two fuzz targets, and the Go race detector.
Both the public main-branch CI and the official release-tag CI completed successfully.
A local synthetic HTTP/PostgreSQL benchmark evaluated 70,671 authorization decisions over eight connections at approximately 7,066 requests per second, with zero unexpected errors.
These results describe the tested implementation and environment. They are not production performance guarantees or proof of universal security.
The project is a focused authorization decision engine, not a complete identity provider, enterprise IAM platform, or security-certified product.
Its purpose is to demonstrate how authorization requirements can be translated into explicit security boundaries, deterministic evaluation semantics, database-backed policy management, and executable verification evidence.
1. The Authorization Problem
Authentication does not establish permission
Authentication answers a question:
Who is making this request?
Authorization answers a different question:
Is this principal permitted to perform this action on this resource under the current conditions?
An authenticated principal may have no permission to access a particular document, customer record, administrative operation, or API endpoint.
Consequently, validating a token is only the beginning of a secure access decision.
Why role checks become insufficient
Consider a simplified application that uses roles such as:
- Viewer
- Analyst
- Manager
- Administrator
A conventional role check might determine that a manager can read confidential reports.
But what happens if the report belongs to another organization?
If the system evaluates only the user's role, it may authorize access across a security boundary.
This is not necessarily a failure of role-based access control as a concept. It is a failure to incorporate the application's full authorization requirements into its decision model.
In a multi-tenant environment, the requested resource's tenant can be just as important as the user's role.
The core engineering questions
The project focuses on several related problems.
Role correctness: Does the user possess an authorized role for the requested operation?
Attribute correctness: Are the relevant conditions satisfied using trusted, correctly typed information?
Tenant isolation: Does the resource belong to the authorized security context?
Policy precedence: What happens when different applicable rules produce conflicting decisions?
Failure behavior: What happens when a required policy, attribute, or database record is missing?
Policy lifecycle: How are policy updates versioned, activated, and audited?
Concurrency: How are simultaneous administrative changes prevented from silently overwriting one another?
Enforcement: Who is responsible for actually preventing the protected operation?
Verification: How can these properties be tested rather than merely asserted?
These questions shaped the initial release.
2. Goals and Boundaries
The objective was to build a small, inspectable, and independently testable authorization decision service.
The release deliberately avoids turning the project into an oversized identity-management platform.
Implemented scope
Version v0.1.0 supports:
- Evaluation of role-based authorization rules.
- Evaluation of supported attribute-based conditions.
- Explicit ALLOW and DENY semantics.
- Denial when no valid authorization rule grants access.
- Tenant-aware authorization decisions.
- Retrieval of authorization-sensitive attributes from PostgreSQL.
- Versioned authorization policies.
- Policy activation with concurrency protection.
- Auditable policy changes.
- Administrative and evaluation APIs.
- Automated security and database tests.
Deliberate non-goals
The initial release does not provide a complete replacement for products such as enterprise identity providers or access-management suites.
It does not claim to include:
- Full user registration and account lifecycle management.
- Enterprise single sign-on.
- A complete OAuth/OIDC identity-provider implementation.
- Automated access-token lifecycle management.
- A universal policy programming language.
- Automatic enforcement inside external applications.
- Security certification.
- Formal mathematical proof of authorization correctness.
- Production-scale availability or performance guarantees.
These exclusions are important because an authorization decision engine has a distinct responsibility within a larger security architecture.
3. RBAC: Role-Based Access Control
Role-Based Access Control associates authorization decisions with the roles assigned to a principal.
Instead of assigning every permission individually to every user, the system evaluates whether the principal's role corresponds to the action permitted by an applicable policy.
For example, a read-oriented role might be permitted to retrieve certain reports but not modify them.
An administrative role may be authorized to perform additional operations within its defined scope.
What RBAC contributes
RBAC provides a relatively understandable mapping between organizational responsibilities and permitted operations.
Roles also offer a useful administrative abstraction.
A policy can refer to the intended responsibility rather than a collection of individual user identifiers.
What RBAC does not automatically solve
A role is not a complete security context.
Two users may hold equivalent roles in different organizations.
Their roles should not automatically be interchangeable across organizational boundaries.
Likewise, a permitted action may still require restrictions involving a resource's ownership, classification, or tenant.
For this reason, Transactional Ledger-style financial correctness and RBAC-style role correctness share a broader architectural principle: a single valid condition is not necessarily sufficient to establish overall correctness.
Authorization requires evaluation of all applicable constraints.
4. ABAC: Attribute-Based Access Control
Attribute-Based Access Control evaluates additional information associated with the principal, resource, or relevant environment.
For the initial release, the engine implements a constrained set of typed comparison operators:
eq— equality.neq— inequality.
These conditions are evaluated against the defined attribute representation.
Why typing matters
Authorization conditions must not depend on ambiguous or accidental comparisons.
An integer, Boolean value, and string should not be treated as interchangeable merely because their textual representations look similar.
Incorrect conversions can create authorization inconsistencies.
Typed evaluation reduces the risk that a malformed or unexpected attribute value silently satisfies a security-sensitive condition.
Why the supported language is deliberately small
A flexible authorization language can be powerful.
However, arbitrary expressions introduce complexity involving parsing, execution safety, type systems, evaluation determinism, and policy validation.
The v0.1.0 implementation uses a narrow, documented comparison model rather than claiming support for a general-purpose policy language.
This is a deliberate scope decision.
The smaller language is easier to inspect, test, and reason about.
Missing and invalid attributes
A missing required attribute must not be interpreted as a successful match.
Similarly, a condition that cannot be evaluated correctly must not become an implicit permission grant.
The implementation follows fail-closed semantics for these conditions.
The essential rule is:
Uncertainty in required authorization information must not create additional access.
5. The Trust Boundary: Where Authorization Data Comes From
One of the project's most important design choices concerns the source of authorization attributes.
The danger of caller-provided claims
Consider an authorization request that allows the caller to supply:
- Their own roles.
- Their own tenant membership.
- The requested resource's ownership.
- The resource's classification.
If the service treats those fields as authoritative, a malicious caller may be able to construct a request that satisfies the desired policy.
For example, changing a submitted tenant identifier could make a foreign resource appear to belong to the caller's organization.
This would undermine the authorization engine even if its rule evaluation logic were otherwise correct.
The implemented request boundary
The reported implementation accepts the relevant identifiers, requested action, and an optional policy version in its evaluation request.
It does not rely on arbitrary caller-supplied roles and protected resource attributes as the source of truth.
Instead, the engine resolves authorization-sensitive information from PostgreSQL within the tenant context associated with the request's authenticated token.
This separates the caller's request from the trusted data needed to evaluate that request.
Why this distinction matters
A user may legitimately choose which resource to request.
That does not mean the user should be able to define the resource's owner or security classification.
Similarly, a client may specify an action it wants to perform.
That does not mean it can assign itself the role required to perform that action.
The engine must evaluate the requested operation against independent, trusted authorization data.
Remaining trust assumptions
PostgreSQL is treated as the trusted source of the relevant authorization attributes.
This makes the integrity of those records, the database's access controls, and the correctness of the authenticated tenant context important parts of the security model.
The design does not eliminate every trust assumption.
It makes the assumptions explicit.
6. Tenant Isolation as a Mandatory Security Constraint
Tenant isolation is a central requirement of the implementation.
The motivating scenario is access to confidential reports belonging to different organizations.
Imagine two tenants:
Tenant A: An organization employing an authorized report manager.
Tenant B: Another organization with its own confidential reporting data.
An authorized manager from Tenant A must not be able to retrieve Tenant B's reports solely because the manager's role would permit access to similar reports within Tenant A.
Authorization matrix
| Tenant relationship | Role or policy conditions | Expected authorization |
|---|---|---|
| Authorized tenant | Sufficient conditions | Eligible for ALLOW under an applicable policy |
| Authorized tenant | Insufficient conditions | DENY |
| Foreign tenant | Sufficient role | DENY |
| Foreign tenant | Insufficient role | DENY |
| Unknown or invalid tenant context | Any role | No authorization grant |
The first row is deliberately described as eligible rather than unconditionally allowed.
A matching tenant and sufficient role must still satisfy all applicable policy requirements.
Why tenant checks must not be optional
A shared authorization library can become dangerous if applications inconsistently remember to check tenant ownership.
Centralizing the decision allows tenant boundaries to be evaluated according to a defined policy model.
However, centralizing the decision does not eliminate the responsibility of the consuming application to enforce it.
Verification evidence
The reported automated tests cover attempts to access confidential resources across tenant boundaries.
They also include forged authorization attributes and revoked access.
These scenarios are particularly valuable because they exercise situations that should be rejected.
A secure engine must demonstrate correct denials, not merely successful authorization of legitimate requests.
7. Deny by Default and Rule Precedence
Authorization policy evaluation must define what happens when no applicable permission exists.
Transactional business applications often handle missing data as an error.
Authorization systems must be more conservative: missing permission evidence must not create a grant.
Deny by Default
The engine implements a deny-by-default model.
The absence of an applicable valid permission does not authorize access.
This applies to conditions including:
- Missing policies.
- Invalid policies.
- Required attributes that cannot be validated.
- Incompatible policy versions.
- Unavailable required authorization data.
Explicit DENY precedence
The evaluator also defines precedence between applicable rules.
When a matching DENY rule conflicts with a matching ALLOW rule, the explicit denial takes priority.
This prevents an applicable restrictive rule from being defeated merely because another policy also grants permission.
Deterministic policy behavior
Security decisions should not depend on incidental implementation details such as the iteration order of a collection.
The evaluation model therefore needs explicitly defined precedence and matching semantics.
The project's fuzz testing includes rule-ordering inputs, helping examine behavior across varying rule arrangements.
This is practical verification evidence, not a mathematical proof that every possible policy combination has been explored.
Decision versus operational error
An explicit DENY caused by a valid policy is not necessarily equivalent to a failure to evaluate the policy.
Both must avoid granting access, but the operational meaning differs.
The service should preserve that distinction where relevant so the consumer can recognize a legitimate denial versus an unavailable authorization dependency.
8. Fail-Closed Behavior During Storage Failures
A critical scenario occurs when the engine cannot retrieve the information necessary to make an authorization decision.
For example, PostgreSQL may become unavailable.
At that moment, the engine cannot safely assume that an earlier permission is still valid.
The current policy may have changed.
The user's role may have been revoked.
The requested resource may have moved to a different authorization state.
The implemented behavior
The reported tests verify fail-closed behavior during storage failure.
The documented scenario returns an HTTP 503 response associated with a denied authorization outcome.
This is an important distinction:
A backend dependency failure must not be converted into an authorization grant.
Correct behavior for consumers
The application consuming the policy decision must not interpret an evaluation failure as permission to continue.
Otherwise, the authorization engine could be correctly designed while the surrounding application remains vulnerable.
The safe integration contract requires the consuming application to enforce only valid authorization grants.
An unavailable Policy Decision Point must not become an implicit ALLOW.
Availability versus security
Fail-closed behavior can reduce availability when the policy store is unavailable.
This is an explicit trade-off.
For protected operations, the alternative—granting access without adequate information—would violate the intended security model.
Production systems may consider additional availability mechanisms, but those mechanisms must preserve authorization freshness and correctness.
No such broader infrastructure guarantee is claimed for this reference release.
9. Policy Decision Point and Policy Enforcement Point
Authorization architecture separates two related responsibilities.
Policy Decision Point (PDP)
The Policy Decision Point evaluates the relevant inputs against applicable rules and produces an authorization decision.
RBAC/ABAC Policy Engine performs this role.
It is concerned with whether the requested action is permitted according to the trusted authorization context and policies.
Policy Enforcement Point (PEP)
The Policy Enforcement Point acts on the decision.
In a typical integration, the consuming application receives the decision and either allows the protected operation to proceed or rejects it.
This can happen in an API gateway, service handler, middleware component, or another enforcement layer.
Why the distinction matters
A correct ALLOW or DENY response is not enough if the consuming application ignores the result.
For example, an application could successfully call the policy engine and then continue processing even when access was denied.
That would be an enforcement failure outside the core decision logic.
Likewise, the application must ensure that the authorization request corresponds to the resource and action it actually executes.
Time-of-check/time-of-use risks
A decision can be valid when it is evaluated but become stale before the corresponding operation is performed.
Permissions may be revoked.
Resource ownership may change.
Other security-relevant state may be updated.
This interval between checking authorization and using the decision creates a time-of-check/time-of-use risk.
The initial release explicitly assigns enforcement and this integration risk to the consuming application.
The project does not claim to solve arbitrary cross-service atomic authorization.
10. Policy Versioning and Lifecycle Management
Authorization policy is not static.
Organizations change responsibilities, permissions, classifications, and access requirements over time.
A policy engine must therefore provide a controlled way to update authorization rules.
Why versioning matters
Without explicit versions, it may be difficult to determine which policy definition produced a particular decision.
Versioning also helps distinguish a published, active policy from a proposed modification.
The engine supports policy versions and controlled activation.
Active policy state
The reported implementation maintains versioned policy data and an active-version reference.
A policy activation operation updates the relevant state.
Atomic activation and audit recording
Policy activation involves multiple related database effects.
According to the implementation report, the following are committed atomically:
- The new policy version.
- The reference identifying the active version.
- The corresponding audit record.
This design avoids a state in which a policy appears to have been activated but the required audit record was not committed.
The transaction boundary is particularly important because administrative security changes should be traceable.
Why transactions are necessary
A partial policy update could create ambiguity.
For example, an active-version pointer might reference a policy version that was not correctly persisted.
Alternatively, an update might become active without the expected record of who changed it.
Coordinating the related writes within one PostgreSQL transaction reduces these risks for the supported workflow.
11. Concurrent Policy Updates and expected_revision
Policy administration is a stateful operation.
Two administrators or automated management processes may attempt to modify the same policy concurrently.
The lost-update problem
Suppose one administrator reads policy revision 12.
Another administrator modifies that policy and activates revision 13.
The first administrator then submits an update based on revision 12.
If the system accepts the update without checking the intervening change, the newer policy could be silently overwritten.
Optimistic concurrency protection
The implementation uses an expected_revision comparison.
The caller identifies the revision against which its intended change was prepared.
The system can reject a conflicting update if the current revision no longer matches that expectation.
Engineering benefit
Optimistic concurrency control does not prevent concurrent work.
Instead, it makes conflicting assumptions visible.
This is particularly useful for policy management because silently losing an administrative change can have security consequences.
What remains the caller's responsibility
A caller receiving a conflict must re-evaluate the current policy state before attempting another modification.
Blindly retrying an outdated policy update would defeat the purpose of revision checking.
12. Auditable Policy Changes
Authorization policies determine what users may do.
Changes to those policies are therefore security-sensitive events.
Why auditing is required
A useful administrative history should make it possible to investigate changes in authorization behavior.
For example:
- Which policy was modified?
- Which revision became active?
- When did the activation occur?
- Which administrative action caused the change?
- What version was previously active?
The specific stored fields are defined by the implementation and its database schema.
Transactional audit consistency
The initial release ties policy activation and audit recording to the same PostgreSQL transaction.
This makes the audit history part of the supported policy-management operation rather than an entirely independent best-effort side effect.
Audit immutability boundaries
The release documents audit-history protection within the permissions of the PostgreSQL environment.
This is not the same as cryptographic tamper-proofing.
A sufficiently privileged database administrator may be able to alter database objects, permissions, or historical records.
The project's security documentation explicitly recognizes this trust boundary.
Why this honesty matters
An audit log is useful only if its protection assumptions are understood.
Application-level append-only behavior and restricted database roles can improve audit integrity.
They do not automatically provide evidence that no privileged person could ever alter a record.
For stronger guarantees, independent retention or tamper-evident mechanisms would need to be designed and verified separately.
13. HTTP API and OpenAPI 3.1
The project exposes its supported operations through a versioned HTTP API.
The public API specification is documented using OpenAPI 3.1.
The reported contract includes six operations covering authorization evaluation, policy administration, version access, and audit inspection.
Why a formal contract matters
An authorization API is a security boundary.
Ambiguous request fields can create inconsistent assumptions about roles, tenants, resources, or policy versions.
A documented contract helps define:
- Required request identifiers.
- Supported actions.
- Optional version selection.
- Authentication requirements.
- Decision and error responses.
- Administrative operations.
- Invalid input behavior.
Contract validation
Both public CI runs reportedly validated the OpenAPI 3.1 definition against the official schema.
This provides evidence that the published API document conforms to the checked schema requirements.
Schema validation does not, by itself, prove that every runtime behavior matches the specification.
That requires separate endpoint and integration testing.
Avoiding undocumented assumptions
The implementation's exact endpoint paths, HTTP methods, request payloads, and response schemas should be taken directly from its published OpenAPI document.
This case study intentionally does not invent endpoint names or JSON fields that were not established by the supplied release evidence.
14. PostgreSQL as the Authorization Data Store
The database has two distinct roles in the architecture.
First, it provides the trusted persisted information used during authorization evaluation.
Second, it stores versioned policy-management and audit state.
Trusted authorization context
The engine resolves roles, ownership, and relevant attributes using PostgreSQL within the request's authenticated tenant context.
This reduces reliance on caller-provided security claims.
Policy persistence
Policy definitions and their versioning information are maintained as persistent state.
Administrative updates must preserve consistency between the stored policy version, its activation state, and audit records.
Database availability
Because authorization relies on trusted database information, storage failures can prevent the engine from issuing a valid grant.
The fail-closed policy makes this dependency explicit.
Database privileges
The PostgreSQL permission model is also part of the security boundary.
An application account should not be assumed to have the same privileges as the database owner.
Similarly, a protection that blocks normal application updates must not be described as impossible for privileged administrators to bypass.
This distinction is included in the project's documented limitations.
15. Automated Verification Strategy
Security-sensitive software requires tests that demonstrate correct denials as well as successful authorized operations.
The project uses both conventional automated tests and fuzzing.
Recorded automated test results
| Verification category | Reported result |
|---|---|
| Automated tests | 14 passed |
| PostgreSQL integration tests | 6 included in the 14 |
| Subtests | 21 reported |
| Fuzz targets | 2 passed |
| Go race detector | Passed |
| Public main CI | Passed |
| Public release-tag CI | Passed |
The subtests are reported separately from the top-level tests and should not be misrepresented as 21 additional independent top-level tests.
Security-focused scenarios
The reported test evidence covers:
Cross-tenant denial: A principal cannot access a confidential resource belonging to an unauthorized tenant merely by possessing a sufficient role.
Forged attributes: Untrusted caller data cannot substitute for trusted authorization attributes.
Revoked access: Relevant authorization changes are reflected in tested evaluation behavior.
Storage failure: Database unavailability must not produce an ALLOW decision.
Rule precedence: Explicit denial takes priority over an applicable permission grant.
Audit atomicity: Policy activation and its related audit record are committed consistently.
Administrative concurrency: Revision expectations prevent silent policy overwrites.
Why PostgreSQL integration tests matter
Mocked database behavior cannot establish all properties of real database transactions.
For example, tests that rely only on in-memory replacements cannot fully demonstrate PostgreSQL transaction atomicity or concurrent update behavior.
The inclusion of six real PostgreSQL integration tests is therefore significant.
They exercise database behavior that forms part of the project's architectural guarantees.
What the test suite does not prove
Passing 14 tests does not establish that all possible authorization states and hostile inputs have been covered.
The test suite provides reproducible evidence for specific behaviors and invariants.
That distinction is central to a technically credible security project.
16. Fuzz Testing and Rule Robustness
Conventional tests evaluate predefined examples.
Fuzz testing explores additional combinations of input data.
The initial release includes two fuzz targets:
- Policy rule ordering.
- JSON input handling.
Why rule-ordering fuzzing is valuable
Authorization results should follow documented policy precedence.
A change in rule order must not accidentally override an explicitly defined DENY-precedence rule.
Exploring varied rule arrangements can uncover assumptions that are not visible in a small collection of manually written examples.
Why JSON fuzzing is valuable
Authorization APIs receive structured input.
Malformed or unusual input can expose parser assumptions, validation problems, or unexpected behavior.
Fuzzing helps exercise conditions beyond common request examples.
Public CI results
| Fuzz target | Main branch CI | Release-tag CI |
|---|---|---|
| Rule ordering | 77,717 reported inputs | 82,029 reported inputs |
| JSON handling | 36,542 reported inputs | 59,782 reported inputs |
Both targets completed successfully in the reported public workflows.
What fuzzing establishes
These results show that the selected targets were exercised under the configured CI budgets without a reported blocking failure.
They do not prove the absence of every vulnerability.
Fuzz effectiveness depends on the scope of the targets, input generators, time budget, and assertions.
17. Go Race Detection
Concurrent systems can contain data races even when individual operations appear correct.
A data race occurs when concurrent access to shared state is not properly synchronized under the language's memory model.
Go provides race-detection tooling that can help identify such problems during execution.
The project's public CI includes successful execution of the Go race detector.
Why this matters
Authorization systems may receive simultaneous evaluation requests while other operations access shared policy-related state.
Testing concurrency behavior is important for reliability and correctness.
A necessary distinction
Passing the race detector does not prove that the system has no logical concurrency bugs.
For example, an implementation may be data-race-free while still using outdated authorization information or applying an incorrect policy revision.
Data-race detection and authorization correctness are separate verification concerns.
Both deserve attention.
18. Authorization Decision Performance
Performance is important for an authorization service because it may be consulted frequently by applications protecting their operations.
However, the cost of evaluating a policy depends on the number and complexity of rules, the data retrieval strategy, and the surrounding transport and storage operations.
The project records two categories of performance measurements.
In-process evaluation latency
The reported local results include:
| Policy workload | Approximate measured evaluation latency |
|---|---|
| 4 rules | 0.60 microseconds |
| 64 rules | 62.1–62.5 microseconds |
These are measurements of the in-process evaluation workload.
They should not be confused with the latency of a complete HTTP request involving PostgreSQL.
Interpretation
The more complex measured policy workload had substantially higher evaluation cost.
That difference illustrates why rule complexity and workload composition matter.
It does not establish a general complexity formula or predict performance for arbitrary policy sets.
A meaningful performance analysis must distinguish the implementation's actual evaluated operations from broader claims about asymptotic scalability.
19. HTTP and PostgreSQL Benchmark
The project also includes a local synthetic workload that measures authorization through the HTTP/database path.
Recorded results
| Metric | Value |
|---|---|
| Authorization decisions | 70,671 |
| Concurrent connections | 8 |
| Approximate throughput | 7,066 requests/second |
| Unexpected errors | 0 |
| p50 latency | 1.085 ms |
| p95 latency | 1.827 ms |
| p99 latency | 2.232 ms |
Latency percentiles
The p50 value represents the median measured latency.
The p95 value indicates that 95% of measured requests were at or below the reported latency threshold, under the benchmark's sampling method.
The p99 value captures a higher percentile of request latency.
These values provide more information than an average alone.
What this benchmark measures
Unlike in-process evaluation, this benchmark involves the local HTTP and PostgreSQL execution path.
Its latency therefore reflects a different measurement scope.
The two benchmark categories should not be presented as interchangeable.
Why zero unexpected errors matters
The test completed with zero reported unexpected errors.
This means the synthetic workload did not encounter unexpected failures under its recorded conditions.
It does not establish that the service will remain error-free under production traffic, larger policy sets, external networks, or different database configurations.
Benchmark limitations
The benchmark was local and synthetic.
Its results are influenced by factors such as:
- Hardware and operating system.
- PostgreSQL configuration.
- Policy and attribute data.
- Request distribution.
- Number of concurrent connections.
- Duration and execution conditions.
The repository's benchmark documentation provides the authoritative reproduction procedure and recorded environment details.
The published numbers should be treated as an engineering baseline, not as a service-level commitment.
20. Security Threat Model
The repository includes a documented threat model describing key attack surfaces and trust assumptions.
Role spoofing
A malicious client may attempt to claim a higher role than it possesses.
The engine's design addresses this risk by retrieving trusted role information rather than relying solely on caller-submitted role claims.
Attribute spoofing
A malicious client may attempt to supply resource ownership or classification data that satisfies a policy.
Trusted attribute retrieval is intended to prevent such claims from becoming authoritative.
Cross-tenant access
A principal may attempt to use legitimate permissions from one tenant against a resource belonging to another.
The project tests this denial behavior directly.
Unauthorized policy changes
Policy administration can change the permissions available to many users.
Consequently, policy-management access has a separate credential boundary.
Administrative security cannot be reduced to allowing every authenticated application client to modify policies.
Conflicting policy rules
Overlapping ALLOW and DENY rules can create ambiguity unless precedence is explicitly defined.
The initial release uses DENY precedence.
Malformed policy input
Unexpected policy conditions or missing information must not accidentally produce a successful evaluation.
The engine uses fail-closed behavior and a constrained set of supported typed operators.
Database failures
If trusted authorization state cannot be retrieved, the service must not grant access by assumption.
The reported storage-failure test verifies this behavior.
Administrative database access
The audit and data-integrity protections operate within documented PostgreSQL privilege boundaries.
Privileged database access remains a residual risk.
Enforcement failures
The engine returns authorization decisions.
A consuming application may still mishandle those decisions.
Such integration mistakes are outside the engine's complete control and must be addressed at the enforcement layer.
Credential lifecycle
Tokens are manually managed in the initial release.
The project does not claim advanced credential rotation, lifecycle automation, or enterprise identity integration.
21. Architectural Trade-offs
The implementation demonstrates several deliberate engineering choices.
A focused policy language instead of arbitrary expressions
Supporting only documented typed comparisons reduces the complexity of the evaluation model.
The trade-off is reduced policy expressiveness.
Additional operators would need explicit semantics, validation, and security testing.
Trusted database attributes instead of client-provided authorization state
Using PostgreSQL as the trusted attribute source reduces reliance on potentially forged request data.
The trade-off is a stronger dependency on correct database records, permissions, and availability.
Deny by Default instead of permissive fallback
Fail-closed behavior prioritizes security when the evaluator lacks sufficient information.
The trade-off is that a dependency failure may prevent legitimate operations until the issue is resolved.
Explicit DENY precedence instead of unspecified conflict handling
Defined precedence makes conflicting policy outcomes more predictable.
The trade-off is that policy authors must understand how restrictive rules interact with permissions.
Tenant-scoped evaluator instances
The reported deployment model configures each evaluator instance for one tenant.
This provides a focused operating boundary for the reference implementation.
The trade-off is that deployments supporting many tenants require an intentional instance-management strategy.
The initial release does not claim a single evaluator instance can safely serve arbitrary tenants without additional architecture.
Versioned policies and audit records instead of direct overwrites
Versioning and atomic activation improve administrative traceability.
The trade-off is greater complexity in persistence, revision handling, and policy-management workflows.
Optimistic revision checking instead of silent last-write-wins
The expected_revision mechanism reveals conflicting administrative updates.
The trade-off is that clients must handle revision conflicts and reconsider their intended changes.
Decision service instead of embedded enforcement
A separate Policy Decision Point can centralize policy evaluation.
The trade-off is that consuming applications must integrate the service correctly and enforce its results.
A central decision service does not automatically create a secure application.
22. Continuous Integration and Release Engineering
The project was published through an independent public source distribution.
The release process retained the approved implementation while separating public source history from internal development administration.
Public source identity
Release: v0.1.0
Public release commit:
4a8d985950862eb0978b7260ae7c5fcfdc1301ad
Public repository:
https://github.com/soroushneyestani/rbac-abac-policy-engine
Source archive
The public source package contains 37 files.
The reported publication verification confirmed that the source archive matched the release-tagged file inventory.
Source ZIP:
Published SHA-256:
48e741efc6ca07e2133e030db72263f6460ae7471c8bde2575dbd758c93d9c40
Checksum file:
https://github.com/soroushneyestani/rbac-abac-policy-engine/releases/download/v0.1.0/SHA256SUMS.txt
Public CI verification
The public distribution passed its main-branch and release-tag GitHub Actions workflows.
Main CI:
https://github.com/soroushneyestani/rbac-abac-policy-engine/actions/runs/45673136989
Release-tag CI:
https://github.com/soroushneyestani/rbac-abac-policy-engine/actions/runs/45673671688
Both workflows reportedly verified:
- Go build and automated tests.
- PostgreSQL integration tests.
- Fuzz targets.
- Race detection.
- OpenAPI 3.1 contract validation.
- Relevant source verification requirements.
Disclosure scanning
The public history was scanned with Gitleaks.
The reported scan returned zero findings.
This is useful evidence that the configured scan did not detect matching secrets in the reviewed history.
It is not proof that every possible security issue or sensitive value has been eliminated.
Branch and tag protection
The public repository's reported protection configuration requires pull requests, successful CI checks, and resolution of review conversations for the protected main branch.
Force-push and deletion protections are enabled.
The release tag is also protected against ordinary modification or deletion under the configured repository rules.
These controls help maintain stable references to the verified release.
They do not make GitHub or the underlying infrastructure cryptographically immutable.
Licensing
The original implementation is released under the MIT License.
The distribution also includes third-party dependency notices.
Cerbos served as a conceptual reference for the engineering topic.
The implementation uses its own policy format and API; native Cerbos compatibility is not claimed.
23. How to Review the Implementation
Developers interested in studying the project can evaluate it through several focused areas.
Authorization semantics
Start with the documented policy model.
Determine how roles, actions, and typed attributes combine to produce ALLOW or DENY.
Verify how explicit denials and missing information are handled.
Tenant boundaries
Review how the authenticated tenant context constrains trusted PostgreSQL lookups.
Pay particular attention to the difference between identifiers submitted by a client and authorization attributes retrieved from trusted storage.
Policy management
Examine how policy versions are created and activated.
Verify that the active version and its audit record participate in the same database transaction.
Review the expected_revision mechanism.
Integration contract
Inspect the published OpenAPI 3.1 specification.
Identify the supported evaluation and administrative operations, their input constraints, and their response semantics.
Negative security tests
Review tests where the correct result is denial:
- Foreign-tenant requests.
- Invalid attributes.
- Revoked access.
- Conflicting policy rules.
- Unavailable persistence.
- Unauthorized policy changes.
Fuzzing and concurrency
Inspect the rule-ordering and JSON fuzz targets.
Review the Go race-detector configuration and reported CI results.
Performance
Study the benchmark methodology before interpreting the published throughput and latency measurements.
Distinguish in-process evaluation from complete HTTP/database execution.
Threat boundaries
Read the threat model.
Evaluate what the engine protects directly, what it assumes about PostgreSQL and tokens, and what remains the responsibility of the consuming application.
24. Potential Future Development
The initial release is complete within its stated scope.
Several capabilities could be considered in future versions.
Broader identity integration
Support for managed credentials, identity-provider integration, or standards-based authentication could improve enterprise adoption.
Such functionality would require explicit design and security review.
Richer ABAC conditions
Additional operators and data types could expand the policy language.
Each addition would also increase the complexity of evaluation semantics and validation.
More flexible deployment models
Supporting multiple tenants within a single evaluator instance would require a carefully designed isolation model.
The current release does not claim this capability.
Policy simulation tools
Administrative tools could help evaluate proposed policy changes against synthetic scenarios before activation.
This could reduce the risk of unintended permission changes.
Enhanced audit protection
Independent, tamper-evident audit retention could provide stronger integrity guarantees than database permissions alone.
This would require a separate trust architecture.
Policy decision observability
Structured metrics, tracing, and carefully controlled decision diagnostics could improve operational understanding without exposing sensitive policy details.
Enforcement integrations
Reusable adapters or middleware for common application frameworks could make integration easier.
However, such components would still need to address resource identity, enforcement placement, and authorization freshness.
Expanded security verification
Additional fault injection, longer fuzz campaigns, adversarial integration scenarios, and formalized policy properties could strengthen the evidence base.
These are prospective directions, not features claimed as implemented in v0.1.0.
25. Engineering Lessons
This project illustrates several principles that apply beyond authorization systems.
Security depends on trusted data provenance
Correct policy evaluation is insufficient if the information supplied to the evaluator can be forged.
The origin of roles, attributes, and resource ownership is fundamental to the security model.
Default behavior is a security decision
An omitted policy is not merely missing configuration.
In a security-sensitive system, its treatment can determine whether unauthorized access is possible.
Explicit precedence reduces ambiguity
Conflict-resolution rules should be documented and tested.
Security decisions must not depend on incidental implementation behavior.
Tenant isolation requires more than role matching
Permissions must be evaluated within the correct security context.
A privileged role in one organization does not automatically create authority in another.
Administration is part of the attack surface
Policies determine access.
Therefore, modifying policies must itself be a protected, auditable operation.
Database transactions support security consistency
Atomically committing policy activation and audit information reduces the risk of inconsistent administrative state.
Failure handling is part of authorization correctness
A service that grants permission when its database fails has fundamentally different security behavior from a fail-closed service.
The failure path deserves direct verification.
Testing must include adversarial outcomes
A test suite containing only successful authorization scenarios cannot meaningfully validate tenant isolation, default denial, or policy conflict handling.
Negative tests are essential.
Benchmarks must describe their measurement scope
Microsecond-level in-process evaluation and millisecond-level HTTP/database requests are different measurements.
They should not be presented as interchangeable performance guarantees.
A security tool needs clearly documented limitations
Engineering credibility depends not only on the safeguards implemented but also on accurately describing what those safeguards cannot guarantee.
Conclusion
RBAC/ABAC Policy Engine v0.1.0 demonstrates a focused approach to building an authorization decision service using Go and PostgreSQL.
The implementation combines role-based permissions with typed attribute-based conditions, tenant-aware authorization, explicit denial precedence, and fail-closed behavior.
It also treats policy administration as a security-sensitive workflow, with versioned activation, optimistic concurrency checks, and transactionally consistent audit records.
The public release provides automated test evidence, PostgreSQL integration verification, fuzz testing, race detection, OpenAPI contract validation, documented performance measurements, and a checksum-verified source distribution.
Its trust boundaries are explicit.
The engine evaluates authorization decisions.
The consuming application must enforce those decisions.
The PostgreSQL environment supplies trusted authorization data and remains subject to its documented privilege model.
Manual credentials, single-tenant evaluator configuration, and operational time-of-check/time-of-use risks remain known limitations.
The central engineering principle is:
Authorization should never be granted because information is missing, a policy cannot be evaluated, or a request happens to contain convenient claims.
A reliable authorization decision must follow from trusted data, applicable rules, defined precedence, and a successful evaluation.
This project turns that principle into a concrete, testable, open-source implementation.
Project Resources
GitHub Repository
https://github.com/soroushneyestani/rbac-abac-policy-engine
Official v0.1.0 Release
https://github.com/soroushneyestani/rbac-abac-policy-engine/releases/tag/v0.1.0
SHA-256 Checksum File
https://github.com/soroushneyestani/rbac-abac-policy-engine/releases/download/v0.1.0/SHA256SUMS.txt
Public Main CI
https://github.com/soroushneyestani/rbac-abac-policy-engine/actions/runs/45673136989
Public Release-Tag CI
https://github.com/soroushneyestani/rbac-abac-policy-engine/actions/runs/45673671688
Threat Model
https://github.com/soroushneyestani/rbac-abac-policy-engine/blob/v0.1.0/docs/THREAT_MODEL.md
Benchmark Methodology and Results
https://github.com/soroushneyestani/rbac-abac-policy-engine/blob/v0.1.0/docs/BENCHMARK.md
MIT License
https://github.com/soroushneyestani/rbac-abac-policy-engine/blob/v0.1.0/LICENSE
Third-Party Notices
https://github.com/soroushneyestani/rbac-abac-policy-engine/blob/v0.1.0/THIRD_PARTY_NOTICES.md
Developed by Soroush Neyestani
RBAC/ABAC Policy Engine — v0.1.0
November 2026 | MIT License | Open Source
Keywords: RBAC, ABAC, Authorization, Access Control, Go, PostgreSQL, Policy Engine, Policy Decision Point, Tenant Isolation, Deny by Default, Zero Trust Architecture, Policy Versioning, Audit Logging, Optimistic Concurrency, OpenAPI, Fuzz Testing, Race Detection, Software Security, Backend Engineering, Open Source.