Open Enterprise
Browse topics
DocumentationIdentity and access

Permissions

The compact installation evaluates custom roles, resource grants, teams, attribute policies, relationships, mandatory conditions, denials, searches, and policy comparisons inside the engine. Select authorization: { provider: native }; it requires no policy process. Service accounts are typed principals with direct assignments and resource grants. Teams contain people and nested teams, and ownership remains human.

The optional reference deployment below uses OPA 1.22.2 through enterprise-pdp and AuthZEN. Both paths use the same compiled model and conformance vectors. A remote decision failure never selects the native provider automatically. PostgreSQL remains the source of truth. The backend comparison records the supported translations.

Run the reference deployment

Requirements: Docker Compose 2.24.4 or later and Node.js 22 or later. Run these commands from the repository root:

Shell
npm ci
npm run build
docker compose -f compose.yaml -f deployments/compose.permissions.yaml up -d --build --wait
npm run demo:permissions:seed
npm run test:e2e:permissions

Open the example. Alice uses alice / dev-only-alice-password and a real TOTP challenge. Her public development TOTP secret is JBSWY3DPEHPK3PXP. Register this secret in an authenticator with SHA-1, six digits, and a 30-second period. Bob uses bob / dev-only-bob-password and has no MFA credential. The recovery connection uses recovery / dev-only-recovery-password. The example accepts its initial owner invitation automatically after recovery login.

The setup service creates only the dedicated oe-v03-permissions Keycloak realm. The seed command creates documents, invoices, a project, roles, groups, shares, and a validated policy version. Seed data uses org_permissions and the dedicated application database. Rerunning the seed resets the demonstration's known grants and policies. The example retains passwords and MFA credentials in Keycloak.

For PostgreSQL volumes created before v0.3, create these databases first:

Shell
docker compose exec postgres createdb -U enterprise enterprise_permissions
docker compose exec postgres createdb -U enterprise enterprise_example_permissions

Do this once for each missing database. The seed command uses the exposed PostgreSQL port 55432. Override PERMISSIONS_EXAMPLE_DATABASE_URL, APP_ORIGIN, and ENTERPRISE_ENDPOINT for custom local ports. All credentials and TOTP secrets in this deployment are public development fixtures. The OPA and PDP ports remain inside the Compose network.

Select capabilities

Use deployments/runtime.permissions.yaml as the complete configuration example. Set capabilities.authorization.provider to authzen and configure:

YAML
authzen:
  issuer: https://pdp.example
  access_token_env: AUTHZEN_ACCESS_TOKEN
  synchronization_endpoint: https://pdp.example/management/v1/organizations
  synchronization_token_env: AUTHZEN_SYNC_TOKEN
  required_capabilities:
    - evaluation
    - evaluations
    - search.resources
    - search.subjects
    - search.actions
    - synchronization.revision
  timeout_seconds: 3

Use distinct decision and synchronization credentials. Startup discovers endpoints, verifies the exact issuer, and checks the required capabilities and synchronization profile. Endpoints must share their configured origin. Redirects are disabled, responses have size limits, and timeouts permit 1–10 seconds. HTTP requires the explicit development setting.

The local-rbac selection retains organization-level v0.1/v0.2 behavior. Its resource context does not enforce ACLs or hierarchy. Advanced APIs require the full authorization selection. An organization whose stored policy has deny or require rules gets no access under local-rbac, because those rules cannot be applied there. Startup logs a warning that names such organizations. To switch one to local-rbac on purpose, remove those rules first.

Decision semantics

Every evaluation names an organization, canonical subject, and action. Resource checks also name a registered {type, id}. The registry belongs to one organization; organization is a reserved synthetic resource type. Unknown resources and inactive subjects cannot receive access. Suspension, SCIM deactivation, session expiry, and accepted CAEP revocations remain mandatory gates.

Permission strings match exactly. Only the literal * matches every action; document:* has no wildcard meaning. The evaluator combines all applicable grant paths:

  • Active base membership roles and SCIM group mappings.
  • Multiple local user or group role assignments.
  • Direct user or group resource grants.
  • Declared relationship actions and inherited parent grants.
  • Matching allow rules.

