FileGator can read users from a MySQL/MariaDB or PostgreSQL table instead of private/users.json. This is useful when the accounts already live in another application's database.

The table is not created for you

FileGator never creates or migrates the table. Create it first, then point the configuration at it. On startup FileGator checks that the table is readable and refuses to start with an actionable message if it is not.

The column layout is identical to users.json:

ColumnTypeNotes
usernamestring, primary keylogin name
namestringdisplay name
rolestringguest, user or admin
permissionsstringpipe-separated, e.g. `readwritezip`
homedirstringhome folder, / for the storage root
passwordstringbcrypt hash ($2y$…)

MySQL / MariaDB

CREATE TABLE users (
  username    VARCHAR(190) NOT NULL PRIMARY KEY,
  name        VARCHAR(190) NOT NULL DEFAULT '',
  role        VARCHAR(16)  NOT NULL DEFAULT 'user',
  permissions VARCHAR(255) NOT NULL DEFAULT '',
  homedir     VARCHAR(255) NOT NULL DEFAULT '/',
  password    VARCHAR(255) NOT NULL DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO users (username, name, role, permissions, homedir, password)
VALUES ('admin', 'Admin', 'admin',
        'read|write|upload|download|batchdownload|zip|chmod', '/',
        '$2y$10$Nu35w4pteLfc7BDCIkDPkecjw8wsH8Y2GMfIewUbXLT7zzW6WOxwq');

The hash above is the default admin123 password. Change it after the first login. FILEGATOR_ADMIN_PASSWORD does not apply here: it seeds the users file, and a SQL-backed installation never has one.

PostgreSQL

CREATE TABLE users (
  username    TEXT PRIMARY KEY,
  name        TEXT NOT NULL DEFAULT '',
  role        TEXT NOT NULL DEFAULT 'user',
  permissions TEXT NOT NULL DEFAULT '',
  homedir     TEXT NOT NULL DEFAULT '/',
  password    TEXT NOT NULL DEFAULT ''
);

INSERT INTO users (username, name, role, permissions, homedir, password)
VALUES ('admin', 'Admin', 'admin',
        'read|write|upload|download|batchdownload|zip|chmod', '/',
        '$2y$10$Nu35w4pteLfc7BDCIkDPkecjw8wsH8Y2GMfIewUbXLT7zzW6WOxwq');

Configuration

In private/config.json:

{
  "auth": {
    "type": "mysql",
    "sql": {
      "dsn": "filegator:secret@tcp(127.0.0.1:3306)/filegator",
      "table": "users",
      "user_cache_ttl": 60,
      "max_open_conns": 10,
      "max_idle_conns": 5,
      "timeout": 10
    }
  }
}

Use "type": "postgres" with a PostgreSQL DSN:

{
  "auth": {
    "type": "postgres",
    "sql": {
      "dsn": "postgres://filegator:[email protected]:5432/filegator?sslmode=require",
      "table": "users",
      "user_cache_ttl": 60,
      "max_open_conns": 10,
      "max_idle_conns": 5,
      "timeout": 10
    }
  }
}
OptionDefaultMeaning
dsn—driver connection string (required)
tableuserstable name
user_cache_ttl60seconds a resolved user is cached. 0 means the default, not "no cache"
max_open_connsdriver defaultconnection pool limit. 0 leaves the driver's own limit
max_idle_connsdriver defaultidle connections kept
timeout10seconds per query

The same settings are available in Admin → Auth.

What changes with a database provider