diff --git a/src/ContentSecurityPolicy.php b/src/ContentSecurityPolicy.php index b99e9f1..7dd20c7 100644 --- a/src/ContentSecurityPolicy.php +++ b/src/ContentSecurityPolicy.php @@ -1,13 +1,25 @@ policies); @@ -15,9 +27,13 @@ public function get() return $csp; } - public function ReportOnly() + /** + * Sets CSP header as Report Only + * @since 1.2.0 + */ + public function reportOnly() { - $this->ReportOnly = true; + $this->reportOnly = true; } /** diff --git a/src/CrossOrigin.php b/src/CrossOrigin.php new file mode 100644 index 0000000..e69de29 diff --git a/src/Headers.php b/src/Headers.php index 8563dac..d237034 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -1,9 +1,20 @@ 'SAMEORIGIN', 'X-Content-Type-Options' => 'nosniff', @@ -12,10 +23,23 @@ class Headers { 'Strict-Transport-Security' => 'max-age=31536000; includeSubDomains', 'Expect-CT' => '', ]; - + /** + * Report log location URI. + * @var $report_uri string URL to report file. + */ public $report_uri; - public function __construct(ContentSecurityPolicy $csp = null) { + /** + * Class constructor. + * + * @since 1.0.0 + * @author WP Helpers | Carlos Matos + * + * @param $csp object COntentSecurityPolicy instance. + * @return void() + * + */ + public function __construct(\WPH\Security\ContentSecurityPolicy $csp = null) { if (!file_exists(WP_CONTENT_DIR . '/security/')) { mkdir(WP_CONTENT_DIR . '/security/', 0777, true); @@ -36,6 +60,12 @@ public function __construct(ContentSecurityPolicy $csp = null) { } + /** + * Adds headers after the class instance. + * + * @internal + * @since 1.0.0 + */ public function add() { foreach ($this->toApply as $key => $value) { @@ -45,11 +75,25 @@ public function add() { } + /** + * Allows adding new headers after the class instance. + * + * @param $header string Name of the header. + * @param $value string Value and arguments for this header. + * + * @since 1.0.0 + */ public function set(string $header, string $value) { $this->toApply[$header] = $value; } + /** + * Retrieves an array of all headers to be set. + * + * @since 1.0.0 + * @return $this->toApply array + */ public static function list() { return $this->toApply; diff --git a/src/PermissionsPolicy.php b/src/PermissionsPolicy.php new file mode 100644 index 0000000..e69de29 diff --git a/src/SetCookie.php b/src/SetCookie.php new file mode 100644 index 0000000..e69de29