When a municipal census needs a custom Decidim authorization handler
A custom Decidim authorization handler is the usual way to make a city census or membership database decide who may vote, sign or propose on the platform. The situation is familiar: the city or membership body wants only people on its official list to take these actions, and Decidim has to check that list without copying it into a spreadsheet that drifts out of date. Decidim's authorization system is designed to be extended, so the work is less about changing how Decidim verifies people and more about teaching it to ask your database the right question and to accept or refuse the answer in a way the rest of the platform understands.
This page covers the decisions, the build sequence, the effort drivers and the handover. The first decision is whether the census check fits a single form that the participant completes, or a multi-step workflow that collects data across several screens and may call external services. The second is how the handler registers with Decidim, since the workflow must be visible to administrators and to component permissions. The third is whether the census check needs extra conditions, such as membership status or district, which are typically expressed as action authorizers. Each choice changes how much testing and staff time the project needs, so the reader should decide them before writing code.
Before engaging a builder, confirm three things with your own team. Ask who owns the census data, what personal data the handler is allowed to store, and how long a verification stays valid before it must be renewed. Ask for a quote that names the workflow type, the connection to your database, the authorizer conditions, the test environment and the handover documentation, including who maintains the handler when Decidim is upgraded. A handler that works on the current release but is not documented or tested against your upgrade path becomes a risk at the next minor version.
What a Decidim authorization handler does
A custom census handler sits between Decidim's authorization system and your city's membership data. The cards below describe the pieces you will build or configure, what each one checks, and the points your team should confirm against the Decidim version you install.
The handler form or workflow
This is the screen a participant completes to prove who they are, such as a national ID number or a membership number plus a date of birth. Decidim's authorization handlers are Ruby classes built on its authorization framework, and the form attributes define what the participant submits. Decide early whether one form is enough or whether the flow needs several steps, because that choice changes the handler's code and its tests. Confirm the form API and workflow classes in the Decidim version you install, since they change between minor releases.
Decidim repositoryThe census data the handler checks
The handler compares what the participant submits with records in your census or membership database. Agree with the city which fields are authoritative, how names and identifiers are normalized, and what happens when a record is missing or duplicated. Ask the data owner for a documented extract or API contract before writing the lookup. Keep the lookup read only, and do not copy the full census into Decidim unless the data protection review allows it.
The verification step
When the check passes, the handler marks the user as authorized and stores the data it needs for later checks, such as a hashed identifier used to detect duplicate verifications. When it fails, the participant should see a clear message that does not reveal whether a given person exists in the census. Confirm in the installed version how the handler stores the authorization metadata and which attributes it persists. Test the failure path as carefully as the success path.
Action authorizers that restrict components
An action authorizer decides whether a participant can perform a specific action, such as voting or proposing, in a given component. The handler supplies the verification, and the authorizer applies the rule. Decidim's documentation describes extra conditions that can be added to an authorizer, for example requiring a particular membership status or a minimum age. Map each restricted action to a named authorizer before you configure component permissions, and confirm the authorizer API in the version you run.
Decidim installation docsRenewal and expiry
A census can change after someone has been verified, so the handler should support a time limit or a renewal check. Decide how long a verification stays valid and what triggers a new check, then confirm whether the installed version supports expiry through the handler or needs custom code. Participants who must verify again need a clear message, and the renewal path must not break votes already cast.
Upgrade and test coverage
A custom handler depends on Decidim internals that can change between releases. Plan automated tests for the form, the lookup, the failure messages and each authorizer condition, and rerun them after every upgrade. Decidim supports only its last two minor versions with security updates, so tie the handler's test suite to the version you will run in production and confirm the supported branch before you start.
- Supported branches
- 0.32.x and 0.31.x
Choosing a form or multi-step workflow for the census check
This table compares a single-form census handler with a multi-step workflow for checking a municipal census or membership database. Read each row as a design decision, then match the column that fits your census data, your support capacity and how much evidence you need to store. The main takeaway is that a single form suits clean, immediately checkable identifiers, while a multi-step workflow fits cases that need extra proof or staff review.
| Decision point | Single-form handler | Multi-step workflow |
|---|---|---|
| How it works | Participant enters identifiers on one screen and the handler checks them against the census at submission | Participant moves through several screens, which may add a code, a document upload or an administrator review before authorization completes |
| When it fits | The census holds reliable identifiers such as a member number plus a date of birth, and a direct lookup is enough | Identifiers are ambiguous, the census is incomplete, or the organization requires a person to confirm the match |
| Data collected | Only the fields the handler needs to match the record, submitted once | The same identifiers plus any extra codes, documents or reviewer notes, each of which needs its own storage and retention decision |
| Participant experience | Short and immediate, with one error message if the match fails | Longer and more steps to finish, so the instructions and the wait between steps must be explained clearly |
| Support load | Most failures are typos or records not in the census, which staff can usually resolve by checking the census directly | Support questions shift to pending reviews, missing documents and status updates, which need a staffed queue |
| Handling failed matches | The participant sees a rejection and can retry, so lock-out and retry rules must be set in the handler | Failures can be routed to a reviewer, which adds a decision record but also more administrative work |
| Testing effort | Test the match logic with sample records, including near-duplicates and records with changed details | Test every branch, including incomplete submissions, rejected reviews and participants who leave mid-flow |
| Confirm with your census owner | Whether the census can be queried live or only through an export, and which identifiers are stable | Who reviews, how long the review queue may run, and what evidence the review must record |
How the census handler is built and rolled out
The sequence moves from confirming the census data and its owner to a tested handler that is switched on for one component before it reaches the whole platform. Each step ends with a named output that a reviewer can check.
Confirm the census source and its owner
Identify which database holds the census or membership records, who owns it, and who may approve access to it. Ask the owner for a written description of the fields, update frequency, and how records are removed when a person leaves the city or membership. The output is a short data source record that names the owner, the access method, and the people who signed off on use for participation. Do not start coding until this record exists, because the handler's matching logic depends on what the owner can actually provide.
Define matching fields and data minimization rules
Decide which fields are needed to decide that a Decidim user is the same person as a census record, such as a national identifier or a combination of name and date of birth, and which fields are only needed for extra conditions like district or age. Store only what the authorization needs, and record the reason for each field. The output is a field specification signed off by the privacy and legal owner, showing which values are compared, which are kept, and which are discarded after the check. Confirm with your data protection officer how long any retained values may stay in the platform.
Build and register the workflow
Write the authorization workflow in Ruby on Rails within a custom Decidim module. A form-based workflow fits a single lookup where the participant enters identifying data once. A multi-step workflow fits cases where the participant confirms data across several screens or where an external lookup must be triggered in sequence. Register the workflow with Decidim so it appears in the authorization options for the organization. The output is a workflow class and a registration entry that load in a local development instance, with the form or steps rendering and the lookup called in the expected order.
Write action authorizers and extra conditions
Create action authorizers that decide whether a verified participant may perform a specific action, such as voting or supporting a proposal. Use them for extra conditions that the census cannot express alone, such as minimum age, membership status or district. Keep each condition explicit in code and in documentation so that administrators can read why a participant was refused. The output is a set of authorizer classes with unit tests for each condition, including the refusal messages shown to participants, and a list of which component actions each authorizer protects.
Configure renewal and revocation behavior
Set how long a successful census check remains valid and what happens when it expires. Decide whether renewal repeats the full lookup or only confirms that the record still exists, and whether revocation runs when a census record is deleted. Write the rule down so that administrators, the census owner and participants can all see the same expectation. The output is a renewal configuration and a tested expiry path, with a note on how participants are told they must verify again. Check that the renewal path does not keep personal data longer than the minimization rules allow.
Test the handler against staging data
Run the workflow, authorizers and renewal logic against a staging copy of census data that the owner has approved for testing, or a synthetic dataset built to mirror the real fields. Cover matches, non-matches, duplicates, missing fields, expired records and participants who fail an extra condition. Record the outcomes in a test report with the expected and actual result for each case. The output is that report, reviewed by the census owner and the platform team, with every failing case either fixed or accepted in writing. Confirm that the staging environment cannot send real census queries to production sources.
Build a permissions matrix for the pilot component
Before widening use, list each component and action that will require the new authorization, along with the verification each one needs. Use the component permissions settings to enable the handler on one pilot component, such as a single participatory process or a small consultation. Keep other components on their current methods until the pilot has run. The output is a permissions matrix that the owner has approved, and a record that the pilot component is the only one using the census handler.
Roll out to one component before wider use
Open the pilot component to participants and watch the verification and refusal rates, support requests and any conflicts raised in the admin panel. Review logs and error messages with the census owner after the pilot closes, then fix any problems before enabling the handler on other components. The output is a short pilot review that lists issues found, changes made and the decision to extend the handler, with the same review repeated before each wider step. Ask the Decidim maintainers or your partner to confirm the upgrade path for custom code before the wider rollout.
How registration and action authorizers connect the handler to components
The handler only affects participation once Decidim knows it exists. In practice, that means registering your workflow under a unique name so the authorization system can offer it to administrators when they configure an authorization method for the organization. Your census workflow is the piece that asks the participant for their identifying data and checks it against the city's census or membership database. Registration is what makes that workflow selectable, and it is also where you decide which attributes are stored on the participant's authorization record, because those stored values are what later checks and renewals rely on. Confirm the registration call, the workflow base class and the attribute and validation interfaces against the Decidim version you run. These internals change between minor versions, so read the upgrade notes for your release before you copy any example code from another project.
Action authorizers sit one level below the workflow. An authorizer is attached to a specific action, such as proposing, voting or commenting, and it can add conditions that go beyond "this person is verified." For a municipal census, that could mean requiring that the stored record belongs to a resident of the district, or that the membership status is still active. Those conditions are evaluated only for the actions where you attach the authorizer, so they do not change the rest of the platform. Component permissions then decide which actions need which verification in each component. The two layers combine: a participant must pass the component's required authorization and every authorizer attached to the action being attempted. Test this combination in a staging copy with a test census, using one account that passes, one that fails the extra condition and one that has no verification, and confirm each outcome before the process opens. Also confirm the exact name of each authorizer option and how the permission screen displays it, since administrators will rely on that wording.
What drives the effort and cost of a census handler
This table lists the factors that change how much work a custom census handler takes, from the census database itself to renewal rules and fork maintenance. Read each row as a question to answer before asking for a quote, and use the right-hand column to see which choices keep the work contained.
| Driver | Why it changes effort | How to keep it down |
|---|---|---|
| Quality and access model of the census database | A clean, documented database with a read-only service account and stable identifiers needs far less mapping and exception handling than an export that changes by hand. | Ask the city for a schema, a sample extract with test records, and a read-only account or an agreed export format before scoping starts. |
| Number of matching fields | Each field the handler must compare adds mapping, normalization (such as accents, dates and address formats) and test cases. | Match on one stable identifier plus, at most, one confirming field, and agree the list in writing before build. |
| Hashing or data minimization requirements | If the handler must store only hashed values or avoid storing census fields, the design needs hashing choices, key management and a review of what Decidim keeps. | Decide early which fields are stored at all, and confirm with the privacy or legal owner which hashing approach is acceptable. |
| Number of extra conditions | Conditions such as residence in a district, minimum age or membership status are checked in action authorizers and each one needs its own rules and tests. | Limit conditions to those the process needs, and move policy choices such as eligibility rules into a written specification. |
| Form versus multi-step workflow | A multi-step workflow with several screens, lookups and confirmations takes more design, session handling and error paths than a single form. | Start with a single form if the rules allow it, and add steps only where a participant must choose or confirm something. |
| Renewal rules | Renewal requires stored verification dates, expiry logic and messages telling participants to verify again, which touch the data model and the user interface. | Ask for the renewal period and the revocation rule in writing, and confirm whether the census changes often enough to need it. |
| Number of components and languages | Each component with its own permissions and each supported language adds configuration, wording and test runs. | Group components with the same permissions and limit launch languages to the ones the census users need. |
| Testing scope | Tests against a copy of the census, failure cases such as missing records and duplicate matches, and checks in each component take time. | Agree a fixed list of test cases tied to the written rules, and ask for a staging environment with anonymized census data. |
| Fork maintenance | A custom module that stays separate from the core framework is cheaper to keep than changes made inside a fork, which must be merged with each upgrade. | Build the handler as a separate module, avoid editing core files, and confirm who will maintain it through each Decidim minor version. |
Keeping census authorizations current with renewal
A census authorization is only as current as the database behind it, and municipal membership changes constantly: residents move, memberships lapse, employees leave and new people qualify. A custom handler that checks the census once, at the moment someone registers, will keep granting access to people who no longer qualify. Decide early whether the authorization should be permanent for the life of the process, renewed on a fixed schedule, or checked again each time a sensitive action is taken. For a municipal census, a renewal rule usually ties the authorization to a date or a process, so the handler re-queries the census after that point and the participant must be verified again if the record no longer matches. Ask the census owner which rule matches the eligibility rule the city already applies to voters or members.
Before the handler connects to a live database, the city must answer data retention and privacy questions, and the census owner should approve in writing exactly what Decidim stores. Confirm which census fields the handler reads, whether it keeps a copy of the record, a hash, or only a yes or no result, how long any stored value persists, and who can view it in the Decidim admin panel. Check whether the census query needs a dedicated read-only database account, and whether connection logs will record personal data. These decisions also shape the renewal design, because a handler that stores nothing must rely on a fresh query at each renewal. Revoking authorizations when a participant no longer qualifies is a separate step covered in the revocation topic, so read that before setting renewal dates.
How a census check flows from the participant to the action
The flow starts when a participant submits the census form or workflow step in Decidim. Decidim calls the custom handler, which queries the census or membership source through an approved interface inside the trust boundary. The handler returns a result that sets the authorization, and the action authorizer then allows or blocks the vote, proposal or signature. Check that the census system never exposes its full records to Decidim and that every hand-off is logged.
Census check path from participant submission to the allowed or blocked action, with the trust boundary marked.
How the census handler connects to the rest of the platform
A census handler is one piece of a larger Decidim deployment. It touches authorization, login, background jobs, email, the census source and the admin panel, and each connection needs access and configuration in your own environment before the handler works end to end.
Authorization and component permissions
The handler registers with Decidim's authorization system, which decides whether a verified user may take an action. Component permissions then choose which actions (proposing, voting, signing, commenting) require that verification. Check that the handler's authorization name matches what each component expects, and test each action with a verified and an unverified account before a process opens.
Decidim repositoryLogin and identity providers
Participants sign in through password accounts or configured social providers. Census matching depends on the email or identifier the participant uses at sign-in, so confirm which login methods are enabled globally or per organization. A custom OmniAuth provider used for municipal single sign-on must return the same identifier the census uses, or matching will fail.
Social providers docsBackground jobs and email
Census lookups, renewal reminders and notices about failed checks are normally run or sent through ActiveJob and SMTP. Production setups need both configured and monitored. Confirm with the team which queue backend runs these jobs, how retries behave when the census is slow, and whether the mail server is allowed to send to municipal addresses.
Decidim installation docsCensus database or membership system
The handler reads from the city census or membership database, usually over a private network connection with a service account. Agree on the query interface, the fields used for matching, read-only access, and how often the data is refreshed. Ask the data owner for their retention and access rules, and confirm whether personal data may be copied into Decidim at all.
Admin panel and failure review
Staff review failed or pending verifications in the admin panel, so messages from the handler must be clear enough to act on without exposing census details. Decide who can see verification outcomes, which errors are shown to staff, and how a participant who was wrongly rejected gets a second attempt. Test these screens with real staff roles before launch.
Environment-specific details to confirm
Network paths to the census, credentials storage, log retention, hosting location and the Decidim version in use all depend on your infrastructure and your data processing agreements. Record each connection in a short inventory, name an owner for it, and confirm the exact settings with your team and the census owner before writing any integration code.
Questions teams ask before writing a Decidim census handler
Can our own developers write a Decidim census authorization handler?
Yes, if your team already runs Ruby on Rails applications and can read Decidim's authorization code. The handler itself is a modest piece of code: a workflow that asks for the fields a participant must provide, checks them against the census, and records the result. The effort sits in the surrounding work: learning how Decidim's authorization workflows and action authorizers fit together, testing every component that will restrict actions, and keeping the code working through upgrades. Ask yourself whether someone on the team can own that code for the life of the platform, not just for the first launch.
What does the city's data owner need to provide before the work starts?
The data owner needs to define what a census match means before any code is written. Expect to settle which fields identify a person, which combinations count as a valid match, whether records can be duplicated, and how often the census changes. The data owner also needs to confirm the lawful basis and retention rules for the data, and who may query it from Decidim. Access arrangements matter as much as the schema: a test extract with realistic but non-live records, a named technical contact for the source database, and a written decision on whether Decidim queries the census live or receives a periodic extract.
What drives the cost and effort of a custom census handler?
The main drivers are the number of census sources, how clean the source data is, and how many authorization rules the city needs. A single table with a stable identifier is far simpler than several registries with inconsistent names, dates and address formats. Effort also grows with extra conditions, such as limiting certain actions to residents of a district, and with the number of components that need different permissions. Costs fall into one-time work (analysis, build, testing, documentation) and recurring work (upgrades, census schema changes, security reviews). Ask any vendor for a quote built from a written scope that lists the sources, rules, components and test cases.
How long does it take to plan and ship a census handler?
Duration depends on the same factors as cost, plus how quickly the data owner, security reviewers and the platform team can make decisions. Planning usually covers the census data model, legal review and the test plan. Build time is often the smaller part, while testing with realistic census extracts and a staged rollout take longer than teams expect. No fixed duration applies to every city. Ask for a timeline in the written scope, with dependencies on data access and sign-off listed as separate milestones so delays are visible early.
Will a custom census handler survive Decidim upgrades?
It can, but only if the handler is written against Decidim's public extension points and is tested after each upgrade. Decidim's update guide asks teams to move one minor version at a time and to follow each release's upgrade instructions, because some releases change database structures. Custom code that overrides core files or depends on internal methods is the usual cause of breakage. Keep the handler in its own module, pin the Decidim version you target, add automated tests for the workflow and authorizer, and check the release notes for each step before upgrading production.
What must be confirmed before a live census is connected to Decidim?
Confirm the data protection basis, the minimum fields Decidim receives, and where census lookups are logged. Check how the handler behaves when the census is unavailable, how it handles duplicate matches, and whether a participant who fails a check sees a clear message. Test with a staging copy of Decidim and non-live records, and confirm that the authorization is recorded against the right user and that revocation or renewal works. Security reviewers should examine the credentials used to reach the census, network paths and the admin access that can change the handler's settings. Record these decisions in writing so the sign-off is auditable.
Does DeployOpen build and support census handlers for Decidim?
DeployOpen implements, customizes, integrates, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure, which includes Decidim customization work of this kind. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. Ongoing support and upgrades are available as retainers. Because DeployOpen does not publish a price list, the practical route is to share your census sources, authorization rules and component list so a quote can follow from a written scope.
Is a census handler the right choice compared with a CSV of emails?
It depends on whether the census changes and whether it holds more than an email address. A CSV import suits a fixed list that rarely changes and needs only a match on email. A custom handler suits a live or regularly refreshed census where the match uses several fields and where renewal rules apply. Start by listing the fields you must match on, how often the source changes, and who maintains it. If the answers point to a stable list, a simpler method may be enough; confirm this with the data owner before committing to custom code.
What the client keeps after the handler is delivered
The handover package is what lets the city run the census handler without the implementation partner in the room. It should include the handler source code in the client's own repository, with the workflow class, the action authorizer extensions, the census lookup code and its tests, all committed with a clear history. Alongside the code, the client should receive the configuration in effect (the census connection settings, the workflow registration, and any authorization_handler options), a permission matrix that maps each component action such as proposing, voting or signing to the handler and its extra conditions, and a set of test cases with the expected result for each participant type. Staging data should be documented as synthetic or anonymized, so that test runs never touch real residents' records.
The runbook is the document staff will use most after launch. It should explain how a census refresh is loaded, what the handler does with records that disappear or change, how renewal dates are checked, and who may revoke or re-verify a participant. It should also cover the data handling record: which census fields are read, which are stored in the authorization metadata, where they are kept, how long they persist, and who can see them. Ask the implementer to confirm that this record matches what the handler actually stores, since reviewers compare the two. Upgrade notes should name the Decidim minor versions the code was written against and flag which parts touch internal APIs. Decidim supports only the last two minor versions with security updates, so the notes should state which branch the code targets. Ownership and licensing need explicit confirmation in the contract. Decidim is licensed under the AGPL-3.0, so any handler that is distributed or offered over a network as part of the platform may carry obligations to publish source. Ask counsel to confirm how the handler's license interacts with the city's procurement and publication rules before work starts.
How DeployOpen scopes and delivers a Decidim census handler
DeployOpen approaches a custom Decidim authorization handler for a municipal census as a fixed-scope engagement, starting from the census data source and the participation rules the city has approved. The work covers the handler, its tests, and the documentation the city's own team needs to run it after handover.
How we scope
- We document the census or membership database fields, their owner, and how often the city refreshes them.
- We agree whether the workflow is a single form or a multi-step flow, and which fields participants must supply.
- We list the actions that need the handler, such as voting or signing, and any extra conditions like district or age checks.
How we build
- We write the workflow, register it with Decidim, and add action authorizers for the extra conditions in the agreed scope.
- We test valid, expired, mismatched and missing census records, and confirm component permissions behave as specified.
- We set up renewal rules so verifications expire and participants are asked to verify again on the agreed schedule.
How we hand over
- We deliver the source code, a configuration guide, and test results written for the city's technical staff.
- We walk the city's team through the renewal process, the failure messages participants see, and the logs to check.
- We agree in writing which staff member owns the census connection after handover and how credentials are rotated.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, covering changes to the census source.
- Retainers can include retesting the handler after each Decidim minor version upgrade before a participatory process opens.
- Confirm with DeployOpen what support window, response arrangements and change process apply before signing the scope.

