-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
EC-CUBE 2系(2.13, 2.17, 2.25)向け EcAuth OpenID Connect RP プラグイン
概要
EcAuth IdP と連携し、ソーシャルログイン機能を EC-CUBE 2系サイトに追加するプラグイン。
MockIdP のフェデレーション機能で動作確認済み。
ディレクトリ構成
ec-cube2-ecauth/
├── .github/
│ └── workflows/
│ ├── ci.yml # CI(PHPStan, Rector, CS Fixer)
│ └── release.yml # リリース(パッケージング)
├── data/
│ ├── class/
│ │ ├── helper/
│ │ │ └── SC_Helper_EcAuth.php
│ │ └── pages/ecauth/
│ │ ├── LC_Page_EcAuth_Authorize.php
│ │ └── LC_Page_EcAuth_Callback.php
│ └── class_extends/page_extends/ecauth/
│ ├── LC_Page_EcAuth_Authorize_Ex.php
│ └── LC_Page_EcAuth_Callback_Ex.php
├── html/ecauth/
│ ├── authorize.php
│ └── callback.php
├── plugin/
│ └── EcAuthLogin2/
│ ├── plugin_info.php
│ └── EcAuthLogin2.php
├── Dockerfile
├── docker-compose.yml
├── install-plugin.sh
├── package.json
├── playwright.config.ts
└── tests/
└── ecauth-login.spec.ts
実装計画
Phase 1: 基盤作成
- リポジトリ作成
-
README.md作成 -
composer.json作成 - 静的解析・コード品質ツール設定
-
phpstan.neon作成(PHPStan設定) -
rector.php作成(Rector設定) -
.php-cs-fixer.dist.php作成(PHP CS Fixer設定)
-
Phase 2: OAuth2/OIDC クライアント
-
data/class/helper/SC_Helper_EcAuth.php作成-
getConfig()- dtb_plugin から設定取得 -
saveConfig()- dtb_plugin に設定保存 -
getAuthorizationUrl()- 認可URL生成(PKCE対応) -
exchangeCodeForTokens()- トークン交換 -
getUserInfo()- UserInfo取得 -
getExternalUserInfo()- External UserInfo取得 -
findOrCreateCustomer()- JITプロビジョニング(PostgreSQL対応) -
loginCustomer()- セッション開始 -
validateState()- state パラメータ検証 -
getAndClearCodeVerifier()- PKCE code_verifier 取得
-
Phase 3: コールバックエンドポイント
-
data/class/pages/ecauth/LC_Page_EcAuth_Callback.php作成 -
data/class_extends/page_extends/ecauth/LC_Page_EcAuth_Callback_Ex.php作成 -
html/ecauth/callback.php作成
Phase 4: プラグイン本体
-
plugin/EcAuthLogin2/plugin_info.php作成 -
plugin/EcAuthLogin2/EcAuthLogin2.php作成-
install()- DB拡張(ecauth_subject カラム追加) -
uninstall()- クリーンアップ -
prefilterTransform()- ログインボタン挿入 -
copyFiles()/removeFiles()- ファイル管理
-
Phase 5: テンプレート・JavaScript
- ログインボタンは
prefilterTransform()で動的に生成(テンプレートファイル不要)
Phase 6: Docker環境・E2Eテスト
-
docker-compose.yml作成 -
Dockerfile作成(EC-CUBE 2.25 公式イメージベース) -
install-plugin.sh作成- プラグイン登録(dtb_plugin, dtb_plugin_hookpoint)
- ecauth_subject カラム追加
- EcAuth 接続設定の自動登録
-
package.json作成 -
playwright.config.ts作成 -
tests/ecauth-login.spec.ts作成
Phase 7: CI/CD
-
.github/workflows/ci.yml作成- PHPStan 実行
- Rector --dry-run 実行
- PHP CS Fixer --dry-run 実行
- PHPUnit 実行(将来)
-
.github/workflows/release.yml作成- release トリガー
- プラグインパッケージング(tar.gz)
- GitHub Release にアセット添付
Phase 8: 認可フロー分離 ✅
セッション state 保存問題を解決するため、認可フローを専用エンドポイントに分離。
-
data/class/pages/ecauth/LC_Page_EcAuth_Authorize.php作成 -
data/class_extends/page_extends/ecauth/LC_Page_EcAuth_Authorize_Ex.php作成 -
html/ecauth/authorize.php作成 - ログインボタンのリンク先を
/ecauth/authorize.phpに変更 - 外部 URL リダイレクトのため
header()を直接使用
技術仕様
設定項目
dtb_plugin.free_field1 に JSON 形式で保存:
{
"client_id": "xxx",
"client_secret": "xxx",
"authorization_endpoint": "https://ecauth.example.com/authorization",
"token_endpoint": "https://ecauth.example.com/token",
"userinfo_endpoint": "https://ecauth.example.com/userinfo",
"external_userinfo_endpoint": "https://ecauth.example.com/api/external-userinfo",
"provider_name": "staging-mockidp"
}DB拡張
ALTER TABLE dtb_customer ADD ecauth_subject VARCHAR(255);
CREATE INDEX idx_customer_ecauth_subject ON dtb_customer(ecauth_subject);対象テンプレート(ボタン挿入先)
mypage/login.tpl- マイページログインshopping/index.tpl- 購入手続き画面
EC-CUBE 2.25 の変更点
dtb_plugin:description→plugin_description、del_flg削除plugin_idに明示的シーケンス必要SC_Plugin_Base継承で PHP 8 エラー(EC-CUBE Issue #551)- HTTP/HTTPS でセッションが分離される
Known Issues
解決済み
EcAuth Issue #210: state パラメータが保持されない→ PR #211 で修正済み- セッション state 保存問題: prefilter でのテンプレートコンパイル時に state が生成される問題 → Phase 8 で解決
- PostgreSQL NOT NULL 制約: customer_id, secret_key, point, email の設定が必要 → SC_Helper_EcAuth で対応
備考
- PHP 7.4 互換(EC-CUBE 2.25 公式イメージ使用)
- 環境変数は使用せず、dtb_plugin テーブルに設定保存
- パッチファイルは使用しない(プラグインフックのみで実装)
- prefilterTransform でテンプレートにボタンを挿入
- Docker 起動時にプラグイン自動インストール
- PKCE (S256) 対応
- JIT プロビジョニング対応
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels