class CwpBasicAuthMiddleware extends BasicAuthMiddleware implements PermissionProvider (View source)

Properties

protected array $urlPatterns

URL Patterns for basic auth. Keys are the Regexp string to match, and the key can be one of the below:

  • true (bool) - Enabled for this url
  • false (bool) - Disabled for this url
  • Any string / array - Enabled for this url, and require the given string as a permission code
  • null (default) - Calls BasicAuth::protect_site_if_necessary(), which falls back to config setting
from  BasicAuthMiddleware
protected array $whitelistedIps

Whitelisted IP addresses will not be given a basic authentication prompt when other basic authentication rules via BasicAuthMiddleware are enabled.

Methods

public
process(HTTPRequest $request, callable $delegate)

Generate response for the given request

public
array
getURLPatterns()

Get list of url patterns

public
$this
setURLPatterns(array $urlPatterns)

No description

protected
bool|string|array|null
checkMatchingURL(HTTPRequest $request)

Check for any whitelisted IP addresses. If one matches the current user's IP then return false early, otherwise allow the default BasicAuthMiddleware to continue its logic.

public
array
getWhitelistedIps()

No description

public
$this
setWhitelistedIps(string|string[] $whitelistedIps)

No description

protected
bool
ipMatchesWhitelist()

Check whether the current user's IP address is in the IP whitelist

public
providePermissions()

Provide a permission code for users to be able to access the site in test mode (UAT sites). This will apply to any route other than those required to change your password.

Details

HTTPResponse process(HTTPRequest $request, callable $delegate)

Generate response for the given request

Parameters

HTTPRequest $request
callable $delegate

Return Value

HTTPResponse

array getURLPatterns()

Get list of url patterns

Return Value

array

$this setURLPatterns(array $urlPatterns)

No description

Parameters

array $urlPatterns

Return Value

$this

protected bool|string|array|null checkMatchingURL(HTTPRequest $request)

Check for any whitelisted IP addresses. If one matches the current user's IP then return false early, otherwise allow the default BasicAuthMiddleware to continue its logic.

{@inheritDoc}

Parameters

HTTPRequest $request

Return Value

bool|string|array|null

boolean value if enabled/disabled explicitly for this request, or null if should fall back to config value. Can also provide an explicit string / array of permission codes to require for this requset.

array getWhitelistedIps()

No description

Return Value

array

$this setWhitelistedIps(string|string[] $whitelistedIps)

No description

Parameters

string|string[] $whitelistedIps

An array of IP addresses, a comma delimited string, or an array of IPs or comma delimited IP list strings

Return Value

$this

protected bool ipMatchesWhitelist()

Check whether the current user's IP address is in the IP whitelist

Return Value

bool

providePermissions()

Provide a permission code for users to be able to access the site in test mode (UAT sites). This will apply to any route other than those required to change your password.