An applicable deny rule overrides every grant. All applicable require rules must pass, even when a role or direct share grants the action. A rule's conditions use AND. Separate allow rules provide alternative grant paths. With no grant, the result is denial. Empty conditions are true; an unconditional require adds no restriction.

A missing, stale, untrusted, null, or incorrectly typed attribute in an applicable rule denies the entire evaluation. This applies to allow, deny, and require rules. Rules do not treat unknown attributes as false and continue through another grant. A resource-scoped denial or required rule also prevents its action from being checked without a resource. Provider errors return an error and never an allow result.

Roles, delegation, and ownership

Management supports custom organization roles with explicit permissions and versioned updates. Assignments target a canonical user or group, optionally at a resource scope. inherit: true includes descendant resources. A global assignment has no resource scope. Removing one assignment leaves independent grant paths intact.

Built-in owner, admin, member, and viewer roles remain protected deployment definitions. Local role assignments cannot assign owner. Ownership uses the existing protected membership and invitation operations. The last active owner cannot be removed. Directory-managed users and groups cannot become recovery owners.

Delegated users need the relevant management action and the permissions they grant. The store rechecks authority, session state, old targets, and new targets under the organization lock. Scope changes cannot move authority outside the delegator's permitted resources. An inheritable grant requires the delegator's own inheritable authority and permission on current descendants. A permission on one object cannot grant authority over future children. Changing a role or group also checks affected existing grants.

Advanced role assignments also apply to membership and invitation administration. A nonowner needs the requested role's permissions and cannot change a target with stronger current role permissions. This covers suspension and reactivation too. The actor must also hold every organization-wide action the target holds through other role assignments, directory groups, and nested groups. Reactivation and role changes also check inherited resource authority and policy-based allow rules. Inherited access requires the actor's own inheritable scope, including authority over future descendants. A suspended member's access still counts, so a delegate cannot reactivate someone with access the delegate lacks. Suspension that keeps the role skips the resource check, because it only removes access. A delegate can therefore offboard a member who holds shares the delegate cannot open. On a single resource, * requires the actor's wildcard authority and coverage of concrete policy restrictions. Conditional policies can prevent a safe comparison of future authority. An independent owner must perform the change when that comparison fails. Invitation creation requires members:write and invitations:write.

The recovery owner can manage the local control plane when the PDP is unavailable. Policy draft, import, activation, and rollback require a recovery owner or a service with policies:write. In AuthZEN mode, business evaluations require the external provider. Service credentials are trusted backends. The runtime checks their organization binding and operation scope on every request. Keep broad management credentials out of browser clients.

Attributes and conditions

The portable schema is oe.permissions/v1, with combining: deny_overrides. Each referenced attribute needs an attribute_rules declaration with its namespace, exact trusted sources, and maximum age. Supported namespaces are subject, resource, context, and authentication. Supported sources are runtime, service:<service-id>, and oidc:<connection-id>.

The runtime stamps service attributes with the authenticated service ID and the observation time. Users cannot write subject attributes or supply arbitrary evaluation context. User-authored resource values carry a user source, which cannot satisfy a trusted service attribute rule. A scoped backend must register authoritative business values before a decision depends on them. The example locks an invoice row, registers its actual amount, checks access, and then commits approval. It does not accept the browser's amount or MFA assertion.

Runtime context supplies now in Unix seconds, hour_utc, and organization_id. The runtime also supplies subject.id. Verified session origins supply mfa, amr, acr when present, and auth_time. mfa is true only when the signed ID token contains amr: ["mfa", ...]. Configure the trusted issuer to emit that value only after actual MFA. Neither a fresh token issue time nor a request property proves fresh authentication. Advanced connections require signed auth_time; freshness uses that original authentication time. Service evaluations without a user session cannot claim the user's authentication assurance.

