Skip to main content
Conditional Role-Based Access Control (CRBAC) is an advanced access control system that extends traditional Role-Based Access Control (RBAC) by introducing dynamic conditions that determine access rights. For the credential types that policies govern (root, tenant, role, and user tokens), see the Authentication reference. CRBAC is particularly useful for businesses that need to comply with various privacy laws, such as:
  1. DPDPA (India’s Digital Personal Data Protection Act)
  2. FERPA (Family Educational Rights and Privacy Act in the USA), which governs student education records
  3. GDPR (General Data Protection Regulation in the EU)
With Databunker Pro, customers can easily implement solutions that align with these regulations, ensuring secure and compliant PII management.

Key Features of CRBAC

  • Hierarchical Access Control: Supports parent-child relationships in data access, enabling fine-grained permissions.
  • Context-Aware Policies: Defines access based on specific attributes like user roles, organizational structures, and compliance requirements.
  • Dynamic Consent Enforcement: Incorporates consent management for accessing PII.
  • Group-Based Roles: Databunker supports groups of users, where each member within a group can have distinct roles. For instance, in an educational group, roles like Teacher and Student can be assigned, or in a family group, roles such as Parent and Child.
  • Similar to AWS IAM Policies: Uses a declarative approach to grant or deny access based on conditions.

Policy Structure

CRBAC policies resemble AWS IAM policies, defining who (principale) can perform what (actions) on which (resources) under which conditions.

Example Policy: Parent-Child Relationship Enforcement

In Databunker Pro, you can create a custom group for family members. Within this group, parents will have read and write access to their child’s information. You can use the following policy to grant parents access to their child’s PII and consent information.

Example Policy: Teacher-Parent Access

This policy will grant to a teacher entity access to the student’s parent information.

Passing runtime context with request_metadata

Most Databunker Pro API endpoints accept an optional request_metadata object on the request body. The caller (application code, an API gateway, or a tokenisation proxy) uses it to pass runtime context — values like the calling environment, the purpose of the request, the originating IP address, a ticket number — that the access-control engine can evaluate at policy time. CRBAC Condition blocks can reference request_metadata values directly, so the same policy can grant or deny access based on why and where the request is coming from, not just who is making it. This is purpose-of-use enforcement.

Example: caller-supplied context

Example: policy that evaluates request_metadata

This policy allows a security-analyst role to read full user records only when the request is tagged with purpose: fraud-investigation and originates from the production environment:
A request from the same role without those metadata values — or with different ones — is denied.

What to put in request_metadata

request_metadata is free-form, so the keys are conventions you adopt for your deployment. Typical keys we see in production: request_metadata is recorded in the audit event for the request, so it doubles as accountability metadata even when no policy references it. Audit calls return it as requestmetadata. Calls that a policy denied keep it too.
  • It is stored encrypted.
  • It is limited to 4 KB of JSON. A larger value is rejected with HTTP 400.
  • It is left out when users read their own audit events, as it may identify your staff.
  • Databunker Pro records what the caller sends and does not verify it. To have the individual verified by the token, issue one per person with XTokenCreateForUser.
See audit event fields.

Field-Level Masking in Responses

When a policy grants access to a subset of a user’s profile fields, Databunker Pro applies the policy at response time. The original record stays untouched in the vault; the API response is filtered for the calling principal. The masking strategy is asymmetric by type so that strongly-typed clients (TypeScript, Python type-hints, Java, generated SDKs) do not encounter silent type mismatches:
  • String fields that the caller is not authorized to read are replaced with the literal "***". The field stays in the response so the client can detect that the field exists.
  • All other types (number, boolean, array, nested object) are omitted from the response entirely when masked. This avoids type-corruption bugs like profile.age + 1 evaluating to "***1" because the engine had substituted a string for a number.

Example

Suppose a sales user has a policy allowing only ${target_group_members:role/lead}.profile.email. A lead’s stored profile is:
Calling UserGet with the sales user’s token returns:
Notice:
  • email is visible because the policy granted it.
  • login, name, phone are strings — present in the response with value "***".
  • age (number), verified (boolean), tags (array), address (object) are absent from the profile object entirely.

TypeScript example

Scoping file access by tag

A policy can limit a role to files carrying certain tags with a users.file.<tag> resource. Patterns work too: users.file.kyc-* covers every tag starting with kyc-, and users.file.* covers all tags. This policy lets a reviewer read files awaiting review and move them to approved, and nothing else:

What a tag-limited role may do

A role has access to all file tags when its policy names no users.file.<tag> resource, or only users.file.*. A role limited by group alone, with users.group.<name>, keeps it. When a policy combines tag and group resources, both limits apply. Points to plan for:
  • Tags a role may not see stay on the file and are left out of its responses. FileAddTags, FileDeleteTags and FileRenameTag never touch them, so a role cannot remove or reveal them. FileDelete removes them with the file.
  • An untagged file matches no tag, so a tag-limited role cannot see it. Removing the last tag a role may see hides the file from that role.
  • A file the role cannot see returns 404, not 403, so its existence is not disclosed.

Scoping token access by tag

A policy can limit a role to tokens with certain tags using a tokens.tag.<tag> resource. Token tags don’t belong to users, so these resources start with tokens, not users. Patterns work too: tokens.tag.payroll-* covers every tag starting with payroll-. This policy lets an HR application read and delete tokens tagged hr, and nothing else:
tokens, tokens.* and tokens.tag.* give access to all tokens, including untagged ones. Points to plan for:
  • An untagged token matches no tag, so a tag-limited role cannot see or delete it.
  • Tags a role may not see stay on the token and are left out of its responses. TokenAddTags, TokenDeleteTags and TokenRenameTag never touch them.
  • A token the role cannot see is reported as not found. BulkListTokens and BulkDeleteTokens skip it.

How CRBAC differs from plain RBAC

Static RBAC answers “which endpoints may this role call?”. CRBAC additionally evaluates the request itself, so the same role can be allowed or refused depending on runtime context passed in request_metadata, and the response can be masked field by field rather than allowed or denied whole. That is what makes it usable for regulated data: a support agent can hold one role and still see different fields depending on which record they are looking at, without you minting a role per situation.

Next steps