Skip to content

Commit

Permalink
rex_response um Nonce Generator ergänzt (#5510)
Browse files Browse the repository at this point in the history
  • Loading branch information
dergel committed Jan 12, 2023
1 parent 4bf1c63 commit eb9f48c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions redaxo/src/core/lib/response.php
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,17 @@ public static function getStatus()
return self::$httpStatus;
}

/**
* Returns a request save NONCE für CSP Headers and Implemntations.
*/
public static function getNonce(): string
{
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

0 comments on commit eb9f48c

Please sign in to comment.