Each value record has observed_at and expires_at in Unix seconds. Observation times in the future, expired values, and values older than max_age_seconds deny access. Maximum age and attribute TTL permit 1–86400 seconds. Applications must refresh authoritative data before it expires. The demo invoice policy deliberately requires recent MFA and expires its seeded values. Rerun the seed after its development policy values expire.

Operator Meaning
eq, ne Exact JSON equality or inequality, without type conversion
lt, lte, gt, gte Integer ordering
in Left value is an element of the right array
contains Left array contains the right value, or left string contains the right string

Operands are literals or declared attribute references. Numbers must be integers within ±(2^53−1); use minor currency units for amounts. Floating point values, arbitrary expressions, regexes, and engine-native policies are unsupported. Unsupported schemas and constructs fail before activation.

Relationships and resource lifecycle

Local and SCIM groups can receive assignments and ACL grants. Local groups can contain users or groups. member edges also connect users or groups to groups. parent edges connect a child resource to a parent resource. A resource's parent field contributes the same hierarchy semantics. Multiple parent edges form a directed acyclic graph.

Custom relation definitions name explicit actions and inheritance behavior. An owner or shared relation is a named permission path, not recovery organization ownership. User/group-to-resource edges use these declarations. Reverse traversal, arbitrary computed relations, and unsupported edge shapes return validation errors.

Both group and resource traversal reject cycles and paths beyond 32 edges. Deleting a resource removes its registered descendants, scoped assignments, grants, and affected relationships in one transaction. Application business rows remain the application's responsibility. Deleting a local group removes its grant paths; a policy reference must be removed first. SCIM group deletion removes only paths tied to that source. Allow selectors retain their other principals; an allow rule with no remaining principal is removed. Deny and require rules keep the deleted group. The group then stays hidden from SCIM, without members, and keeps its ID. If the directory creates a group with the same externalId again, it gets that ID back and the restrictions apply to its members again. It preserves independent local grants.

The portable model permits 100 local roles, 200 local groups, 10,000 individually registered resources, 10,000 direct grants, and 200 policy rules per organization. Assignments and relationships each permit 5000 local entries. Groups permit 1000 members. The group traversal graph permits 4096 groups in total. Ordinary organization members are counted separately. Point evaluations look up grants on the organization, the target record, and its ancestors. A child also needs an inherited grant to receive access through an ancestor. SCIM rejects a new group when the organization already has 4096 groups. Rules permit 20 conditions, and action lists permit 100 actions. Attribute maps permit 100 keys, eight nested levels, 100 array/object entries, and 2048-byte strings. Each deployment also enforces a request-body limit. Register records through individual changes when a complete imported bundle exceeds that limit. AuthZEN synchronization additionally requires the snapshot and its compiled representation to fit the PDP's 8 MiB transport bounds.

To reproduce the engine benchmark, run cargo test --release -p enterprise-core --test permission_capacity -- --ignored --nocapture. On a local arm64 machine, compilation of 10,000 invoices and 10,000 direct grants took 15.7 ms. The prepared native engine evaluated 100,000 point decisions in 91.4 ms.

The authorized_list_ integration tests exercise the runtime API against PostgreSQL. Each fixture has one grant per invoice, alternating between two people. The tests register the last invoice, grant access, check a point allow and refusal, then enumerate every authorized invoice with 200 results per page. Each page loads and compiles the current organization snapshot and checks its revision. Run the tests with the development database and fixture credentials using cargo test -p enterprise-runtime --test permissions authorized_list_ -- --ignored --nocapture --test-threads=1.

One local arm64 run used a debug runtime, loopback PostgreSQL, and the reference OPA process for AuthZEN. The point measurement includes the first evaluation after a grant change.

Provider Registered invoices Point evaluation First authorized page Full authorized list
Native 10,000 280 ms 503 ms 5,000 invoices, 25 pages, 14.65 s
AuthZEN with OPA 1,002 373 ms 381 ms 501 invoices, 3 pages, 1.31 s

Runtime API and SDK

