Repository navigation
07. The database servers
The databases to be displayed in Jaxon DbAdmin are defined in the servers.php config file.
Note
If aservers.json,servers.yamlorservers.ymlfile is provided, it will be used instead.
In that file, theenv('DBA_PGSQL_HOST')value is set as'env(DBA_PGSQL_HOST)';
It takes advantage of the configuration provider feature of Jaxon packages to customize the database list depending on the authenticated user.
This is an example of a servers.php config file.
[
'common' => [
'access' => [
'server' => false,
'system' => false
],
'servers' => [
'db-postgresql' => [
'driver' => 'pgsql',
'name' => 'PostgreSQL 14',
'host' => env('DBA_PGSQL_HOST'),
'port' => env('DBA_PGSQL_PORT')
],
'db-mariadb' => [
'driver' => 'mysql',
'name' => 'MariaDB 10',
'host' => env('DBA_MARIA_HOST'),
'port' => env('DBA_MARIA_PORT')
],
'db-mysql' => [
'driver' => 'mysql',
'name' => 'MySQL 8',
'host' => env('DBA_MYSQL_HOST'),
'port' => env('DBA_MYSQL_PORT')
]
]
],
'fallback' => [],
'users' => [[
'id' => [
'users' => [
'user1@company.com',
'user2@company.com'
]
],
'servers' => [
'db-postgresql' => [
'username' => env('DBA_PGSQL_USERNAME'),
'password' => env('DBA_PGSQL_PASSWORD')
],
'db-mysql' => [
'username' => env('DBA_MYSQL_USERNAME'),
'password' => env('DBA_MYSQL_PASSWORD')
],
'laravel' => [
'driver' => 'sqlite',
'name' => 'Laravel',
'directory' => env('SQLITE_LARAVEL_DIR')
]
]
], [
'id' => [
'user' => 'admin@company.com'
],
'access' => [
'server' => true,
'system' => true
],
'servers' => [
'db-mariadb' => [
'username' => env('DBA_MARIA_USERNAME'),
'password' => env('DBA_MARIA_PASSWORD')
],
'db-mysql' => [
'username' => env('DBA_MYSQL_USERNAME'),
'password' => env('DBA_MYSQL_PASSWORD')
],
'sqlite-3' => [
'driver' => 'sqlite',
'name' => 'Sqlite 3',
'directory' => env('SQLITE_DEFAULT_DIR')
]
]
]]
]This section contains options that are shared for all users. The options in this section will be merged with the user options found. Which also means that if no entry is found for a given user, these options are not returned.
The options in this entry will be returned if no specific entry exists for the authenticated user in the users entry.
These options will be merged with the common options.
This entry contains an array of options, each for a given user or group of users.
Each entry in the array must have an attribute with id key, which itself is an object with 4 possible attributes to identify the corresponding users:
-
user: a single user email. -
users: an array of user emails. -
role: a single user role. -
roles: an array of user roles.
The other attributes are the database options, described in the following paragraph.
If any entry is found here for the current user, its value will be merged with the common options.
The common, fallback and each entry in users array contain the same options, excepted the id option in the servers array items.
The servers entry lists the database servers to be managed.
For each value in the entry, the key is the unique identifier used in requests to the Jaxon DbAdmin application.
The driver option indicate the corresponding DBMS: pgsql for PostgreSQL, mysql for MySQL or MariaDB, and sqlite for SQLite.
The name option is the name to be displayed in the UI.
The other options depend on the DBMS.
For SQLite, the directory option is a directory where to look for database files.
Each file in the directory with the db, sdb or sqlite extension is listed as a database.
For the other DBMS, the host, port, username and password options will be used to connect to the database server. Only the port option is optional.
Except for driver and name, the values for all the other options can be loaded from env vars.
In a json config file, the option can be set in a specific format like env(DBA_PGSQL_HOST), where the value in the parenthesis is the env var name.
In addition to the default .env, the application also loads the .env.dbadmin file, which can be used to define the Jaxon DbAdmin specific env vars.
After the merge with the options in the common section, the entries in the servers options are filtered on valid values.
As a consequence, only the entries for which all the required options (except port) are provided will be returned in the final list.
The default entry defines a server the application will connect to when the web page is loaded or refreshed.
The access entry is an object that contains multiple options to define to which databases and to which part of the application the user will have access.
The access entry can be defined at top level, in this case it applies to all the database servers, or it can be defined in a specific server options, to be applied only to that server.
In the access value, the system entry defines if the user has access to system databases and schemas. If set to false, which is the default, the system databases will not be listed in the user account.
The server entry defines if the user has access to server specific pages. If set to false, which is the default, the user will not have access to the Databases, Process list and Variables pages, as well as the server-related Query, Import and Export pages.
The corresponding menu entries will not be displayed in the sidebar menu.
The databases and schemas entries restrict the user access to the listed databases and schemas.