Study-level access control with the Orthanc Python plugin: when you need it
If clinicians, researchers or partner sites share one Orthanc archive but should each see only some studies, built-in RegisteredUsers cannot separate them, because every registered user gets full read-write access. Study-level control means Orthanc makes a decision for each REST request, based on the requesting user and the study it touches. Teams often choose this route without Keycloak when they already trust an identity source, want the change confined to one Orthanc server, and have engineers who can own a small amount of code. This section covers two routes: a Python plugin that evaluates the rules inside Orthanc, and the advanced authorization plugin backed by a custom web service. Start from the orthanc-setup-samples repository, which includes a sample combining a Python plugin with the authorization plugin for study-level access.
The routes differ mainly in where the policy lives. The Python route keeps decisions in the Orthanc process, so fewer components run, but the script becomes security-relevant code that you must review, version and retest with each Orthanc upgrade. The advanced authorization plugin forwards each REST request's token to an external service, which allows or denies the request and returns HTTP 403 when access is refused. That separation suits teams that want policy managed outside the archive, but it adds a service to run, secure and keep available. Before you pick one, confirm which request types and fields your Orthanc version passes to each mechanism, since the rules must be checked against the Orthanc version in use. Orthanc 1.13.0, released on 2026-08-15, rewrote storage-area access, so do not assume older examples still hold.
Whichever route you choose, settle the mapping before writing code. Decide which users belong to which labels or projects, who approves changes to that mapping, and what happens to a study that carries no label, which should be denied by default. Confirm that the rules cover every request a viewer makes, not only the study list, because a viewer issues several requests as a user opens a study. Then test with live viewer sessions as each test user, checking that a restricted user cannot open, download or change a study outside their scope, and that denials are recorded where your audit process expects them. Repeat these checks after every Orthanc upgrade and every change to the mapping.
Which Orthanc study-level access route fits your team
This table compares four ways to limit which studies a user can see in Orthanc, from built-in accounts to a Keycloak-backed reference service. Read each row from left to right: the decision column shows where access is checked, the restriction column shows the granularity the official documentation supports, and the last column lists what to confirm before you commit. The main takeaway is that RegisteredUsers alone cannot restrict users per study, so any study-level rule needs a plugin or external service.
| Route | How the decision is made | What it can restrict | Footprint and what to confirm |
|---|---|---|---|
| RegisteredUsers only | Orthanc checks the HTTP login against the users listed in its configuration. | Built-in users cannot be limited per study, so any user with access can reach any study. | Smallest footprint. Confirm AuthenticationEnabled is true and that HTTPS sits in front of any remote access. |
| Python plugin with authorization logic | Your Python code decides, following the study-level sample in the orthanc-setup-samples repository. | Study-level rules you write and test yourself. Scope is limited to what your code can check. | Your team owns the code and its upgrades. Confirm the sample's Orthanc version and plugin dependencies. |
| Advanced authorization plugin with a custom web service | Orthanc forwards each REST request's token to your web service, which allows or denies it. | Whatever your service checks per request, including study-level rules. Denials return HTTP 403. | You build and secure the service. Confirm how it is hosted, tested and kept available. |
| Keycloak-backed service (reference point) | Keycloak issues user tokens, and a service validates them, as in the orthanc-auth-service reference project. | Study-level rules are whatever the service enforces. The reference project is used with Orthanc Explorer 2. | Adds Keycloak operations to the service. Confirm the project's current status before relying on it. |
Every viewer request passes one study decision before Orthanc answers
The request starts at a viewer or API client that sends HTTPS traffic to a reverse proxy, which forwards it to the Orthanc REST API. Orthanc passes the request token or user identity to the authorization plugin or Python logic. That code asks a decision service which study labels the user may see, then returns either an allow or an HTTP 403 to the viewer. The DICOM branch runs separately. REST rules do not automatically cover C-FIND, C-MOVE or C-STORE traffic, so confirm how that path is restricted before you rely on this design.
Viewer requests pass one study decision, while DICOM traffic needs its own check.
Setting up Orthanc study-level access rules step by step
The sequence below moves from reviewing a working reference to a tested access model for Orthanc. Each step ends with a check, so the team knows whether it can move on. The result is a deployment where each user sees only the studies their labels allow, and where remote access is protected before any clinical or research user signs in.
Review the orthanc-setup-samples sample
Start by reading the sample in the orthanc-setup-samples repository that pairs a Python plugin with the authorization plugin to enforce user access at study level. Your architect or security engineer should note which parts are configuration, which parts are Python code, and where any call goes to an outside decision service. Check that the sample's approach matches your identity model, including whether users come from a local list or an external directory. The step is done when the team can explain, in one paragraph, how a single REST request for a study is allowed or denied.
Confirm Orthanc and plugin versions
Record the Orthanc core version and the exact version of each plugin you plan to run, then compare them with the Orthanc NEWS file. The release notes list 1.13.0, released on 2026-08-15, which describes a rewrite of storage-area access and DICOM parsing and transcoding. Because that release changes storage-area access, rerun the full access test set after any version change, including upgrades you make later. The step is done when the version table is signed off by the engineer who owns the deployment and matches the release notes you read.
Define users and label mapping once
Create the user list and the user-to-label mapping in one source of truth, such as a version-controlled file or a directory group set that your identity team already maintains. Each user should map to the labels that cover the studies they may open. Avoid granting access through values typed into Orthanc Explorer, because those changes are hard to review. Point the decision service at this same source so the Orthanc configuration and the authorization logic cannot drift apart. The step is done when a sample of users resolves to the expected labels in a dry run, without any manual edits.
Implement the per-study decision service
Build the decision service or Python callback that receives each request's token, works out the user and the requested study, and returns allow or deny. Under the authorization plugin, the service decides each REST request, and a denial comes back as HTTP 403. Cover every study-level route you use, and fail closed when the user, label or study cannot be resolved. Developers write the code, and the platform team reviews it before deployment. The step is done when unit tests show that an allowed study, a denied study and an unknown user each produce the expected result.
Enable authentication and HTTPS first
Before any remote access is allowed, enable AuthenticationEnabled, define accounts in RegisteredUsers, and only then set RemoteAccessAllowed. The Orthanc security guidance recommends HTTPS, either built in or through a reverse proxy, for any remote or Internet exposure. Confirm that DICOM TLS is configured for every peer that exchanges studies with this archive. The step is done when an unauthenticated request is refused over HTTPS, and a registered test user is accepted.
Keep script and export routes disabled
Confirm that the /tools/execute-script route and the export route are disabled in the Orthanc configuration and blocked at the reverse proxy, so no viewer user can reach them. The security guidance warns that the first can let a malicious user run any system command, and that the second can overwrite files. Include both paths in the proxy rules and in the regression checks you run after each upgrade. The step is done when a request to each path, made with a valid test account, is refused and the proxy log records it.
Verify access with named test accounts
Create a named test account for each access profile. For example (illustrative), one account with one label, one with two labels, and one with none, and record which studies each should see. Test through the same viewer and REST paths that clinical users will use, and check that denied studies return HTTP 403 and do not appear in study lists or search results. Repeat the full test set after any Orthanc, plugin or mapping change. The step is done when every named account matches its expected study list, and only then should a clinical or research user be onboarded.
Testing that viewers respect study rules, not just the API
A viewer showing a study does not prove that the API denies it, so the test plan must check both layers for every test user and every study state. Viewers such as Orthanc Explorer 2 or a web viewer issue many REST calls in the background, and a study can appear in a list while a series or instance request still returns data. Build a matrix with one row per test user, for example (illustrative) a user holding the label for site A, a user holding no labels, and an administrator. Give each study state its own column: a study with a permitted label, a study with a label the user lacks, an unlabeled study, and a study relabeled after upload. Each cell records the expected outcome before the test runs, then the observed result.
Run each cell at three request levels: study, series and instance. First, drive the viewer through its normal workflow as each test user, then repeat the same requests directly against the REST API with that user's token, using the identifiers the viewer exposed. A denied call should fail with HTTP 403 from the authorization service, which is how the advanced authorization plugin reports refusal, and the response should reveal nothing about the study beyond that status. Add edge cases that guess or reuse identifiers: an instance identifier from a permitted study requested in a session with no access to it, a request carrying an expired or altered token, and a request made after a label has been removed from the user. Confirm how your authorization service reads labels from each token, because the matrix only tests the mapping you actually built.
Repeat the full matrix after every Orthanc upgrade and every change to the plugin, the authorization service or the viewer, not only after changes to your own code. Orthanc 1.13.0, released on 2026-08-15, included a complete rewrite of storage-area access and DICOM parsing and transcoding, so checks that passed on an earlier version should not be assumed to still pass. Keep the matrix in version control with expected results, store captured responses as evidence, and record the Orthanc, plugin and viewer versions each run used. Before scheduling an upgrade window, read the Orthanc NEWS file for every release between your current and target version.
Gaps that let users bypass study rules
Each of these gaps lets a signed-in user reach a study they should not see, or leaves no record of who did. They sit in different layers: the REST API, the DICOM network, the viewer and the logs around them. Check each one in your own environment before you rely on study-level rules.
Administrative routes left enabled
The /tools/execute-script route can run any system command, and the export route can overwrite files, according to the Orthanc security FAQ, which says both should stay disabled. A user who reaches either route can sidestep every study rule you write in Python. Verify that neither route is reachable through your reverse proxy, that your configuration does not enable them, and that a test request from a non-admin account fails.
Remote access without authentication
Orthanc accepts HTTP connections only from localhost by default. When RemoteAccessAllowed is enabled, the docs say AuthenticationEnabled should be true and every user should be listed in RegisteredUsers, with HTTPS and a reverse proxy for any Internet exposure. A remote session that skips these settings can reach the REST API with no identity attached, so the study rules never see a user. Verify the effective values in your deployed configuration, confirm that unauthenticated requests get a refusal, and confirm that plain HTTP is not reachable from outside the network.
Fail-open decision service
A study rule enforced by an external decision service is only as strong as its failure behavior. If the service times out, returns an error or is unreachable, a plugin or callback that treats silence as approval can fail open and let the request through. The advanced authorization plugin returns HTTP 403 when access is denied, so confirm which response Orthanc gives when the service is down and whether your Python callback fails into a denial. Verify it by stopping the service in a test environment and requesting a restricted study from a restricted account.
Authorization plugin docsDICOM traffic that skips REST rules
The REST rules you set for the web interface do not govern traffic on the DICOM port. A modality or peer that can reach that port may query, retrieve or store studies without passing through the Python callback or the authorization plugin, which only sees REST requests. Verify which AE titles and IP addresses can connect, whether unknown devices are refused, and whether a C-FIND or C-MOVE from an unlisted device fails. Confirm this in the version you run, since 1.13.0 changed storage-area access and DICOM parsing.
Tokens in viewers and browser storage
A viewer that keeps its access token in browser storage or places it in a URL exposes that token to any script running in the page and to anything that logs the URL. Because the authorization plugin forwards each REST request's token to your decision service, a stolen or stale token carries the same study access as the user who held it. Verify where each viewer stores its token, how long tokens last, whether they appear in proxy or server logs, and whether a revoked user's token is refused on the next request.
Audit trail of study views
Access rules answer who may open a study, but an investigation also needs to know who did open it. Check whether Orthanc's logs or your reverse proxy's logs record the authenticated user, the study or instance requested and the time, and that no shared account is used. Confirm where those logs are written, who can read them, and how long they are kept under your own retention policy. Test it by opening a study from a known account and finding that exact entry.
What does study-level access control in Orthanc cost and take?
What makes an Orthanc access control project cost more or less?
The cost moves with the rules, the identities and the software built around them. Expect these drivers:
- Rule complexity: the number of labels, whether access depends on study attributes, and how many exceptions the policy allows.
- Number of identity sources: each directory or login system that supplies users adds mapping and test work.
- Custom service build: the Python callbacks or the external authorization service must be written, reviewed and deployed.
- Testing: proving that viewers and the REST API respect every rule takes the most effort when many roles exist.
- Keycloak integration, if you choose it: token configuration and claim mapping are added on top of the core work.
- Upgrades: a new Orthanc release can change behavior that your callbacks depend on, so each upgrade needs a retest.
A quote reflects these drivers once the written scope fixes the number of rules, sources and tests.
Which access control costs are one-time and which recur?
Most of the work is one-time, and a smaller set of costs recurs after go-live. One-time work covers policy design, the Python callbacks or custom authorization service, identity mapping, Keycloak integration if chosen, and the test pass that shows viewers respect the rules. Recurring costs come from keeping the system current:
- Upgrades to the Orthanc core and plugins, followed by retesting the access rules.
- Changes to users, labels or identity sources as your organization changes.
- Ongoing support, if you contract a retainer for upgrades, continuous testing or support.
Ask for the quote to list one-time and recurring items on separate lines, so budget owners can see what continues after launch.
How long does an Orthanc study access project usually take?
Timing depends on the written scope, and the duration is set in that scope rather than fixed in advance. The main factors are the number of rules and labels, the number of identity sources to connect, whether a custom service must be built, and how much testing the viewers need. Most engagements are fixed-scope, so the scope, deliverables and timeline are agreed in writing before work starts. Ask for the timeline as milestones tied to deliverables, including the test evidence and the handover. Also confirm the dates on which your team must supply policy decisions, account access and test accounts, because late inputs are a common cause of delay. Treat any timeline given before the scope is written as provisional.
What must our team provide for an Orthanc access project?
Your team supplies the decisions and access that the design depends on. Four inputs matter most:
- A user and label policy: who may see which studies, which labels exist, and who approves changes.
- Identity source access: read access to the directory or login system, or a representative export, so mappings can be built and tested.
- Test accounts: a set of users for each role, including users who must be denied, so the tests cover both sides of each rule.
- A named owner: one person who makes policy decisions, accepts test results and answers questions during the build.
Missing decisions are the usual cause of rework, so agree the policy in writing before the build starts.
Can our own team build per-study restrictions in Orthanc alone?
Yes, a team with Python and Orthanc experience can build it alone, but the work is demanding. The core tasks are writing the authorization logic, mapping users to labels, deploying the component in your environment and proving that every viewer and API route enforces the rules. Your engineers must test authorization failures carefully, not only successful logins. The orthanc-setup-samples repository includes a sample that combines a Python plugin with the authorization plugin for study-level access, which gives your engineers a working starting point to review. Assess your team's skills against the scope, and bring in a partner for the parts you cannot staff, such as the independent test pass or the upgrade plan.
Does Orthanc study access control require Keycloak?
No. Keycloak is not required for study-level access control in Orthanc. The approach can use Python authorization callbacks, or the advanced authorization plugin with a custom service, to map users to labels without Keycloak. Keycloak becomes relevant when your organization already runs it as the identity provider, or when you want Keycloak-issued tokens to carry the user and label information. If you choose it, the integration appears as its own line in the scope, with configuration and testing. Confirm which identity source your users already sign in with, because that decision shapes the mapping work more than the choice of software does.
Does DeployOpen issue certifications for Orthanc access controls?
No. DeployOpen does not issue audit reports, attestations or certifications. For study-level access control, DeployOpen can configure the controls, document them and prepare the evidence a compliance team needs, such as access rules, user-to-label mappings, test results and logging settings. Independent auditors and certification bodies assess that evidence and issue any formal outcome. If your organization is working toward HIPAA or GDPR obligations, ask for each control to be mapped to the requirement it supports, and ask your compliance lead which evidence the assessor expects. A control that works in a test environment does not prove it works in production, so the evidence should come from the production configuration.
How do we request a quote for Orthanc access control work?
DeployOpen does not publish a price list, and a quote follows the written scope. To get a comparable quote, prepare the facts that set the effort: the number of user roles and labels, the identity sources, the Orthanc version and deployment model, whether Keycloak is in scope, and the tests you need. Ask for the quote to list one-time work and recurring items separately, along with the deliverables, the acceptance tests and the assumptions behind them. Also ask which inputs your team must provide and when, because those inputs are part of the scope. Most engagements are fixed-scope, so the written scope is agreed before any work begins.
Limits to confirm before relying on study-level rules
The sample combines a Python plugin with the authorization plugin to enforce study-level access, so each rule depends on the Orthanc core version, the plugin builds, the routes covered and the service that makes the decisions. The six items below set the effort for a pilot, and each names who should confirm it before anyone relies on the rules for patient images.
Orthanc core version compatibility
Confirm which Orthanc core release the sample targets, then test it against the release you plan to run. Release 1.13.0, published on 2026-08-15, completely rewrote storage-area access and DICOM parsing and transcoding, so code that touches those paths can behave differently. Plan a full retest after every core upgrade, and count that retest as part of the effort. The platform team should own this check with the engineer who maintains the Python callbacks.
Sample repositoryPlugin builds for your platform
Check that the Python plugin and the authorization plugin have builds for your operating system, container image and architecture, at versions that match your core. Orthanc ships Windows, macOS and Linux packages and Docker images, but plugin availability per target decides whether the sample runs without a custom build. If you must compile or repackage the plugins, add that work and its ongoing rebuild cost to the scope. Your infrastructure team should confirm this before the design is fixed.
Orthanc plugins pageREST, DICOMweb and worklist coverage
List every REST route, DICOMweb endpoint and modality worklist that returns or changes study data, then confirm the rules apply to each one. A rule that filters the study browser can still leave a route open if it skips a DICOMweb query or an export. The Orthanc security FAQ warns that /tools/execute-script can run system commands and that the export route can overwrite files, so keep both disabled unless you have a reviewed need. Security engineers should test each route with a restricted user and record the result.
Label assignment and audit trail
Decide who assigns study labels, when they are assigned, and how a label is changed after upload. Labels drive access, so changing a label changes who can see a study, and that change needs an owner and a record. Confirm who can edit labels through the API and whether those edits are written to an audit log you can export. Compliance leads and the data steward should sign off on this before the mapping from users to labels is built.
Production-ready or reference pattern
The orthanc-setup-samples repository includes a sample that combines a Python plugin with the authorization plugin for study-level access. Treat it as a reference to adapt and test, since it does not come with your user model, label scheme, logging or failure handling. Budget for code review, load testing and a written decision on who owns the code after handover. The engineering lead and the security reviewer should agree the production bar in writing before the build starts.
Sample repositoryAuthorization service availability
The advanced authorization plugin forwards each REST request's token to an external web service, which decides access and returns HTTP 403 when access is denied. That service is now in the path of every study request, so its uptime and latency limit the archive. Confirm what happens when the service is unreachable, and who operates it. Architects should test an outage before users depend on the archive, and the identity team should confirm how tokens are issued and validated.
Authorization plugin docsHow DeployOpen scopes and tests study-level access for Orthanc
DeployOpen scopes study-level access for Orthanc as fixed-scope work, agreed in writing before the build starts. We build the access rules inside your own infrastructure, then test that viewers and the REST API respect them for each user group you define. The result is a Python plugin and authorization service your security and compliance teams can review before go-live.
How we scope
- Inventory which user groups, roles and study attributes need separate visibility in your Orthanc archive.
- Confirm where user identity comes from and how study labels map to each user.
- Agree the scope and deliverables in writing before work starts, and decide whether ongoing support should be a retainer.
How we build
- Build the external service that receives each request's token and decides access, so Orthanc returns HTTP 403 when denied.
- Add Python callbacks that map each authenticated user to permitted study labels, with the mapping reviewed by your security team.
- Start from the orthanc-setup-samples Python and authorization plugin sample, then adapt it to your identity groups and labels.
How we test and hand over
- Test that viewers and the REST API show each test user only permitted studies and deny the rest.
- Document the label model, the decision flow and the test cases, so compliance reviewers can trace each rule.
- Hand over the code, configuration and retest notes, with admin steps for adding users and labels.
How we support
- Keep the rule set under change control, so new studies, labels and users go through the same review.
- Retest after Orthanc upgrades, plugin changes or identity changes, since the authorization path touches every request.
- Offer ongoing support and continuous testing as a retainer, scoped in writing like the original engagement.