Runtime endpoints use the generated OpenAPI contract. They use the runtime's canonical API shape rather than claiming AuthZEN wire conformance.

Operation Runtime endpoint
Evaluate / ordered batch POST /v1/access/evaluate, POST /v1/access/evaluations
Search resources, subjects, or actions POST /v1/access/search
Inspect / export / revision GET /v1/organizations/{id}/permissions[/export|/revision]
Typed role, group, resource, ACL, relationship, or attribute mutation POST /v1/organizations/{id}/permissions/changes
List / import draft versions GET, POST /v1/organizations/{id}/permissions/policies
Compare / activate POST /v1/organizations/{id}/permissions/policies/{version}/compare, /activate
Synchronization state GET /v1/organizations/{id}/permissions/synchronization

Mutations require expected_revision. HTTP 409 requires a fresh read and review; the SDK does not retry stale writes automatically. User evaluations bind the session subject and organization. Services require authorization:check for evaluations. Each advanced permissions route requires its own operation scope and an organization binding. A binding covers an explicitly listed organization or, with created_organizations: true, one created by that same service. Subject enumeration requires permission-management read authority. It evaluates subjects without borrowing the caller's MFA proof.

TypeScript
const alice = enterprise.asSession(runtimeSessionToken);
const decision = await alice.access.evaluate({
  organizationId: "org_permissions",
  subjectId: canonicalAliceId,
  action: "document:edit",
  resource: { type: "document", id: "permissions-team" },
});
const page = await alice.access.search({
  organizationId: "org_permissions",
  kind: "resources",
  subjectId: canonicalAliceId,
  action: "document:read",
  resourceType: "document",
  limit: 20,
});

Use page.next_cursor as the next request's cursor for continuation and stop when it is null. Search results use the same evaluator as individual checks. Cursors bind the organization, immutable snapshot, query, authentication, page size, and a 60-second lifetime. A changed query or revision requires restarting the list. Time and attribute expiry can still change decisions between pages; check again before protected writes. Action search enumerates explicit actions present in the model and does not expand an infinite wildcard action set.

The SDK exposes permissions.roles, assignments, groups, resources, grants, relationships, attributes, and policies helpers. permissions.inspect returns source-tagged managed projections and local data. Authorized management responses include canonical directory links for identity mapping. They do not expose upstream credentials. Decision reasons require the recovery owner or a service with authorization:diagnose.

AuthZEN and the synchronization profile

The separate reference PDP implements the final AuthZEN Authorization API 1.0:

  • /.well-known/authzen-configuration discovery.
  • /access/v1/evaluation single evaluation.
  • /access/v1/evaluations with defaults, single-request compatibility, individual errors, and all three ordered evaluation semantics.
  • /access/v1/search/resource, /subject, and /action with pagination.

The runtime adapter uses those discovered endpoints with its decision credential. The PDP accepts trusted canonical context through the context.oe extension. It binds every response to the organization, snapshot key, revision, and policy version. Runtime tests reject malformed decisions and mismatched bindings. The repository tests protocol behavior; it does not claim external product certification.

AuthZEN does not define role, ACL, or policy management. This deployment therefore requires the separate oe.permissions/v1 synchronization profile. The management credential accesses /management/v1/profile and immutable snapshot uploads under /management/v1/organizations. The profile declares revision barriers, paginated resource search, and zero stale-access seconds. A generic AuthZEN service without this management integration cannot run the complete deployment.

Consistency and recovery

Every relevant database mutation records a new organization revision and a durable synchronization entry in the same transaction. This includes roles, memberships, SCIM data, policies, relationships, and security revocations. The worker retries pending synchronization every second. Requests also synchronize their current immutable snapshot on demand. Snapshot keys include the revision, policy version, and a hash of the complete snapshot. Repeated uploads are idempotent.

After a remote result, the runtime rechecks the current revision and the requesting session. A revision change returns conflict, even if the remote result allowed access. No stale allow fallback or decision cache exists. The declared stale-access interval is zero seconds for changes completed before the final decision check. An operation already authorized and in progress may finish. The runtime does not provide a distributed transaction with application writes or undo completed operations. Applications must preserve their own business transaction invariants.

