forbidden Validator Documentation
forbidden Validator Documentation
Unconditional Denial of Access for FHIR Resources
Intent
The forbidden validator acts as a strict denial rule, rejecting all requests for a specified resource and operation. It enforces a "deny-by-default" security model to prevent accidental data exposure.
Key Use Cases:
- Blocking public access to sensitive resources (e.g., genetic data).
- Disabling unsafe operations (e.g.,
PatientdeletingMedicationRequestrecords). - Serving as a fallback rule when no other validators apply.
Key Features
- No validation logic: always denies, for every operation, without inspecting anything.
- It cannot be overridden. Where several rules match the same request, all of them must pass. Adding an
allowedrule alongside aforbiddenone does not widen access — both run,forbiddendenies, and the request fails. To grant access, remove theforbiddenrule. The exception is a rule that names a practitioner role: aforbiddenwith no role is the "other practitioners" rule and does not apply to a practitioner who holds one of the triple's roles (Several roles on one triple). - Performance: zero overhead. Nothing is fetched and no request reaches the FHIR server.
Access is already denied when no rule matches — that is what default_access: "Forbidden" means. forbidden is for the narrower case where you want a denial to be explicit and legible: a rule someone will find when they ask "why can't this role do that?", rather than an absence they have to infer.
It is also the right tool when you want to carve one operation out of a set you are otherwise granting, and want the carve-out visible in the configuration rather than implied by its absence.
Configuration Examples
1. An explicit, documented denial
{
"rbac": {
"default_access": "Forbidden",
"validation_rules": [
{
"client_role": "Practitioner",
"entity_name": "Patient",
"operation": "delete",
"validator": "forbidden"
}
]
}
}
Explanation: every request is denied unless a rule grants it, and this rule states that practitioners may not delete patients — visibly, so that a later editor adding practitioner permissions has to remove it deliberately rather than widening the set by accident.
2. Block Patient Access to MedicationRequests
{
"client_role": "Patient",
"entity_name": "MedicationRequest",
"operation": "read",
"validator": "forbidden"
}
Outcome: patients receive 403 Forbidden when attempting to view medication orders — and continue to, even if another rule for the same triple is added later.
Best Practices
- Default security posture:
Spell it with the capital
"default_access": "Forbidden"F.ForbiddenandAllowedare the only two recognised values and both are compared literally, so"forbidden","Allow"and"Forbidden "are none of them and none of them is a valid configuration. Publishing rejects an unrecognised value with a400before it reaches storage. - Grant by adding, restrict by removing. Because matching rules are combined with AND, you widen access by deleting restrictive rules, not by adding permissive ones.
- Audit logs: monitor requests blocked by this validator to spot applications that are misconfigured rather than misbehaving.
FHIR Security Considerations
- Aligns with FHIR’s Security principles for access control.
- Use with Provenance resources to track access attempts.
Use Case: Research Database Lockdown
A genomics study keeps its sequencing reports unreachable by default — which they already are, since access requires a rule — and grants them only to practitioners holding a specific role code, tied to ethics approval.
Configuration:
{
"client_role": "Practitioner",
"entity_name": "DocumentReference",
"operation": "read",
"validator": "legitimate_interest",
"required_role_system": "http://terminology.hl7.org/CodeSystem/practitioner-role",
"required_role_code": "researcher"
}
DocumentReference and not MolecularSequence: legitimate_interest takes its policy from a platform table, and that table has no practitioner entry for MolecularSequence, so a rule naming the two together denies every request no matter which role code the caller holds. Check the validation strategy table for your resource type before pairing it with this validator.
Note what this example does not do: it does not pair a forbidden rule with an allowed one and expect the second to win. Rules on the same triple are combined with AND, so that arrangement grants nothing. The restriction here comes from the role gate, and from there being no other rule for the triple.