Compare commits

...

7 Commits

Author SHA1 Message Date
Abel Hoogeveen 58e885e35f Added the setLocation() method for Output.
Useful for redirecting the user to a different page and automatically setting the correct status header.
2023-02-14 14:55:46 +01:00
Abel Hoogeveen d6863d3f51 Merge pull request 'Fixed bug #3 which caused xss_clean() to fail when calling input variables from arrays.' (#5) from fix/3 into master
Reviewed-on: #5
2022-12-06 11:19:05 +00:00
Abel Hoogeveen 22e3ec2fd0 Fixed bug #3 which caused xss_clean() to fail when calling input variables from arrays.
Closes #3.
2022-12-06 12:18:13 +01:00
Abel Hoogeveen d66c244931
Merge branch 'master' of ssh://gitea.i15.nl:7070/FuzeWorks/WebComponent 2022-03-15 19:24:47 +01:00
Abel Hoogeveen 0e2eb5ef72
`config.web.php` already provides a prefix, so `config.security` should not provide one.
Can be merged later whenever necessary.

Also verifies if the protection is enabled or not.
2022-03-15 19:24:29 +01:00
Abel Hoogeveen 3c7011eddb
`config.web.php` already provides a prefix, so `config.security` should not provide one.
Can be merged later whenever necessary.
2022-03-15 19:18:45 +01:00
Abel Hoogeveen cd331dc39d
Stop lowering cache permissions.
- Temporary solution until ObjectStorage is implemented here.
2021-11-30 11:33:18 +01:00
4 changed files with 31 additions and 11 deletions

View File

@ -9,7 +9,7 @@
}
],
"require": {
"php": ">=7.4.0",
"php": ">=8.1.0",
"fuzeworks/core": "~1.3.0",
"fuzeworks/mvcr": "~1.3.0",
"fuzeworks/objectstorage": "~1.3.0"

View File

@ -50,12 +50,12 @@ return [
| 'csrf_exclude_uris' = Array of URIs which ignore CSRF checks
*/
'csrf_protection' => true,
'csrf_token_name' => 'fw_csrf_token',
'csrf_token_name' => 'csrf_token',
'csrf_expire' => 7200,
'csrf_exclude_uris' => array(),
// CSRF Cookie information
'csrf_cookie_name' => 'fw_csrf_cookie',
'csrf_cookie_name' => 'csrf_cookie',
'csrf_cookie_prefix' => '',
'csrf_cookie_domain' => '',
'csrf_cookie_path' => '/',

View File

@ -326,9 +326,6 @@ class Output
return false;
}
// Lowering permissions to read only
chmod($cachePath, 0640);
// And report back
Logger::logInfo("Output cache has been saved.");
@ -525,4 +522,25 @@ class Output
}
}
/**
* Set the location to redirect the user to.
*
* @param string $locationUrl Should be prepended with /
* @param bool $permanent True for 301, false for 302 redirect.
* @return void
*/
public function setLocation(string $locationUrl, bool $permanent = false)
{
// Set the status header
if ($permanent)
$this->setStatusHeader(301);
else
$this->setStatusHeader(302);
// And the location itself
$header = 'Location: ' . $locationUrl;
$this->headers[] = [$header, true];
}
}

View File

@ -188,7 +188,7 @@ class Security {
$this->input = Factory::getInstance()->input;
// Is CSRF protection enabled?
if ($this->config->csrf_protection)
if ($this->config->get('csrf_protection'))
{
// CSRF config
foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
@ -222,6 +222,10 @@ class Security {
*/
public function csrf_verify(): self
{
// If not enabled, do not run
if (!$this->config->get('csrf_protection'))
return $this;
// If it's not a POST request we will set the CSRF cookie
if (strtoupper($this->input->server('REQUEST_METHOD')) !== 'POST')
return $this->csrf_set_cookie();
@ -371,10 +375,8 @@ class Security {
// Is the string an array?
if (is_array($str))
{
while (list($key) = each($str))
{
$str[$key] = $this->xss_clean($str[$key]);
}
foreach ($str as $key => $value)
$str[$key] = $this->xss_clean($value);
return $str;
}