diff --git a/typerocket-v5.php b/typerocket-v5.php index 99cbee4a..ab38a1da 100644 --- a/typerocket-v5.php +++ b/typerocket-v5.php @@ -3,7 +3,7 @@ Plugin Name: TypeRocket - Andromeda Plugin URI: https://typerocket.com/ Description: TypeRocket is a framework that joins refined UI elements and modern programming architecture together. -Version: 5.0.37 +Version: 5.0.38 Requires at least: 5.5 Requires PHP: 7.2 Author: TypeRocket @@ -34,7 +34,7 @@ public function __construct() return; } - define('TYPEROCKET_PLUGIN_VERSION', '5.0.37'); + define('TYPEROCKET_PLUGIN_VERSION', '5.0.38'); define('TYPEROCKET_PLUGIN_INSTALL', __DIR__); if(!defined('TYPEROCKET_ROOT_WP')) diff --git a/typerocket/composer.lock b/typerocket/composer.lock index a801bb45..6f28c452 100644 --- a/typerocket/composer.lock +++ b/typerocket/composer.lock @@ -875,16 +875,16 @@ }, { "name": "typerocket/core", - "version": "v5.0.127", + "version": "v5.0.128", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "348e4439230db3fcf75997be9c983d03f066c69d" + "reference": "461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/348e4439230db3fcf75997be9c983d03f066c69d", - "reference": "348e4439230db3fcf75997be9c983d03f066c69d", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d", + "reference": "461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d", "shasum": "" }, "require": { @@ -922,9 +922,9 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.0.127" + "source": "https://github.com/TypeRocket/core/tree/v5.0.128" }, - "time": "2022-07-25T13:01:53+00:00" + "time": "2022-07-26T19:33:33+00:00" }, { "name": "woocommerce/action-scheduler", diff --git a/typerocket/config/cookies.php b/typerocket/config/cookies.php new file mode 100644 index 00000000..d394135c --- /dev/null +++ b/typerocket/config/cookies.php @@ -0,0 +1,40 @@ + [ + + /* + |-------------------------------------------------------------------------- + | SameSite Policy + |-------------------------------------------------------------------------- + | + | WordPress uses old PHP settings for its auth cookies. If you are using + | PHP 7.3 or greater you can set the `SameSite` value for cookies. This + | option defines the value of `SameSite`. + | + | Options: None, Lax or Strict + | + */ + 'same_site' => 'Lax', + + /* + |-------------------------------------------------------------------------- + | Timeout Period - Action Scheduler + |-------------------------------------------------------------------------- + | + | By default, WordPress adds `X-Frame-Options: SAMEORIGIN`. However, these + | headers are often set by the web server instead. Set this option as + | `false` to disable WordPress' x-frame-options. + | + */ + 'x_frame_options' => true, + ] +]; \ No newline at end of file diff --git a/typerocket/vendor/composer/autoload_classmap.php b/typerocket/vendor/composer/autoload_classmap.php index 7e0d6eae..a6b53074 100644 --- a/typerocket/vendor/composer/autoload_classmap.php +++ b/typerocket/vendor/composer/autoload_classmap.php @@ -1023,6 +1023,7 @@ 'TypeRocket\\Services\\ErrorService' => $vendorDir . '/typerocket/core/src/Services/ErrorService.php', 'TypeRocket\\Services\\JobQueueRunner' => $vendorDir . '/typerocket/core/src/Services/JobQueueRunner.php', 'TypeRocket\\Services\\MailerService' => $vendorDir . '/typerocket/core/src/Services/MailerService.php', + 'TypeRocket\\Services\\SecureAuthCookiesService' => $vendorDir . '/typerocket/core/src/Services/SecureAuthCookiesService.php', 'TypeRocket\\Services\\Service' => $vendorDir . '/typerocket/core/src/Services/Service.php', 'TypeRocket\\Template\\Component' => $vendorDir . '/typerocket/core/src/Template/Component.php', 'TypeRocket\\Template\\Composer' => $vendorDir . '/typerocket/core/src/Template/Composer.php', diff --git a/typerocket/vendor/composer/autoload_static.php b/typerocket/vendor/composer/autoload_static.php index 9711039d..cb7b6f85 100644 --- a/typerocket/vendor/composer/autoload_static.php +++ b/typerocket/vendor/composer/autoload_static.php @@ -1148,6 +1148,7 @@ class ComposerStaticInit1ea299e54fdefaef41f855b3138bc6c1 'TypeRocket\\Services\\ErrorService' => __DIR__ . '/..' . '/typerocket/core/src/Services/ErrorService.php', 'TypeRocket\\Services\\JobQueueRunner' => __DIR__ . '/..' . '/typerocket/core/src/Services/JobQueueRunner.php', 'TypeRocket\\Services\\MailerService' => __DIR__ . '/..' . '/typerocket/core/src/Services/MailerService.php', + 'TypeRocket\\Services\\SecureAuthCookiesService' => __DIR__ . '/..' . '/typerocket/core/src/Services/SecureAuthCookiesService.php', 'TypeRocket\\Services\\Service' => __DIR__ . '/..' . '/typerocket/core/src/Services/Service.php', 'TypeRocket\\Template\\Component' => __DIR__ . '/..' . '/typerocket/core/src/Template/Component.php', 'TypeRocket\\Template\\Composer' => __DIR__ . '/..' . '/typerocket/core/src/Template/Composer.php', diff --git a/typerocket/vendor/composer/installed.json b/typerocket/vendor/composer/installed.json index b895637d..e4cc092c 100644 --- a/typerocket/vendor/composer/installed.json +++ b/typerocket/vendor/composer/installed.json @@ -2621,17 +2621,17 @@ }, { "name": "typerocket/core", - "version": "v5.0.127", - "version_normalized": "5.0.127.0", + "version": "v5.0.128", + "version_normalized": "5.0.128.0", "source": { "type": "git", "url": "https://github.com/TypeRocket/core.git", - "reference": "348e4439230db3fcf75997be9c983d03f066c69d" + "reference": "461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/TypeRocket/core/zipball/348e4439230db3fcf75997be9c983d03f066c69d", - "reference": "348e4439230db3fcf75997be9c983d03f066c69d", + "url": "https://api.github.com/repos/TypeRocket/core/zipball/461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d", + "reference": "461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d", "shasum": "" }, "require": { @@ -2642,7 +2642,7 @@ "require-dev": { "phpunit/phpunit": "8.5.*" }, - "time": "2022-07-25T13:01:53+00:00", + "time": "2022-07-26T19:33:33+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -2671,7 +2671,7 @@ "support": { "docs": "https://typerocket.com/docs/v5/", "issues": "https://github.com/TypeRocket/core/issues", - "source": "https://github.com/TypeRocket/core/tree/v5.0.127" + "source": "https://github.com/TypeRocket/core/tree/v5.0.128" }, "install-path": "../typerocket/core" }, diff --git a/typerocket/vendor/composer/installed.php b/typerocket/vendor/composer/installed.php index 5f6fbce3..aeda911d 100644 --- a/typerocket/vendor/composer/installed.php +++ b/typerocket/vendor/composer/installed.php @@ -5,7 +5,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '365ab558fc87d3a7374c8b61a9bf2611e52b23b7', + 'reference' => 'b77692a83d8be813e48f8177d978d0d9faa2d5fe', 'name' => 'typerocket/typerocket', 'dev' => true, ), @@ -359,12 +359,12 @@ 'dev_requirement' => true, ), 'typerocket/core' => array( - 'pretty_version' => 'v5.0.127', - 'version' => '5.0.127.0', + 'pretty_version' => 'v5.0.128', + 'version' => '5.0.128.0', 'type' => 'library', 'install_path' => __DIR__ . '/../typerocket/core', 'aliases' => array(), - 'reference' => '348e4439230db3fcf75997be9c983d03f066c69d', + 'reference' => '461d1a9ef66bb36f36c5d831a69fa7b0fe4abc0d', 'dev_requirement' => false, ), 'typerocket/typerocket' => array( @@ -373,7 +373,7 @@ 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'reference' => '365ab558fc87d3a7374c8b61a9bf2611e52b23b7', + 'reference' => 'b77692a83d8be813e48f8177d978d0d9faa2d5fe', 'dev_requirement' => false, ), 'webmozart/assert' => array( diff --git a/typerocket/vendor/typerocket/core/src/Services/SecureAuthCookiesService.php b/typerocket/vendor/typerocket/core/src/Services/SecureAuthCookiesService.php new file mode 100644 index 00000000..35f71c0a --- /dev/null +++ b/typerocket/vendor/typerocket/core/src/Services/SecureAuthCookiesService.php @@ -0,0 +1,100 @@ += 70300)) { + throw new \Error(__(static::class . ' TypeRocket service requires PHP 7.3 > ' . \PHP_VERSION_ID, 'typerocket-core')); + } + + /** + * Options: None, Lax or Strict + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite + */ + $same_site = Config::getFromContainer()->locate('cookies.auth.same_site', 'Lax'); + + /** + * By default, WordPress adds `X-Frame-Options: SAMEORIGIN`. However, these headers are often set + * by the web server instead. Set this option as `false` to disable WordPress' x-frame-options. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options + */ + $x_frame_options = Config::getFromContainer()->locate('cookies.auth.x_frame_options', true); + + if(!$x_frame_options) { + remove_action('admin_init', 'send_frame_options_header'); + remove_action('init', 'send_frame_options_header'); + remove_action('login_init', 'send_frame_options_header'); + } + + add_filter('send_auth_cookies', '__return_false'); + + add_action('set_auth_cookie', function ($auth_cookie, $expire) use ($same_site) { + setcookie( SECURE_AUTH_COOKIE, $auth_cookie, [ + 'expires' => $expire, + 'path' => PLUGINS_COOKIE_PATH, + 'domain' => COOKIE_DOMAIN, + 'secure' => true, + 'httponly' => true, + 'samesite' => 'None' + ]); + setcookie( SECURE_AUTH_COOKIE, $auth_cookie, [ + 'expires' => $expire, + 'path' => ADMIN_COOKIE_PATH, + 'domain' => COOKIE_DOMAIN, + 'secure' => true, + 'httponly' => true, + 'samesite' => $same_site + ]); + }, 10, 2); + + add_action( 'set_logged_in_cookie', function($logged_in_cookie, $expire) use ($same_site) { + setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, [ + 'expires' => $expire, + 'path' => COOKIEPATH, + 'domain' => COOKIE_DOMAIN, + 'secure' => true, + 'httponly' => true, + 'samesite' => $same_site + ]); + if ( COOKIEPATH != SITECOOKIEPATH ) { + setcookie( LOGGED_IN_COOKIE, $logged_in_cookie, [ + 'expires' => $expire, + 'path' => SITECOOKIEPATH, + 'domain' => COOKIE_DOMAIN, + 'secure' => true, + 'httponly' => true, + 'samesite' => $same_site + ]); + } + }, 10, 2); + + add_filter('typerocket_cookie_options', function ($options, $name) use ($same_site) { + if(in_array($name, [ + Redirect::KEY_ADMIN, + Redirect::KEY_DATA, + Redirect::KEY_MESSAGE, + Redirect::KEY_OLD, + Redirect::KEY_ERROR, + ])) { + $options['samesite'] = $same_site; + } + + return $options; + }, 10, 2); + } + + public function register() : Service + { + return $this; + } +} \ No newline at end of file