Skip to content

feat: EC-CUBE 4.4への対応-新ブランチ向け - #24

Open
KenTanaka wants to merge 5 commits into
EC-CUBE:4.4from
KenTanaka:feat-4.4
Open

KenTanaka wants to merge 5 commits into
EC-CUBE:4.4from
KenTanaka:feat-4.4

Conversation

@KenTanaka

Copy link
Copy Markdown
Collaborator

概要

会員向けアプリ認証(TOTP)プラグインを EC-CUBE 4.4(Symfony 7.4 / Doctrine ORM 3.0 / PHP 8.2+) に対応させ、コードを TwoFactorAuthCustomerApp42 → TwoFactorAuthCustomerApp44 に改名します。親プラグイン依存も TwoFactorAuthCustomer42 → TwoFactorAuthCustomer44 に更新します。4.3 とは非互換(属性必須・ORM 3・PHP 8.2+)のため、新規 4.4 ブランチへの取り込みです。

参考: 4.3→4.4 マイグレーション手順 (doc #346) /

変更内容

1. EC-CUBE 4.4 対応(コア移行)

  • Annotations → PHP 属性: Controller の @Route/@Template → #[Route]/#[Template](Sensio 依存除去)、EntityExtension の @EntityExtension → #[EntityExtension](Eccube\Attribute\EntityExtension)
  • 型宣言の明示: Entity カラム型(Types::STRING)、メソッド引数・戻り値型(createSecret(): string / verifyCode(...): bool 等)
  • AbstractPluginManager: enable/disable/uninstall ほか関連メソッドに : void
  • テンプレート参照: @TwoFactorAuthCustomerApp44/... およびページ登録パスを TwoFactorAuthCustomerApp44 に統一
  • 依存更新: composer require を ec-cube/twofactorauthcustomer44 へ、code / version: 4.4.0 を TwoFactorAuthCustomerApp44 に統一
  • PHPUnit 11: phpunit.xml.dist を <source>/<extensions> 形式へ、Tests/bootstrap.php を追加

2. 動作改善(初回APP認証)

  • 初回登録(/mypage/two_factor_auth/app/create)でセッション切れ等により秘密鍵が欠落した場合、鍵を再発行して入力画面を出し直すフォールバックを追加
  • チャレンジ時は秘密鍵・トークンの型チェックを追加してから verifyCode を実行

3. 静的解析・整形ツール

  • Resource/rector.php / Resource/.php-cs-fixer.dist.php を追加(.php 設定は本体の Plugin\: サービス検出で 500 を避けるため Resource/ 配下に配置)
  • rector / php-cs-fixer を適用し、CI で dry-run 検査できる構成にする

4. CI(.github/workflows/main.yml ほか)

  • マトリクスを EC-CUBE 4.4 / PHP 8.2–8.5 / MySQL8・PostgreSQL に更新、checkout@v4・$GITHUB_OUTPUT 化
  • 親プラグイン TwoFactorAuthCustomer44 を checkout / archive し、mock-package-api + eccube:composer:require で依存解決のうえ有効化
  • --ignore-platform-req=ext-redis: Symfony 7.4 の symfony/cache が古い php-redis と衝突して本体 composer install が失敗するのを回避(redis は未使用)
  • phpunit 前に cache:warmup: 有効プラグインのルート確定のため warmup を実行(Tests がある場合のみ PHPUnit 実行)
  • static-analysis ジョブ: php-cs-fixer / rector を SQLite・PHP 8.5 の1構成で実行
  • release.yml: 配布パッケージから Resource/rector.php / Resource/.php-cs-fixer.dist.php を除外

テスト

  • EC-CUBE 4.4 環境で手動試験を実施(初回APP認証・チャレンジ、セッション切れ時のフォールバックを含む)
  • CI マトリクス: 4.4 × PHP 8.2/8.3/8.4/8.5 × MySQL8/PostgreSQL
  • 静的解析ジョブ: php-cs-fixer / rector dry-run
  • 配布パッケージ(release.yml 相当)から開発用ファイルが除外されることを確認

Summary by CodeRabbit

  • 新機能
    • EC-CUBE 4.4向けの会員向け二要素認証(TOTP)プラグインに対応しました。
    • 認証コードの生成・検証や顧客情報への認証設定を、EC-CUBE 4.4環境で利用できます。
  • 改善
    • 顧客編集画面への認証設定表示を更新しました。
    • プラグインの有効化・無効化・アンインストール処理を安定化しました。
  • ドキュメント
    • インストール要件、依存プラグイン、設定方法、対応ブランチをREADMEに追加しました。
  • 品質向上
    • 自動テスト、静的解析、コード整形の実行環境を更新しました。

@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 313b842a-b098-4ba8-81a7-2ab44f3eeacd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

- EC-CUBE 4.4 が同梱する robthree/twofactorauth v3 はコンストラクタの第 1 引数 (IQRCodeProvider) が必須で、引数なしでは初回登録・認証画面が 500 になる
- 本体の TwoFactorAuthService と同じ QRServerProvider を渡す。QR コードは画面側の jquery.qrcode で描画しており、プロバイダは使われない

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ttokoro20240902 ttokoro20240902 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正をお願いします。

  • PR 本文の「秘密鍵が欠落した場合、鍵を再発行して入力画面を出し直すフォールバックを追加」に当たる実装が見当たりません。現状はセッションに鍵が無いと is_string($auth_key) が false になり、エラー表示のうえ auth_key が null のまま QR を描画します。実装するか、本文とテスト欄の記載を外してください。
  • removePages() の条件修正(!$Page → $Page !== null)で、無効化・アンインストール時に dtb_page が実際に削除されるようになりました。この挙動を確かめるテストを追加してください。

path: 'TwoFactorAuthCustomer42'
# 親プラグイン PR が公式 4.4 にマージされるまで、パッケージ名 twofactorauthcustomer44 が入っている
# KenTanaka/TwoFactorAuthCustomer の feat-4.4 を参照する。マージ後は EC-CUBE/TwoFactorAuthCustomer42@4.4 に戻す。
repository: 'KenTanaka/TwoFactorAuthCustomer'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

親プラグインを個人 fork KenTanaka/TwoFactorAuthCustomer@feat-4.4 から取得しています。公式リポジトリの CI が個人リポジトリに依存しないよう、EC-CUBE/TwoFactorAuthCustomer42#59 のマージ後に EC-CUBE/TwoFactorAuthCustomer42 の 4.4 へ戻してからマージしてください(L232 の static-analysis も同様)。

* @return array<string, mixed>|RedirectResponse
*/
#[Route(path: '/mypage/two_factor_auth/app/create', name: 'plg_customer_2fa_app_create', methods: ['GET', 'POST'])]
#[Template('@TwoFactorAuthCustomerApp44/default/tfa/app/register.twig')]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TwoFactorAuthCustomerApp44/... 形式にしたため、テンプレートが app/template/plugin/{code} → プラグインの Resource/template の順で解決され、app/template/{theme} は見なくなります。その結果、copyTwigFiles() が配置するコピーと、ページ管理での編集が画面に反映されません。TwoFactorAuthCustomerApp44/Resource/template/default/... のパス形式で指定してください(L112 も同様)。詳細は EC-CUBE/TwoFactorAuthCustomer42#59 を参照してください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants