Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rex_response um Nonce Generator ergänzt #5510

Merged
merged 4 commits into from
Jan 12, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions redaxo/src/core/lib/response.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class rex_response
private static $additionalHeaders = [];
/** @var array */
private static $preloadFiles = [];
/** @var string */
private static $nonce = '';

/**
* Sets the HTTP Status code.
Expand Down Expand Up @@ -62,6 +64,19 @@ public static function getStatus()
return self::$httpStatus;
}

/**
* Returns a request save NONCE für CSP Headers and Implemntations.
*
* @return string
*/
public static function getNonce()
dergel marked this conversation as resolved.
Show resolved Hide resolved
{
if (!self::$nonce) {
self::$nonce = bin2hex(random_bytes(16));
}
return self::$nonce;
}

/**
* Set a http response header. A existing header with the same name will be overridden.
*
Expand Down