Synchronization status reports pending work and the last acknowledged revision. An acknowledged revision is not a health guarantee. If OPA loses projection data, the next request rebuilds it from PostgreSQL. An unreachable PDP, timeout, invalid result, or unrecoverable projection error prevents access. PostgreSQL retains durable changes and policy versions; OPA holds a rebuildable projection. Immutable OPA snapshots currently remain until the OPA process restarts. Monitor its memory and restart or clear projection data as needed; requests rebuild required snapshots. Keep PostgreSQL and OPA/PDP management endpoints within the trusted network.

Migration and policy versions

Migrations 0001–0004 remain unchanged; migration 0005 adds permission state, revisions, versions, and the synchronization log. Back up the database before deployment upgrades. Existing base memberships and v0.2 group mappings project into the full model with their original source tags. permissions.migrateLegacy imports supported custom role definitions and records an idempotent migration marker. It does not copy directory-managed grants into independent local grants. Switching providers preserves canonical identities and active membership gates.

Export bundles contain the organization, schema, local configuration, and a read-only managed manifest. Import binds the bundle to that organization and rejects unsupported constructs or altered managed provenance. An import carries attribute values, not their provenance. A subject or resource attribute set that differs from the current state is credited to the importing user or service and observed at import time. A bundle therefore cannot claim that a trusted service asserted a value, or make a stale value look fresh. Attribute sets that match the current state keep their original source and times. A bundle contains the full local role, resource, attribute, ACL, relationship, and policy state. Review the whole bundle before activation.

Create a draft, provide representative decision cases, compare, and activate:

TypeScript
const state = await enterprise.permissions.revision(org);
const bundle = await enterprise.permissions.export(org);
const draft = await enterprise.permissions.policies.draft(org, state.revision, bundle);
await enterprise.permissions.policies.compare(org, draft.id, state.revision, cases);
await enterprise.permissions.policies.activate(org, draft.id, state.revision);

Comparison evaluates the current and candidate policies for each supplied case. Native mode records those decisions locally. AuthZEN mode also evaluates each version through OPA and requires both translations to agree. Review the old and proposed decisions in the report. Validation requires at least one case. It does not require the new policy to preserve every old decision. Comparison cases do not synthesize a user's MFA proof. Use the signed-session integration tests for authentication conditions.

Activation requires validation against the current revision and writes an atomic audit event. Concurrent changes invalidate validation and require another comparison. A draft that was never active must also be activated at the revision it was created from. Activating it later would undo every change made since, such as a revoked share. Activation then returns a conflict; create a new draft from a current export. Rollback revalidates and activates a prior version through the same checks. AuthZEN comparison needs a reachable PDP. During a PDP outage, an operator with activation authority can restore a previously active version with "without_comparison": true. That version passed a comparison when it was first activated. A draft that was never active always needs a fresh comparison. The audit log records this activation as permissions.policy.activated_without_comparison. The SDK provides permissions.policies.rollback for this sequence, and permissions.policies.rollbackWithoutComparison for a rollback during a PDP outage. Rollback restores the full saved local bundle, including local resources and shares. It never restores old membership status, SCIM data, recovery ownership, or revoked sessions. Business records are not part of a permission bundle.

Verification

bash scripts/test.sh installs a checksum-verified native OPA binary and runs the complete repository suite. Set TEST_DATABASE_URL to a dedicated PostgreSQL database. Use TEST_OPA_BINARY for an already downloaded binary with the pinned checksum. The suite checks Native/OPA equivalence, every comparison operator, graph limits, AuthZEN endpoints, and signed assurance claims. Runtime tests cover revocation races, delegation, source-preserving migration, rollback, resource deletion, tenant isolation, malformed responses, and interrupted synchronization. The permissions browser test uses actual password-plus-TOTP authentication. It covers every v0.3 scope row through the example. The Keycloak, Dex, and SAML browser tests remain regression gates.

Search documentation