Files
opensourcepos/.env.example
T
objecttothis c701d21886 fix(sales): gate per-record endpoints behind reports_sales grant (#4627)
fix(sales): gate per-record endpoints behind reports_sales grant (REDACTED)

Cashiers holding only the base `sales` grant could reach per-sale endpoints
(getRow, getEdit, postSave, getReceipt, getInvoice, getSendPdf, getSendReceipt)
that require `reports_sales`. getManage() enforced this at the list level, but
individual endpoints did not re-check. Regression tests added.

Auth:
- Introduce `IsLoggedIn` filter to centralize login checks across controllers
- Replace custom `AccessDeniedRedirectException` with built-in `RedirectException`

Employees:
- Add `DISALLOW_PASSWORD_CHANGE` and `DISALLOW_GRANT_CHANGE` env vars to restrict
  credential and permission changes in locked-down environments
- Extract `hasGrantsChanged()` to streamline `postSave`

Refactor:
- Rename snake_case variables to camelCase in Sales, Items, and Employees
  controllers for PSR-12 compliance
- Use explicit `db_connect()` for transaction clarity in Items controller

Fixes:
- SMTP config entries fall back to defaults via null coalescing
- Migration uses `DROP FOREIGN KEY` instead of `DROP CONSTRAINT`
- Password hash upgrade only sets session on successful `hash_version` update
- Correct lang key for unknown error in Module model

Language:
- Translate `error_grant_change_disallowed` / `error_password_change_disallowed`
  across all 44 supported locales with => alignment matching en reference
- Fix "cannot be deleted" messages and misc typos across ~15 language files

Tests:
- Bootstrap seeder only once in ItemsCsvImportTest; close connection after
- Restore `DISALLOW_GRANT_CHANGE` in teardown to prevent side effects
- Use `uniqid()` for test user data to avoid collisions

Signed-off-by: 17935339+objecttothis@users.noreply.github.com
2026-08-23 17:40:06 +04:00

106 lines
3.8 KiB
Bash

#--------------------------------------------------------------------
# ENVIRONMENT
#--------------------------------------------------------------------
CI_ENVIRONMENT=production
#--------------------------------------------------------------------
# SECURITY: ALLOWED HOSTNAMES
#--------------------------------------------------------------------
# CRITICAL: Whitelist of allowed hostnames to prevent Host Header
# Injection attacks (GHSA-jchf-7hr6-h4f3).
#
# REQUIRED IN PRODUCTION: Application will fail to start if not configured.
# In development, falls back to 'localhost' with an error log.
#
# Configure with comma-separated list of domains/subdomains:
# app.allowedHostnames='yourdomain.com,www.yourdomain.com'
#
# Or via environment variable (useful for Docker/Compose):
# ALLOWED_HOSTNAMES=yourdomain.com,www.yourdomain.com
#
# For local development:
# app.allowedHostnames='localhost'
#
# Note: Do not include protocol (http/https) or port numbers.
app.allowedHostnames=''
#--------------------------------------------------------------------
# DATABASE
#--------------------------------------------------------------------
database.default.hostname='localhost'
database.default.database='ospos'
database.default.username='admin'
database.default.password='pointofsale'
database.default.DBDriver='MySQLi'
database.default.DBPrefix='ospos_'
database.development.hostname='localhost'
database.development.database='ospos'
database.development.username='admin'
database.development.password='pointofsale'
database.development.DBDriver='MySQLi'
database.development.DBPrefix='ospos_'
database.tests.hostname='localhost'
database.tests.database='ospos'
database.tests.username='admin'
database.tests.password='pointofsale'
database.tests.DBDriver='MySQLi'
database.tests.DBPrefix='ospos_'
#--------------------------------------------------------------------
# ENCRYPTION
#--------------------------------------------------------------------
encryption.key=''
#--------------------------------------------------------------------
# LOGGER
# - 0=Disables logging, Error logging TURNED OFF
# - 1=Emergency Messages - System is unusable
# - 2=Alert Messages - Action Must Be Taken Immediately
# - 3=Critical Messages - Application component unavailable, unexpected exception.
# - 4=Runtime Errors - Don't need immediate action, but should be monitored.
# - 5=Warnings - Exceptional occurrences that are not errors.
# - 6=Notices - Normal but significant events.
# - 7=Info - Interesting events, like user logging in, etc.
# - 8=Debug - Detailed debug information.
# - 9=All Messages
#--------------------------------------------------------------------
logger.threshold=0
app.db_log_enabled=false
#--------------------------------------------------------------------
# HONEYPOT
#--------------------------------------------------------------------
honeypot.hidden=true
honeypot.label='Fill This Field'
honeypot.name='honeypot'
honeypot.template='<label>{label}</label><input type="text" name="{name}" value="">'
honeypot.container='<div style="display:none">{template}</div>'
#--------------------------------------------------------------------
# SECURITY: DISALLOW PASSWORD CHANGE
#--------------------------------------------------------------------
# When true, disables the "change password" feature for all employees.
# Useful when passwords are managed by an external system (e.g. SSO/LDAP).
#
# DISALLOW_PASSWORD_CHANGE=false
DISALLOW_PASSWORD_CHANGE=false
#--------------------------------------------------------------------
# SECURITY: DISALLOW GRANT CHANGE
#--------------------------------------------------------------------
# When true, disables changing an employee's grants for all employees.
# New employees cannot be created with grants while this is enabled.
# Useful for demo deployments.
#
# DISALLOW_GRANT_CHANGE=false
DISALLOW_GRANT_CHANGE=false