Home website gpas.lu
  • HTML 42.9%
  • Rust 36.2%
  • CSS 14.6%
  • JavaScript 5.6%
  • Nix 0.7%
Find a file
asyncnomi 2154d42dd2
All checks were successful
Release / build (push) Successful in 6m8s
Release / release (push) Successful in 36s
Merge pull request 'Release v0.1.8' (#10) from dev into main
Reviewed-on: #10
2025-11-02 18:48:07 +00:00
.forgejo/workflows add a worjflow_call to trigger build on release commit 2025-10-04 19:41:10 +00:00
src switch to case-insensitive 2025-11-02 19:37:21 +01:00
static update README & css hover bg color fix on manager auth btn 2025-10-26 19:48:43 +01:00
.gitignore switch to flakes 2025-10-04 18:29:54 +02:00
Cargo.lock switch to case-insensitive 2025-11-02 19:37:21 +01:00
Cargo.toml switch to case-insensitive 2025-11-02 19:37:21 +01:00
flake.lock switch to flakes 2025-10-04 18:29:54 +02:00
flake.nix switch to case-insensitive 2025-11-02 19:37:21 +01:00
README.md update README & css hover bg color fix on manager auth btn 2025-10-26 19:48:43 +01:00

Home App for Gpas.lu

Gpas.lu is designed to works with Dovecot as an IMAP provider. The whole point of this app is to provide both a user interface for creating email, and a management interface.

The database backend only supports SQLite, there is for now no need for something heavier. The relational scheme is far from ideal, I chose it for the sole purpose of easing integration with Dovecot.

There is no database migration script for now.

Build and Run the App

Using Nix

Simply using the flake

nix build

For dev:

nix develop
cargo build --release

It can be tested simply using (you need to define a config.toml first, see below):

cargo run --release -- daemon -f config.toml

Using anything else

You will need the following dependencies to be installed on your system with dev libs

  • pkg-config
  • openssl
  • sqlite

CLI

The main entry exposes a simple CLI:

  • daemon: Start in daemon mode (this is the only mode)
    • --file (-f): provide a path to a configuration file

Configuration

The file take a TOML configuration file as input. Here are all available configuration options.

Structure Overview

The configuration file is organized into several main sections:

  • [server] - Server and application settings
  • [admin] - Administrator authentication
  • [mailer] - Email/SMTP configuration
  • [db] - Database connection settings
  • [quota] - Storage quota limits
  • [governor] - Rate limiting (optional)

Server Configuration

server.domain

Type: String
Required: Yes
Description: The domain name where the application is hosted.

server.static_file_path

Type: String
Required: No
Description: Path to directory containing static files to be served by the application (if the parameter is not declared, the static files won't be served, you can then use your own web server).

server.reserved_usernames

Type: Array of strings
Required: No
Description: List of usernames that cannot be registered by users (e.g., "admin", "root", "postmaster").

server.maildir_prefix

Type: String (absolute path)
Required: Yes
Description: Absolute path to the directory where user maildirs will be stored. Must be an absolute path starting with /. Users mail directory MUST match <server.maildir_prefix>/<username>

server.address

Type: String
Required: No
Description: IP address the server will bind to. Overrides Rocket.toml settings if specified, will be overrided by rocket ENV var if specified.

server.port

Type: Integer
Required: No
Description: Port number the server will listen on. Overrides Rocket.toml settings if specified,, will be overrided by rocket ENV var if specified.

server.workers

Type: Integer
Required: No
Description: Number of worker threads for handling requests. Overrides Rocket.toml settings if specified, will be overrided by rocket ENV var if specified.

server.log_level

Type: String
Required: No
Description: Logging verbosity level. Overrides Rocket.toml settings if specified, will be overrided by rocket ENV var if specified.

server.secret_key

Type: String
Required: No
Description: Secret key for session encryption and signing. Overrides Rocket.toml settings if specified, will be overrided by rocket ENV var if specified. Can also reference an environment variable using $__VARIABLE_NAME syntax. The value can be generated using: head -c64 /dev/urandom | base64.


Admin Configuration

admin.master_hash

Type: String
Required: Yes
Description: Bcrypt hash of the master admin password. Can reference an environment variable using $__VARIABLE_NAME syntax. The value can be generated using: python -c "import bcrypt; print(bcrypt.hashpw(b'<password>', bcrypt.gensalt()).decode())"


Mailer Configuration

mailer.from

Type: String
Required: Yes
Description: Email address to use as the "From" address for outgoing emails.

mailer.password

Type: String
Required: No
Description: Password for SMTP authentication. Can reference an environment variable using $__VARIABLE_NAME syntax.

mailer.smtp_addr

Type: String
Required: Yes
Description: SMTP server address (e.g., "smtp.example.com").

mailer.smtp_port

Type: Integer (u16)
Required: Yes
Description: SMTP server port number (e.g., 587 for STARTTLS, 465 for SSL/TLS, ...).

mailer.smtp_tls

Type: Boolean
Required: Yes
Description: Whether to use TLS encryption for the SMTP connection.

mailer.admin

Type: String
Required: Yes
Description: Email address of the administrator who should receive system notifications.


Database Configuration

db.url

Type: String
Required: Yes
Description: Database connection URI.

db.pool_size

Type: Integer
Required: Yes
Description: Maximum number of database connections in the connection pool.

db.timeout

Type: Integer (seconds)
Required: Yes
Description: Connection timeout in seconds.


Quota Configuration

All quota values support human-readable size formats (e.g., "1GB", "500MB", "10GiB").

quota.per_user_limit

Type: Size string
Required: Yes
Description: Maximum storage quota per user (e.g., "1GB", "500MB").

quota.per_user_min

Type: Size string
Required: Yes
Description: Minimum required storage quota per user.

quota.global_limit

Type: Size string
Required: Yes
Description: Total storage limit across all users.


Governor Configuration (Optional)

This entire section is optional.

governor.global_limit

Type: Integer
Required: No
Description: Global rate limit for API requests (requests per seconds).


Example Configuration

[server]
domain = "mail.example.com"
static_file_path = "./static"
maildir_prefix = "/var/mail/users"
reserved_usernames = ["admin", "root", "postmaster", "abuse"]
address = "0.0.0.0"
port = 8000
secret_key = "$__SECRET_KEY"

[admin]
master_hash = "$__ADMIN_HASH"

[mailer]
from = "noreply@example.com"
password = "$__SMTP_PASSWORD"
smtp_addr = "smtp.example.com"
smtp_port = 465
smtp_tls = true
admin = "admin@example.com"

[db]
url = "./test.db"
pool_size = 10
timeout = 30

[quota]
per_user_limit = "1GB"
per_user_min = "100MB"
global_limit = "100GB"

[governor]
global_limit = 100