Luminova Framework

PHP Luminova: Request and File Security Configuration

Last updated: 2026-06-05 23:34:03

Security configuration for Luminova applications. Allow you to manage default file permissions, HTTP request trusted origins, hostnames, CORS, and API-specific security settings for safe and consistent request validation.

The Security configuration class defines properties for managing security settings in luminova applications. It controls file permissions and trusted origins, hostnames, and other security rules used by Luminova\Http\Request and Luminova\Http\Header to authenticate incoming requests.

Additionally, it includes essential settings for securing your API endpoints, such as allowed origins, headers, and credentials, ensuring consistent and safe API access.


  • Class namespace: \App\Config\Security
  • File path: /app/Config/Security.php
  • This class is marked as final and can't be subclassed

Properties

filePermissions

Set Unix file permission, to use while creating a new file in your application.

public static int $filePermissions = 0644;

dirPermissions

Set Unix directory permission, to use while creating a new directory.

public static int $dirPermissions = 0755;

enforceApiSecurityOnHttp

Apply API-style security to all HTTP requests.

If set to true, all incoming HTTP requests (not just API requests)will be validated using the same security rules as API requests, including:

  • forbidEmptyOrigin
  • allowCredentials
  • allowOrigins
  • allowHeaders
public bool $enforceApiSecurityOnHttp = false;

This is useful when you want consistent security enforcement across web pages, AJAX calls, and API endpoints.


forbidEmptyOrigin

Whether to reject API requests with an empty Origin header.

This property controls whether to forbid requests with an empty Origin header.If true, requests without an Origin header are denied.

public bool $forbidEmptyOrigin = true

allowCredentials

Whether to include credentials in API responses.

This property controls whether to allow credentials header in API requests.If true, the Access-Control-Allow-Credentials header is sent.

public bool $allowCredentials = true

allowOrigins

Allowed origins for incoming API requests.

This property controls which origins should be allowed to access API endpoints.

  • Use '*' to allow any origin.
  • Use the string 'null' to also allow all origins explicitly.
  • Provide an array to restrict to specific origins.
public string|array<int,string> $allowOrigins = '*'

Example:

public string|array $allowOrigins = [
    'https://example.com',
    'https://luminova.ng',
    '127.0.0.1'
]

allowHeaders

Allowed request headers for API requests.

This property controls which headers should be allowed in request headers when accessing API endpoints.

public array<int,string> $allowHeaders = []

An empty array allows all headers by default.

Example:

public array $allowHeaders = [
    'Content-Type',
    'Authorization',
    'X-Requested-With',
    'Host',
    'Accept', 
    'User-Agent'
];

Note:When you define a custom headers to only allow, if request is sent with none matching headers, it will fail.


trustedOrigins

Set the list of trusted origin domains or patterns.

public array<int,string> $trustedOrigins = [];

This will be use in Request class for authenticating incoming requests origin.

If none is specified then not additional check will be done when you call method request()->getOrigin() or request()->isTrustedOrigin().


trustedHostname

Set the list of trusted hostname or patterns.

public array<int,string> $trustedHostname = [];

This will be use in Request class for authenticating your hostname.

If none is specified then not additional check will be done when you call method request()->getHostname().