From 93899554d13f8db39a9aa3446fa0e53c90054b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ya=C4=9F=C4=B1zhan?= Date: Tue, 12 May 2026 20:15:20 +0300 Subject: [PATCH 01/10] Added information about configuring the rate limiter --- .../docs/customizing-fossbilling/config.mdoc | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/content/docs/customizing-fossbilling/config.mdoc b/src/content/docs/customizing-fossbilling/config.mdoc index 1b99d88..4429bf5 100644 --- a/src/content/docs/customizing-fossbilling/config.mdoc +++ b/src/content/docs/customizing-fossbilling/config.mdoc @@ -101,21 +101,33 @@ Temporarily disable public access. Use `allowed_urls` for endpoints that must st ### API Settings -Control API access and rate limiting. Use `require_referrer_header` to lock browser-originated requests to your install URL, `allowed_ips` for explicit allowlists, and the `rate_*` values to tune throttling. +Control API access. Use `require_referrer_header` to lock browser-originated requests to your install URL, and `allowed_ips` for explicit allowlists. ```php 'api' => [ 'require_referrer_header' => true, 'allowed_ips' => [], - 'rate_span' => 60, - 'rate_limit' => 100, - 'throttle_delay' => 2, - 'rate_span_login' => 60, - 'rate_limit_login' => 20, 'CSRFPrevention' => true, ], ``` +### Rate Limiter +FOSSBilling includes a built-in rate limiter which depends on Symfony's [rate limiter](https://symfony.com/doc/current/rate_limiter.html) component. + +`policies` is an empty array by default and inherits sensible defaults from [`FOSSBilling\Security\RateLimiter::getDefaultConfig()`](https://github.com/FOSSBilling/FOSSBilling/blob/9acf34ec12f908e01e516b7d54839e155b990b9d/src/library/FOSSBilling/Security/RateLimiter.php#L37). + +Any policy you explicitly set in the `policies` array will override the default one. We have included an example below. You can refer to their documentation on creating rate limiter policies. + +```php +'rate_limiter' => [ + 'enabled' => true, + 'whitelist_ips' => [], // Array of whitelisted IP addresses and CIDRs + 'policies' => [ + 'client_signup' => ['policy' => 'fixed_window', 'limit' => 5, 'interval' => '1 hour'], + ], +], +``` + ## Environment Variables Some settings can be overridden via environment variables: From d3b76994d6c4025218b812c946a261af0a27a648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ya=C4=9F=C4=B1zhan?= Date: Wed, 13 May 2026 00:13:58 +0300 Subject: [PATCH 02/10] Update invoice PDF documentation for v0.8 --- .../customizing-fossbilling/invoice-pdf.mdoc | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/content/docs/customizing-fossbilling/invoice-pdf.mdoc b/src/content/docs/customizing-fossbilling/invoice-pdf.mdoc index a7c7adf..fa2a36a 100644 --- a/src/content/docs/customizing-fossbilling/invoice-pdf.mdoc +++ b/src/content/docs/customizing-fossbilling/invoice-pdf.mdoc @@ -7,13 +7,14 @@ FOSSBilling generates invoice PDFs with [Dompdf](https://github.com/dompdf/dompd ## CSS Limitations -Dompdf doesn't support everything. As of version 2.0.3: +Dompdf is not a complete PDF engine. FOSSBilling uses Dompdf 3.x, which supports many print-friendly CSS features but still has layout limitations: | Supported | Not Supported | |-----------|---------------| | CSS 2.1 and some CSS3 | Flexbox | | `@import`, `@media`, `@page` | CSS Grid | -| Basic positioning | Complex layouts | +| CSS custom properties and math functions such as `calc()` | Browser-style complex layouts | +| Basic positioning and table layouts | Splitting table rows or cells across pages | {% aside type="tip" %} Table cells can't span pages. Keep table rows compact enough to fit on one page. @@ -23,37 +24,41 @@ Table cells can't span pages. Keep table rows compact enough to fit on one page. ### Creating a Custom Stylesheet -1. Copy `/modules/Invoice/pdf_template/default-pdf.css` -2. Paste as `/modules/Invoice/pdf_template/custom-pdf.css` +1. Copy `/modules/Invoice/templates/pdf/default-invoice.css` +2. Paste as `/modules/Invoice/templates/pdf/custom-invoice.css` -FOSSBilling automatically uses `custom-pdf.css` if it exists. +FOSSBilling automatically uses `custom-invoice.css` if it exists. {% aside type="caution" %} -Editing `default-pdf.css` directly is overwritten on updates. Always use `custom-pdf.css`. +Editing `default-invoice.css` directly is overwritten on updates. Always use `custom-invoice.css`. {% /aside %} ### CSS Classes Reference ![PDF layout with CSS classes](../../../assets/invoice-layout.png) -Common classes include: +The default stylesheet uses these classes: -- `.invoice-header` — Company and client info -- `.invoice-details` — Invoice number, date, due date -- `.invoice-items` — Line items table -- `.invoice-totals` — Subtotal, tax, total -- `.invoice-footer` — Terms, notes +- `.CompanyLogo` — Company logo image +- `.TopSectionDivider` — Divider below the header area +- `.InvoiceInfo` — Invoice number, dates, and status +- `.CompanyInfo` — Seller/company heading and details +- `.ClientInfo` — Client heading and details +- `.Breakdown` — Line items, tax, discount, and total table +- `.InvoiceText` — Custom invoice text blocks +- `.InvoiceFooter` — Payment details, company footer, and signature +- `.muted-text` — Muted footer signature text ## Custom HTML Template -**FOSSBilling 0.6.0+**: Customize the HTML structure. +Customize the HTML structure by adding a custom Twig template. ### Creating a Custom Template -1. Copy `/modules/Invoice/pdf_template/default-pdf.twig` -2. Paste as `/modules/Invoice/pdf_template/custom-pdf.twig` +1. Copy `/modules/Invoice/templates/pdf/default-invoice.twig` +2. Paste as `/modules/Invoice/templates/pdf/custom-invoice.twig` -FOSSBilling uses `custom-pdf.twig` automatically. +FOSSBilling uses `custom-invoice.twig` automatically. ### Template Variables @@ -61,17 +66,24 @@ Available in PDF templates: | Variable | Description | |----------|-------------| -| `invoice` | Invoice data (id, total, items, etc.) | -| `client` | Client information | -| `company` | Your company details | -| `currency` | Currency code and symbol | +| `currency_code` | Invoice currency code for `format_currency`. | +| `css` | Contents of `custom-invoice.css` or `default-invoice.css`, inserted into the template's `