mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-04 14:13:52 +09:00
* Refactor database connection to use `DriverManagerFactory`
* Add Doctrine DBAL connection to DI container
Revert "Add Doctrine DBAL connection to DI container"
This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.
Reapply "Add Doctrine DBAL connection to DI container"
This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.
* Refactor database access to use Doctrine DBAL
* Refactor DB config to use 'driver' instead of 'type'
* Refactor database connection to use `DriverManagerFactory`
* Add Doctrine DBAL connection to DI container
Revert "Add Doctrine DBAL connection to DI container"
This reverts commit bc2f9f4901d8baee4b12cd2795b0ef76156849cf.
Reapply "Add Doctrine DBAL connection to DI container"
This reverts commit 48debb74bbfa6c8cebf27ee20c222c911d508ccb.
* Refactor database access to use Doctrine DBAL
* Refactor DB config to use 'driver' instead of 'type'
* Refactor tests to use `dbal` mocks
* Replace `getQueryBuilder` with `createQueryBuilder
* Fix handling of empty query results and cleanup exception comment
* Update Composer lock file
* Refactor PDO initialization in DI container
Updated the DI definition for 'pdo' to directly use the PDO instance returned by Doctrine's DriverManagerFactory, removing unnecessary object casting. Also added missing import for DriverManagerFactory. Updated PHPStan config to remove a redundant ctype_alnum rule.
* Refactor query execution and result fetching logic
Updated database query handling in Extension and System Service classes to separate query building from execution and fetching. This improves code clarity and ensures consistent use of fetchOne for single-value results.
* Fix SQL where clause syntax in Service.php
Corrects the syntax of the where clause in several queries by changing 'where('param', ':param')' to 'where('param = :param')' for proper parameter binding and query execution.
* Refactor Stats module to use Doctrine DBAL
* Refactor Custompages Service to use dbal instead of pdo
Replaced all direct PDO usage with dbal methods for database operations in the Custompages Service. This improves consistency, leverages dbal's abstraction, and prepares the codebase for better maintainability and future enhancements.
* Refactor DBAL usage and update test mocks
Refactored DBAL service definitions and query builder usage to improve clarity and consistency. Updated tests to use anonymous classes for DBAL and query builder mocks instead of PHPUnit mock objects, simplifying test setup and improving maintainability.
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor DB queries to use executeQuery and executeStatement
Replaced manual PDO prepare/execute calls with Doctrine DBAL's executeQuery and executeStatement methods in UpdatePatcher and ApiRequestTable. This improves code consistency and leverages DBAL features for query execution and result fetching.
* Add input validation for DB charset, table, and column names
Introduces strict validation for supported database charsets in DriverManagerFactory, allowed column names in Custompages Service, and allowed table names in Stats Service to prevent invalid or unsafe input. Also updates UpdatePatcher with default values for new config keys and adjusts a Stats Service test to use a valid table name.
* Add 'CHARSETS' to cspell custom words list
* Refactor query execution in patcher and product domain
Updated query builder usage in UpdatePatcher and ProductDomainTable to separate query building from execution, aligning with best practices. Removed unused fetchOne stubs from ServiceTest to reflect these changes.
Co-Authored-By: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor `getProductSummary` to use Doctrine DBAL
* Fix parameter binding for category and hash in UpdatePatcher
Updated the insert statement in UpdatePatcher to bind the 'category' and 'hash' parameters explicitly, ensuring correct handling of null values during database insertion.
* Update MySQL charset handling in PDO setup
Removes redundant charset initialization statements for MySQL connections, relying on DBAL to handle connection charset via DSN. Now only sets the server default charset and session timeouts.
* Set default DB driver to `pdo_mysql` in `UpdatePatcher`
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
202 lines
6.6 KiB
PHP
202 lines
6.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* FOSSBilling configuration file example.
|
|
*
|
|
* If you are not using the web installer, you can rename this file
|
|
* to "config.php" and fill in the values.
|
|
* Import /install/sql/structure.sql to your database
|
|
* Import /install/sql/content.sql to your database
|
|
* Open browser https://www.yourdomain.com/admin to create a new admin account.
|
|
* Remove /install directory
|
|
*
|
|
* For more information, see the documentation: https://fossbilling.org/docs/customizing-fossbilling/config
|
|
*/
|
|
|
|
return [
|
|
/*
|
|
* These configuration options allow you to configure the security options inside of FOSSBilling.
|
|
* The default values are what we recommended running unless they are causing issues.
|
|
*/
|
|
'security' => [
|
|
'mode' => 'strict',
|
|
'force_https' => true,
|
|
'session_lifespan' => 7200,
|
|
'perform_session_fingerprinting' => true,
|
|
'debug_fingerprint' => false,
|
|
],
|
|
|
|
'debug_and_monitoring' => [
|
|
/*
|
|
* Enable or disable displaying advanced debugging messages.
|
|
* You should keep this disabled unless you're making tests as it can reveal some information about your server.
|
|
*/
|
|
'debug' => false,
|
|
/*
|
|
* Enable or disable stacktraces when an exception is thrown (also requires debug to be enabled).
|
|
*/
|
|
'log_stacktrace' => true,
|
|
/*
|
|
* How long the stacktrace should be.
|
|
*/
|
|
'stacktrace_length' => 25,
|
|
|
|
/*
|
|
* Enables automated error, stability, and performance reporting.
|
|
* Private information is scrubbed from any info before being sent.
|
|
* FOSSBilling uses Sentry.io for error reporting which has a full writeup on their security and privacy practices here: https://sentry.io/security/.
|
|
* Enabling error reporting will help us proactively identify and fix bugs in FOSSBilling as well as provide better technical support.
|
|
*/
|
|
'report_errors' => false,
|
|
],
|
|
|
|
'info' => [
|
|
'salt' => bin2hex(random_bytes(16)),
|
|
'instance_id' => 'XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXXX',
|
|
],
|
|
|
|
/*
|
|
* Full URL where FOSSBilling is installed with trailing slash.
|
|
*/
|
|
'url' => 'localhost/',
|
|
|
|
/*
|
|
* The URL prefix to access the BB admin area. Ex: '/admin' for https://example.com/admin.
|
|
*/
|
|
'admin_area_prefix' => '/admin',
|
|
|
|
/*
|
|
* Configure the update branch for the automatic updater.
|
|
* Currently acceptable options are "release" or "preview".
|
|
*/
|
|
'update_branch' => 'release',
|
|
|
|
'maintenance_mode' => [
|
|
/*
|
|
* Enable or disable the system maintenance mode.
|
|
* Enabling this will block public access to your website, and API endpoints except the allowed ones won't work
|
|
* However, this will not block access to the administrator area.
|
|
*/
|
|
'enabled' => false,
|
|
|
|
/*
|
|
* Don't block these URLs when the maintenance is going on.
|
|
* Supports wildcard (e.g. '/api/guest/staff/*').
|
|
*/
|
|
'allowed_urls' => [],
|
|
|
|
/*
|
|
* Don't block these IP/Subnet addresses when the maintenance is going on.
|
|
* Supported formats: 127.0.0.1、127.0.0.1/32.
|
|
*/
|
|
'allowed_ips' => [],
|
|
],
|
|
|
|
/*
|
|
* FOSSBilling will automatically execute cron when you login to the admin panel if it hasn't been executed in awhile. You can disable this fallback here.
|
|
*/
|
|
'disable_auto_cron' => true,
|
|
|
|
/*
|
|
* These configuration options allow you to configure the default localisation.
|
|
*/
|
|
'i18n' => [
|
|
'locale' => 'en_US',
|
|
'timezone' => 'UTC',
|
|
|
|
// Short names for formats (none, short, medium, long).
|
|
// @see https://www.php.net/manual/en/class.intldateformatter.php
|
|
'date_format' => 'medium',
|
|
'time_format' => 'short',
|
|
|
|
// Specifying a pattern will override the above date/time options.
|
|
// @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
|
|
'datetime_pattern' => '',
|
|
],
|
|
|
|
/*
|
|
* Set location to store sensitive data.
|
|
*/
|
|
'path_data' => __DIR__ . '/data',
|
|
|
|
'db' => [
|
|
/*
|
|
* Database type. Don't change this if in doubt.
|
|
*/
|
|
'driver' => 'pdo_mysql',
|
|
|
|
/*
|
|
* Database hostname. Don't change this if in doubt.
|
|
*/
|
|
'host' => getenv('DB_HOST') ?: '127.0.0.1',
|
|
|
|
/*
|
|
* The name of the database for FOSSBilling.
|
|
*/
|
|
'name' => getenv('DB_NAME') ?: 'fossbilling',
|
|
|
|
/*
|
|
* Database username.
|
|
*/
|
|
'user' => getenv('DB_USER') ?: 'foo',
|
|
|
|
/*
|
|
* Database password.
|
|
*/
|
|
'password' => getenv('DB_PASS') ?: 'bar',
|
|
|
|
/*
|
|
* Database Port.
|
|
*/
|
|
'port' => getenv('DB_PORT') ?: '3306',
|
|
],
|
|
|
|
'twig' => [
|
|
'debug' => false,
|
|
'auto_reload' => true,
|
|
'cache' => __DIR__ . '/data/cache',
|
|
],
|
|
|
|
'api' => [
|
|
// All requests made to the API must have referrer request header with the same URL as the FOSSBilling installation
|
|
'require_referrer_header' => false,
|
|
|
|
// Empty array will allow all IPs to access the API
|
|
'allowed_ips' => [],
|
|
|
|
// Time span for limit in seconds
|
|
'rate_span' => 60 * 60,
|
|
|
|
// How many requests allowed per time span
|
|
'rate_limit' => 1000,
|
|
|
|
/**
|
|
* Note about rate-limiting login attempts:
|
|
* When the limit is reached, a default delay of 2 seconds is added to the request.
|
|
* This makes brute-forcing a password useless while not outright blocking legitimate traffic.
|
|
* When calculating, ensure the rate-limited traffic can still make enough requests to stay rate limited
|
|
* Ex: One request every 2 seconds is more than 20 times in 1 minute, so the IP will remain throttled.
|
|
*/
|
|
'throttle_delay' => 2,
|
|
|
|
// Time span login for limit in seconds
|
|
'rate_span_login' => 60,
|
|
|
|
// How many login requests allowed per time span
|
|
'rate_limit_login' => 20,
|
|
|
|
/*
|
|
* This enables the usage of a token to protect the system from CSRF attacks.
|
|
* Disabling this is highly discouraged and opens your instance to a known vulnerability.
|
|
* This option is only here for backwards compatibility.
|
|
*/
|
|
'CSRFPrevention' => true,
|
|
|
|
/**
|
|
* Any IP address within this list will not be put through the rate-limiter system.
|
|
* This is useful if you have an application with a static IP address that needs to make frequent API requests to FOSSBilling.
|
|
*/
|
|
'rate_limit_whitelist' => [],
|
|
],
|
|
];
|