Documentation

Security extends BaseConfig
in package

Class BaseConfig

Not intended to be used on its own, this class will attempt to automatically populate the child class' properties with values from the environment.

These can be set within the .env file.

Table of Contents

$cookieName  : string
-------------------------------------------------------------------------- CSRF Cookie Name --------------------------------------------------------------------------
$expires  : int
-------------------------------------------------------------------------- CSRF Expires --------------------------------------------------------------------------
$headerName  : string
-------------------------------------------------------------------------- CSRF Header Name --------------------------------------------------------------------------
$redirect  : bool
-------------------------------------------------------------------------- CSRF Redirect --------------------------------------------------------------------------
$regenerate  : bool
-------------------------------------------------------------------------- CSRF Regenerate --------------------------------------------------------------------------
$registrars  : array<string|int, mixed>
An optional array of classes that will act as Registrars for rapidly setting config class properties.
$samesite  : string
-------------------------------------------------------------------------- CSRF SameSite --------------------------------------------------------------------------
$tokenName  : string
-------------------------------------------------------------------------- CSRF Token Name --------------------------------------------------------------------------
$didDiscovery  : bool
Has module discovery happened yet?
$moduleConfig  : Modules
The modules configuration.
__construct()  : mixed
Will attempt to get environment variables with names that match the properties of the child class.
getEnvValue()  : mixed
Retrieve an environment-specific configuration setting
initEnvValue()  : mixed
Initialization an environment-specific configuration setting
registerProperties()  : mixed
Provides external libraries a simple way to register one or more options into a config file.

Properties

$cookieName

-------------------------------------------------------------------------- CSRF Cookie Name --------------------------------------------------------------------------

public string $cookieName = 'csrf_cookie_name'

Cookie name for Cross Site Request Forgery protection cookie.

$expires

-------------------------------------------------------------------------- CSRF Expires --------------------------------------------------------------------------

public int $expires = 7200

Expiration time for Cross Site Request Forgery protection cookie.

Defaults to two hours (in seconds).

$headerName

-------------------------------------------------------------------------- CSRF Header Name --------------------------------------------------------------------------

public string $headerName = 'X-CSRF-TOKEN'

Token name for Cross Site Request Forgery protection cookie.

$redirect

-------------------------------------------------------------------------- CSRF Redirect --------------------------------------------------------------------------

public bool $redirect = true

Redirect to previous page with error on failure.

$regenerate

-------------------------------------------------------------------------- CSRF Regenerate --------------------------------------------------------------------------

public bool $regenerate = true

Regenerate CSRF Token on every request.

$registrars

An optional array of classes that will act as Registrars for rapidly setting config class properties.

public static array<string|int, mixed> $registrars = []

$samesite

-------------------------------------------------------------------------- CSRF SameSite --------------------------------------------------------------------------

public string $samesite = 'Lax'

Setting for CSRF SameSite cookie token.

Allowed values are: None - Lax - Strict - ''.

Defaults to Lax as recommended in this link:

Tags
see
https://portswigger.net/web-security/csrf/samesite-cookies
deprecated

$tokenName

-------------------------------------------------------------------------- CSRF Token Name --------------------------------------------------------------------------

public string $tokenName = 'csrf_token_name'

Token name for Cross Site Request Forgery protection cookie.

$didDiscovery

Has module discovery happened yet?

protected static bool $didDiscovery = false

Methods

__construct()

Will attempt to get environment variables with names that match the properties of the child class.

public __construct() : mixed

The "shortPrefix" is the lowercase-only config class name.

Return values
mixed

getEnvValue()

Retrieve an environment-specific configuration setting

protected getEnvValue(string $property, string $prefix, string $shortPrefix) : mixed
Parameters
$property : string
$prefix : string
$shortPrefix : string
Return values
mixed

initEnvValue()

Initialization an environment-specific configuration setting

protected initEnvValue(mixed &$property, string $name, string $prefix, string $shortPrefix) : mixed
Parameters
$property : mixed
$name : string
$prefix : string
$shortPrefix : string
Return values
mixed

registerProperties()

Provides external libraries a simple way to register one or more options into a config file.

protected registerProperties() : mixed
Tags
throws
ReflectionException
Return values
mixed

Search results