From 4dfc53763a697bf4cb54dcf90e1e9aa33b4eff41 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 22 Sep 2022 09:26:15 +0300 Subject: [PATCH 1/9] Try imposter to avoid conflicts with already installed packages --- composer.json | 12 +- composer.lock | 176 +++++++++++++++++++++++- inc/class-adminsettings.php | 6 +- inc/class-ajax.php | 8 +- inc/class-credential-migrator.php | 14 +- inc/class-settingsvalidator.php | 6 +- inc/class-utils.php | 8 +- inc/class-webauthn-credential-store.php | 14 +- inc/class-webauthn-provider.php | 12 +- inc/class-webauthn-user-credential.php | 10 +- inc/class-webauthn-user.php | 8 +- 11 files changed, 238 insertions(+), 36 deletions(-) diff --git a/composer.json b/composer.json index e3e84107..29d553ff 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.4.0 || ^8.0.0", "composer/installers": "^2.0", "madwizard/webauthn": "^0.8.0", + "typisttech/imposter-plugin": "^0.6.2", "wildwolf/singleton-trait": "^1.0" }, "require-dev": { @@ -31,12 +32,21 @@ "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true, "composer/package-versions-deprecated": true, - "composer/installers": true + "composer/installers": true, + "typisttech/imposter-plugin": true }, "platform": { "php": "7.4" } }, + "extra": { + "imposter": { + "namespace": "WildWolf\\WordPress\\TwoFactorWebAuthn\\Vendor", + "excludes": [ + "wildwolf/singleton-trait" + ] + } + }, "scripts": { "phpcs": "phpcs", "phpcs:fix": "phpcbf", diff --git a/composer.lock b/composer.lock index 9ebb3bbc..b76a8bd3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e3b52ea6cdeedf4cfbd48cf35ef35b90", + "content-hash": "716b63b3ff39d0d96f0e807176657833", "packages": [ { "name": "composer/installers", @@ -1876,6 +1876,180 @@ ], "time": "2022-05-27T12:56:18+00:00" }, + { + "name": "typisttech/imposter", + "version": "0.6.1", + "source": { + "type": "git", + "url": "https://github.com/TypistTech/imposter.git", + "reference": "f52b1a2289d2ea9c660cf9595085d0b11469af83" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TypistTech/imposter/zipball/f52b1a2289d2ea9c660cf9595085d0b11469af83", + "reference": "f52b1a2289d2ea9c660cf9595085d0b11469af83", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "codeception/codeception": "^4.1", + "codeception/mockery-module": "^0.4.0", + "codeception/module-asserts": "^1.3", + "codeception/module-filesystem": "^1.0", + "squizlabs/php_codesniffer": "^3.5" + }, + "suggest": { + "typisttech/imposter-plugin": "Composer plugin to integrate composer and imposter" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "TypistTech\\Imposter\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Typist Tech", + "email": "imposter@typist.tech", + "homepage": "https://typist.tech" + }, + { + "name": "Tang Rufus", + "email": "tangrufus@gmail.com", + "homepage": "https://typist.tech", + "role": "Developer" + } + ], + "description": "Wrapping all composer vendor packages inside your own namespace. Intended for WordPress plugins.", + "homepage": "https://github.com/TypistTech/imposter", + "keywords": [ + "composer", + "dependency", + "monkey-patching", + "namespace", + "wordpress" + ], + "support": { + "email": "imposter@typist.tech", + "issues": "https://github.com/TypistTech/imposter/issues", + "source": "https://github.com/TypistTech/imposter" + }, + "funding": [ + { + "url": "https://typist.tech/donation/", + "type": "custom" + }, + { + "url": "https://www.paypal.me/iAmTangRufus/30usd", + "type": "custom" + }, + { + "url": "https://github.com/tangrufus", + "type": "github" + } + ], + "time": "2020-12-06T22:57:09+00:00" + }, + { + "name": "typisttech/imposter-plugin", + "version": "0.6.2", + "source": { + "type": "git", + "url": "https://github.com/TypistTech/imposter-plugin.git", + "reference": "15fa3c90aca3b79497f438b9e02a6176498de53c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TypistTech/imposter-plugin/zipball/15fa3c90aca3b79497f438b9e02a6176498de53c", + "reference": "15fa3c90aca3b79497f438b9e02a6176498de53c", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.1 || ^2.0", + "php": "^7.3 || ^8.0", + "typisttech/imposter": "^0.6.1" + }, + "require-dev": { + "codeception/codeception": "^4.1", + "codeception/module-asserts": "^1.3", + "codeception/module-cli": "^1.1", + "codeception/module-filesystem": "^1.0", + "composer/composer": "^1.10.19 || ^2.0", + "squizlabs/php_codesniffer": "^3.5", + "typisttech/codeception-composer-project-module": "^0.1.1" + }, + "type": "composer-plugin", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + }, + "class": "TypistTech\\Imposter\\Plugin\\ImposterPlugin" + }, + "autoload": { + "psr-4": { + "TypistTech\\Imposter\\Plugin\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Typist Tech", + "email": "imposter-plugin@typist.tech", + "homepage": "https://www.typist.tech" + }, + { + "name": "Tang Rufus", + "email": "tangrufus@gmail.com", + "homepage": "https://www.typist.tech", + "role": "Developer" + } + ], + "description": "Composer plugin that wraps all composer vendor packages inside your own namespace. Intended for WordPress plugins.", + "homepage": "https://github.com/TypistTech/imposter-plugin", + "keywords": [ + "composer", + "composer-plugin", + "dependency", + "monkey-patching", + "namespace", + "wordpress" + ], + "support": { + "email": "imposter-plugin@typist.tech", + "issues": "https://github.com/TypistTech/imposter-plugin/issues", + "source": "https://github.com/TypistTech/imposter-plugin" + }, + "funding": [ + { + "url": "https://typist.tech/donation/", + "type": "custom" + }, + { + "url": "https://www.paypal.me/iAmTangRufus/30usd", + "type": "custom" + }, + { + "url": "https://github.com/tangrufus", + "type": "github" + } + ], + "time": "2020-12-06T23:41:30+00:00" + }, { "name": "wildwolf/singleton-trait", "version": "1.0.5", diff --git a/inc/class-adminsettings.php b/inc/class-adminsettings.php index f94b7209..88aace85 100644 --- a/inc/class-adminsettings.php +++ b/inc/class-adminsettings.php @@ -2,9 +2,11 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Dom\AuthenticatorAttachment; -use MadWizard\WebAuthn\Dom\UserVerificationRequirement; use WildWolf\Utils\Singleton; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Dom\AuthenticatorAttachment, + MadWizard\WebAuthn\Dom\UserVerificationRequirement, +}; final class AdminSettings { use Singleton; diff --git a/inc/class-ajax.php b/inc/class-ajax.php index a8934390..33e25899 100644 --- a/inc/class-ajax.php +++ b/inc/class-ajax.php @@ -3,12 +3,14 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; use InvalidArgumentException; -use MadWizard\WebAuthn\Json\JsonConverter; -use MadWizard\WebAuthn\Server\Registration\RegistrationContext; -use MadWizard\WebAuthn\Server\Registration\RegistrationOptions; use Throwable; use UnexpectedValueException; use WildWolf\Utils\Singleton; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Json\JsonConverter, + MadWizard\WebAuthn\Server\Registration\RegistrationContext, + MadWizard\WebAuthn\Server\Registration\RegistrationOptions, +}; use WP_User; use wpdb; diff --git a/inc/class-credential-migrator.php b/inc/class-credential-migrator.php index 23507d32..e3eccb94 100644 --- a/inc/class-credential-migrator.php +++ b/inc/class-credential-migrator.php @@ -2,12 +2,14 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Credential\UserHandle; -use MadWizard\WebAuthn\Crypto\CoseAlgorithm; -use MadWizard\WebAuthn\Crypto\CoseKeyInterface; -use MadWizard\WebAuthn\Crypto\Ec2Key; -use MadWizard\WebAuthn\Exception\ParseException; -use MadWizard\WebAuthn\Format\ByteBuffer; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Credential\UserHandle, + MadWizard\WebAuthn\Crypto\CoseAlgorithm, + MadWizard\WebAuthn\Crypto\CoseKeyInterface, + MadWizard\WebAuthn\Crypto\Ec2Key, + MadWizard\WebAuthn\Exception\ParseException, + MadWizard\WebAuthn\Format\ByteBuffer, +}; use WP_User; use wpdb; diff --git a/inc/class-settingsvalidator.php b/inc/class-settingsvalidator.php index d11df333..77303ce1 100644 --- a/inc/class-settingsvalidator.php +++ b/inc/class-settingsvalidator.php @@ -2,8 +2,10 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Dom\AuthenticatorAttachment; -use MadWizard\WebAuthn\Dom\UserVerificationRequirement; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Dom\AuthenticatorAttachment, + MadWizard\WebAuthn\Dom\UserVerificationRequirement, +}; /** * @psalm-import-type SettingsArray from Settings diff --git a/inc/class-utils.php b/inc/class-utils.php index db015f70..83308ad2 100644 --- a/inc/class-utils.php +++ b/inc/class-utils.php @@ -2,9 +2,11 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Builder\ServerBuilder; -use MadWizard\WebAuthn\Config\RelyingParty; -use MadWizard\WebAuthn\Server\ServerInterface; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Builder\ServerBuilder, + MadWizard\WebAuthn\Config\RelyingParty, + MadWizard\WebAuthn\Server\ServerInterface, +}; abstract class Utils { public static function get_u2f_app_id(): string { diff --git a/inc/class-webauthn-credential-store.php b/inc/class-webauthn-credential-store.php index bb1e1d04..ed60f0c1 100644 --- a/inc/class-webauthn-credential-store.php +++ b/inc/class-webauthn-credential-store.php @@ -2,12 +2,14 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Credential\CredentialId; -use MadWizard\WebAuthn\Credential\CredentialStoreInterface; -use MadWizard\WebAuthn\Credential\UserCredentialInterface; -use MadWizard\WebAuthn\Credential\UserHandle; -use MadWizard\WebAuthn\Crypto\CoseKey; -use MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Credential\CredentialId, + MadWizard\WebAuthn\Credential\CredentialStoreInterface, + MadWizard\WebAuthn\Credential\UserCredentialInterface, + MadWizard\WebAuthn\Credential\UserHandle, + MadWizard\WebAuthn\Crypto\CoseKey, + MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface, +}; use WP_User; use wpdb; diff --git a/inc/class-webauthn-provider.php b/inc/class-webauthn-provider.php index ce3b55ac..e941b02a 100644 --- a/inc/class-webauthn-provider.php +++ b/inc/class-webauthn-provider.php @@ -3,16 +3,18 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; use InvalidArgumentException; -use MadWizard\WebAuthn\Credential\CredentialId; -use MadWizard\WebAuthn\Extension\AppId\AppIdExtensionInput; -use MadWizard\WebAuthn\Json\JsonConverter; -use MadWizard\WebAuthn\Server\Authentication\AuthenticationContext; -use MadWizard\WebAuthn\Server\Authentication\AuthenticationOptions; use Throwable; use Two_Factor_Provider; use TwoFactor_Provider_WebAuthn; use UnexpectedValueException; use WP_User; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Credential\CredentialId, + MadWizard\WebAuthn\Extension\AppId\AppIdExtensionInput, + MadWizard\WebAuthn\Json\JsonConverter, + MadWizard\WebAuthn\Server\Authentication\AuthenticationContext, + MadWizard\WebAuthn\Server\Authentication\AuthenticationOptions, +}; class WebAuthn_Provider extends Two_Factor_Provider { public const AUTHENTICATION_CONTEXT_USER_META = Constants::AUTHENTICATION_CONTEXT_USER_META_KEY; diff --git a/inc/class-webauthn-user-credential.php b/inc/class-webauthn-user-credential.php index 9e554bf1..525a28a9 100644 --- a/inc/class-webauthn-user-credential.php +++ b/inc/class-webauthn-user-credential.php @@ -2,10 +2,12 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Credential\CredentialId; -use MadWizard\WebAuthn\Credential\UserCredentialInterface; -use MadWizard\WebAuthn\Credential\UserHandle; -use MadWizard\WebAuthn\Crypto\CoseKeyInterface; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Credential\CredentialId, + MadWizard\WebAuthn\Credential\UserCredentialInterface, + MadWizard\WebAuthn\Credential\UserHandle, + MadWizard\WebAuthn\Crypto\CoseKeyInterface, +}; class WebAuthn_User_Credential implements UserCredentialInterface { private CredentialId $credential_id; diff --git a/inc/class-webauthn-user.php b/inc/class-webauthn-user.php index 0c0cee2a..c38783c6 100644 --- a/inc/class-webauthn-user.php +++ b/inc/class-webauthn-user.php @@ -2,11 +2,13 @@ namespace WildWolf\WordPress\TwoFactorWebAuthn; -use MadWizard\WebAuthn\Credential\UserHandle; -use MadWizard\WebAuthn\Exception\NotAvailableException; -use MadWizard\WebAuthn\Server\UserIdentityInterface; use UnexpectedValueException; use WP_User; +use WildWolf\WordPress\TwoFactorWebAuthn\Vendor\{ + MadWizard\WebAuthn\Credential\UserHandle, + MadWizard\WebAuthn\Exception\NotAvailableException, + MadWizard\WebAuthn\Server\UserIdentityInterface, +}; use wpdb; // phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- there is no other way to access our own tables From fa011a7f1e0ae2dd0830c6629f5bb54f7b9e81dc Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 22 Sep 2022 09:59:46 +0300 Subject: [PATCH 2/9] Patch madwizard/webauthn to work with imposter --- composer.json | 9 +++++++- composer.lock | 50 +++++++++++++++++++++++++++++++++++++++++- patches/webauthn.patch | 11 ++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 patches/webauthn.patch diff --git a/composer.json b/composer.json index 29d553ff..eddaf326 100644 --- a/composer.json +++ b/composer.json @@ -10,6 +10,7 @@ "require": { "php": "^7.4.0 || ^8.0.0", "composer/installers": "^2.0", + "cweagans/composer-patches": "^1.7", "madwizard/webauthn": "^0.8.0", "typisttech/imposter-plugin": "^0.6.2", "wildwolf/singleton-trait": "^1.0" @@ -33,7 +34,8 @@ "dealerdirect/phpcodesniffer-composer-installer": true, "composer/package-versions-deprecated": true, "composer/installers": true, - "typisttech/imposter-plugin": true + "typisttech/imposter-plugin": true, + "cweagans/composer-patches": true }, "platform": { "php": "7.4" @@ -45,6 +47,11 @@ "excludes": [ "wildwolf/singleton-trait" ] + }, + "patches": { + "madwizard/webauthn": { + "Fix interoperability with imposter": "patches/webauthn.patch" + } } }, "scripts": { diff --git a/composer.lock b/composer.lock index b76a8bd3..7a6ba9fc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "716b63b3ff39d0d96f0e807176657833", + "content-hash": "8ae53679f115d7f8277b58d0fd7678b9", "packages": [ { "name": "composer/installers", @@ -151,6 +151,54 @@ ], "time": "2022-08-20T06:45:11+00:00" }, + { + "name": "cweagans/composer-patches", + "version": "1.7.2", + "source": { + "type": "git", + "url": "https://github.com/cweagans/composer-patches.git", + "reference": "e9969cfc0796e6dea9b4e52f77f18e1065212871" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/e9969cfc0796e6dea9b4e52f77f18e1065212871", + "reference": "e9969cfc0796e6dea9b4e52f77f18e1065212871", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=5.3.0" + }, + "require-dev": { + "composer/composer": "~1.0 || ~2.0", + "phpunit/phpunit": "~4.6" + }, + "type": "composer-plugin", + "extra": { + "class": "cweagans\\Composer\\Patches" + }, + "autoload": { + "psr-4": { + "cweagans\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Cameron Eagans", + "email": "me@cweagans.net" + } + ], + "description": "Provides a way to patch Composer packages.", + "support": { + "issues": "https://github.com/cweagans/composer-patches/issues", + "source": "https://github.com/cweagans/composer-patches/tree/1.7.2" + }, + "time": "2022-01-25T19:21:20+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.5.0", diff --git a/patches/webauthn.patch b/patches/webauthn.patch new file mode 100644 index 00000000..0c6370e0 --- /dev/null +++ b/patches/webauthn.patch @@ -0,0 +1,11 @@ +--- src/Metadata/MetadataResolverInterface.orig.php 2022-09-22 09:55:34.152470592 +0300 ++++ src/Metadata/MetadataResolverInterface.php 2022-09-22 09:55:48.708300739 +0300 +@@ -5,7 +5,7 @@ + use MadWizard\WebAuthn\Attestation\TrustAnchor\MetadataInterface; + use MadWizard\WebAuthn\Server\Registration\RegistrationResultInterface; + +-interface MetadataResolverInterface // TODO move namespace ++interface MetadataResolverInterface + { + public function getMetadata(RegistrationResultInterface $registrationResult): ?MetadataInterface; + } From 4a2e7f0a283ee14b0517d13c8aa79df4d1ecc4c5 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 22 Sep 2022 10:10:21 +0300 Subject: [PATCH 3/9] Update composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index eddaf326..095c47b2 100644 --- a/composer.json +++ b/composer.json @@ -45,6 +45,7 @@ "imposter": { "namespace": "WildWolf\\WordPress\\TwoFactorWebAuthn\\Vendor", "excludes": [ + "cweagans/composer-patches", "wildwolf/singleton-trait" ] }, From 8500e86151d11fd64314aee1f8fe349f1e1f98df Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 22 Sep 2022 10:21:32 +0300 Subject: [PATCH 4/9] Update scripts --- .github/workflows/push-tag.yml | 6 +++--- bin/build-archive.sh | 3 +-- composer.json | 4 +++- composer.lock | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 95405ee8..3a4e0b10 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -19,7 +19,7 @@ jobs: run: | git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) cp composer.lock /var/tmp/two-factor-provider-webauthn/ - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers && rm -f composer.lock) + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches typisttech/imposter-plugin && rm -rf composer.lock patches vendor/madwizard/webauthn/{.github,conformance,tests} vendor/psr/log/Psr/Log/Test) (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) - name: Release @@ -42,8 +42,8 @@ jobs: - name: Install dependencies to bundle run: | composer install --no-dev --no-interaction - composer remove --update-no-dev --no-interaction composer/installers - rm -f composer.lock composer.json + composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches + rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/{.github,conformance,tests} vendor/psr/log/Psr/Log/Test - name: Deploy to wordpress.org uses: 10up/action-wordpress-plugin-deploy@stable diff --git a/bin/build-archive.sh b/bin/build-archive.sh index fba92515..05d3a954 100755 --- a/bin/build-archive.sh +++ b/bin/build-archive.sh @@ -3,8 +3,7 @@ ( cd .. && \ git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) && \ - cp composer.lock /var/tmp/two-factor-provider-webauthn/ && \ - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers && rm -f composer.lock) && \ + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test) && \ (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) && \ mv /var/tmp/two-factor-provider-webauthn.zip two-factor-provider-webauthn.zip ) diff --git a/composer.json b/composer.json index 095c47b2..3cf8ccd3 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,9 @@ }, "platform": { "php": "7.4" - } + }, + "optimize-autoloader": true, + "classmap-authoritative": true }, "extra": { "imposter": { diff --git a/composer.lock b/composer.lock index 7a6ba9fc..1a352c31 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8ae53679f115d7f8277b58d0fd7678b9", + "content-hash": "274ac22b435a8f98fdd5990cf4879b24", "packages": [ { "name": "composer/installers", From b40a4ea5760c854d62b528b0b03c53234683a7ad Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 22 Sep 2022 16:52:42 +0300 Subject: [PATCH 5/9] Reduce bundle size --- .github/workflows/push-tag.yml | 2 +- bin/build-archive.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index 3a4e0b10..ef2a098e 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -43,7 +43,7 @@ jobs: run: | composer install --no-dev --no-interaction composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches - rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/{.github,conformance,tests} vendor/psr/log/Psr/Log/Test + rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/{.github,conformance,tests} vendor/psr/log/Psr/Log/Test vendor/typisttech - name: Deploy to wordpress.org uses: 10up/action-wordpress-plugin-deploy@stable diff --git a/bin/build-archive.sh b/bin/build-archive.sh index 05d3a954..266239d1 100755 --- a/bin/build-archive.sh +++ b/bin/build-archive.sh @@ -3,7 +3,7 @@ ( cd .. && \ git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) && \ - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test) && \ + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) && \ mv /var/tmp/two-factor-provider-webauthn.zip two-factor-provider-webauthn.zip ) From 3e8a84bb1c59b85d96ca413ae75ec489dc08145a Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 13 Oct 2022 21:19:02 +0300 Subject: [PATCH 6/9] Run E2E tests on the self-contained plugin --- .github/workflows/e2e.yml | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 7c87e584..e02f3cd0 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -61,3 +61,45 @@ jobs: name: playwright-test-results path: test-results/ retention-days: 3 + + e2e-bundle: + name: Run E2E tests on the generated plugin + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # tag=v3.1.0 + + - name: Generate self-contained package + run: | + git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ + (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) + + - name: Patch docker-compose.yml + run: | + sed -i 's!- .:!- /var/tmp/two-factor-provider-webauthn:!' docker-compose.yml + + - name: Set up Node.js environment + uses: actions/setup-node@969bd2663942d722d85b6a8626225850c2f7be4b # tag=v3.5.0 + with: + node-version: lts/* + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Install Playwright + run: npx playwright install chromium + + - name: Run Playwright E2E tests + run: npm run test:e2e + env: + WP_VERSION: php8.0 + + - name: Upload test results + uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # tag=v3 + if: failure() + with: + name: playwright-test-results + path: test-results/ + retention-days: 3 From 3d40ad66e0530054ba395a3b77e6ef208e1b7782 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 13 Oct 2022 21:49:29 +0300 Subject: [PATCH 7/9] Update scripts --- .github/workflows/e2e.yml | 3 +-- .github/workflows/push-tag.yml | 3 +-- bin/build-archive.sh | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e02f3cd0..5c5ba0c4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -72,8 +72,7 @@ jobs: - name: Generate self-contained package run: | git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ - (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) - name: Patch docker-compose.yml run: | diff --git a/.github/workflows/push-tag.yml b/.github/workflows/push-tag.yml index ef2a098e..74cbb373 100644 --- a/.github/workflows/push-tag.yml +++ b/.github/workflows/push-tag.yml @@ -18,8 +18,7 @@ jobs: - name: Generate self-contained package run: | git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) - cp composer.lock /var/tmp/two-factor-provider-webauthn/ - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches typisttech/imposter-plugin && rm -rf composer.lock patches vendor/madwizard/webauthn/{.github,conformance,tests} vendor/psr/log/Psr/Log/Test) + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) - name: Release diff --git a/bin/build-archive.sh b/bin/build-archive.sh index 266239d1..1654059e 100755 --- a/bin/build-archive.sh +++ b/bin/build-archive.sh @@ -2,8 +2,8 @@ ( cd .. && \ - git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) && \ - (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ + git archive --format=tar --prefix=two-factor-provider-webauthn/ HEAD | (cd /var/tmp/ && tar xf -) + (cd /var/tmp/two-factor-provider-webauthn && composer install --no-dev --no-interaction && composer remove --update-no-dev --no-interaction composer/installers cweagans/composer-patches && rm -rf composer.lock composer.json patches vendor/madwizard/webauthn/.github vendor/madwizard/webauthn/conformance vendor/madwizard/webauthn/tests vendor/psr/log/Psr/Log/Test vendor/typisttech) && \ (cd /var/tmp && zip -r -9 two-factor-provider-webauthn.zip two-factor-provider-webauthn) && \ mv /var/tmp/two-factor-provider-webauthn.zip two-factor-provider-webauthn.zip ) From 521b9fedd9f4e54cbad9baff43d556c9143a6a52 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 13 Oct 2022 21:57:13 +0300 Subject: [PATCH 8/9] Update mkcert --- .docker/wordpress/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/wordpress/Dockerfile b/.docker/wordpress/Dockerfile index fb32d315..2f321ba9 100644 --- a/.docker/wordpress/Dockerfile +++ b/.docker/wordpress/Dockerfile @@ -3,7 +3,7 @@ FROM wordpress:${VERSION} RUN \ a2enmod ssl && \ a2ensite default-ssl.conf && \ - curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.3/mkcert-v1.4.3-linux-amd64 -o /usr/local/bin/mkcert && \ + curl -L https://github.com/FiloSottile/mkcert/releases/download/v1.4.4/mkcert-v1.4.4-linux-amd64 -o /usr/local/bin/mkcert && \ chmod +x /usr/local/bin/mkcert && \ /usr/local/bin/mkcert -cert-file /etc/ssl/certs/ssl-cert-snakeoil.pem -key-file /etc/ssl/private/ssl-cert-snakeoil.key localhost && \ mkdir -p /var/www/mu-plugins From 15abbc5bcaa0d1185ecfb3f1a4824d8b2f462a52 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Thu, 13 Oct 2022 22:02:18 +0300 Subject: [PATCH 9/9] Use PHP 8.0 by default --- .docker/wordpress/Dockerfile | 2 +- docker-compose.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.docker/wordpress/Dockerfile b/.docker/wordpress/Dockerfile index 2f321ba9..26e84f9d 100644 --- a/.docker/wordpress/Dockerfile +++ b/.docker/wordpress/Dockerfile @@ -1,4 +1,4 @@ -ARG VERSION=php7.4@sha256:6003ce1cc14ed9d83c3df5593b3359cc8e4236fb80238e9530a0beeb6c60f688 +ARG VERSION=php8.0@sha256:1e7fee0c6fec2eebe4d54c7719fb055a6b9834f7430e26f3e83c1a141cdcb8c4 FROM wordpress:${VERSION} RUN \ a2enmod ssl && \ diff --git a/docker-compose.yml b/docker-compose.yml index 67393a61..80e5e215 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: context: .docker/wordpress dockerfile: Dockerfile args: - VERSION: ${WP_VERSION:-php7.4} + VERSION: ${WP_VERSION:-php8.0} depends_on: - mariadb ports: @@ -26,12 +26,12 @@ services: WORDPRESS_DB_NAME: wordpress WORDPRESS_DB_HOST: mariadb volumes: &ref_0 - - 'wordpress:/var/www/html' + - wordpress:/var/www/html - .:/var/www/html/wp-content/plugins/two-factor-provider-webauthn networks: - tfpwa cli: - image: 'wordpress:cli-php7.4@sha256:c253f3b5043a6414e2d93a2ee5ddb1021d82e67c84c7d050d11c08accd627859' + image: wordpress:cli-php7.4@sha256:06513d92834e401c96d213b71914f645914e8ce7fde5a5b4f97375ee0d3313c3 volumes: *ref_0 user: '33:33' environment: