Four database access roles for one product

The hypothetical matrix for a migrator, editorial process, public reader, and background consumer: where permissions and rejection checks matter.

Four different keys beside shared storage: a metaphor for distinct process permissions.
Four different keys beside shared storage: a metaphor for distinct process permissions.

Reading, editing, background tasks, and schema changes need different permissions.

One database can serve several different tasks. A public page reads articles. An editorial panel changes them. A background process prepares a derived result or handles an event. A separate operation changes the structure of the tables.

If all these actions run with the same broad permissions, the reach of an error or an unwanted action also grows. Solution200's server series considers these needs through four roles: a migrator, an editorial application, public reading, and a background process. Let us consider a hypothetical model for one journal.

The task determines the role

A database account represents a process's technical permissions. Its privileges need to match the operations that the process requires.

The migrator performs an accepted schema change. The editorial process reads and changes defined data. The public reading process retrieves the required content. The background consumer works only with the data and service state needed by its scenario.

An application's name alone is not a sufficient basis for permissions. For example, a Frontend with user login may have separate write requirements. These need to be defined for the specific capability. The matrix below concerns only public article reading and does not establish a universal rule for all web applications.

A hypothetical permissions matrix

RoleRequired behavior in the examplePermissions not needed for this behavior
MigratorPerform a defined schema change and track migrationsContinuously serve public requests
Editorial processRead and change editorial dataArbitrarily change the database structure
Public readingRead permitted contentChange articles or the schema
Background processHandle its own events and required service stateManage all data belonging to other scenarios

These are functional roles. They are not ready-made sets of GRANT commands. The exact tables and permissions depend on the implementation, migrations, execution tracking, and other required operations. The MySQL documentation defines separate privileges for reading, changing data, and changing structure.

The migrator role also does not mean that every migration needs unrestricted administrative privileges. The actual operations of the accepted transition need to be identified: a migration may also transform data, so its required write privileges are determined separately. A serving process's lasting permissions and a brief schema change operation have different lifecycles.

Permission to read a table is not permission to publish every article

Database permissions and product rules operate at different levels. A technical process may have permission to read a particular table, but the application must still select only the articles permitted for public presentation.

Likewise, separate accounts alone do not establish data boundaries between several sites. If tables contain data belonging to different consumers, the context needs to be explicitly defined and consistently applied. A name or prefix in the data does not replace this check.

In the hypothetical journal, a hidden draft must not enter the public list merely because reading the table is technically allowed. This scenario needs checking at the level of the relevant content capability.

Check both access and rejection

A positive check shows that a process can perform a required action. A rejection check shows that a defined unnecessary action actually fails.

For public reading, a hypothetical set of questions is: can permitted content be read; is an attempt to change data rejected; is unnecessary access to another defined data set absent; and does the selection return the correct visible articles?

A simple SELECT 1 query is useful for a particular connection check, but it does not confirm permission to read a specific table. MySQL allows expressions to be evaluated without accessing tables. The method therefore needs to match the intended conclusion.

Permission changes and write checks should not be performed casually on production data. A learning scenario needs defined test data and a controlled environment.

From a model to configuration

The matrix helps separate processes' needs. Moving to specific configuration requires identifying the accounts, tables, and operations of each scenario, then checking actual rejection in the appropriate environment.

A useful starting point is to list the processes' tasks and the operations they need. Then check both required access and defined unnecessary permissions.

  1. Architecture Admin, Frontend, and API: three distinct responsibilities
  2. Observability Why a VPS snapshot is not enough for recovery
  3. Data & Infrastructure MySQL 8.4: an owned server with separate migrator and runtime access
  4. API Permission to act and permission to access data: two checks for one API request
  5. Symfony Core One migration owner for several applications

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article