Skip to content

fix(nginx): Shibboleth ログインスクリプトを login.py に戻し、PHP を取り除く(arm64 対応を含む) - #1936

Merged
ivis-miyachi merged 3 commits into
develop_v2.1.0from
fix/nginx-login-py
Oct 5, 2026
Merged

ivis-miyachi merged 3 commits into
develop_v2.1.0from
fix/nginx-login-py

Conversation

@mhaya

@mhaya mhaya commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

概要 (Summary)

develop_v2.1.0 の nginx イメージでは Shibboleth でログインできない。原因は2つあり、この PR で両方を直す。あわせて、AMS 用の nginx イメージ(nginx/Dockerfile.ams)を arm64 でビルド・起動できるようにする(3.)。

1. ログインスクリプト login.py が配置されていない

  • 7e53679(2025-02)で Shibboleth のログインスクリプトを login.php から login.py に切り替えた。ただしこのとき直したのは nginx/Dockerfile だけで、nginx/Dockerfile.arm64 は login.php のまま残っていた。
  • d6d92a5(2026-07-17)と 3de23b2(2026-07-20)は、どちらもコミットメッセージが「fix build error」。この2つで nginx/Dockerfile が v2.0.4 の nginx/Dockerfile.arm64 と同じ内容に置き換わり、login.py への切り替えが失われた。
    • d6d92a5 の変更は、直後の b19e39d でいったん戻された。
    • 3de23b2 で再び同じ置き換えが入り、そのまま release_v2.1.0 に含まれている。
  • その結果、イメージには fcgiwrap も login.py も入らず、login.php が配置されている。一方、次の3つは login.py を前提にしたままなので、/secure/login.py が動かない。
    • weko.conf の /secure/(fcgiwrap で .py を実行)
    • supervisord.conf の fcgiwrap
    • WEKO_ACCOUNTS_SHIB_IDP_LOGIN_URL の既定値(secure/login.py)

2. arm64 で shibauthorizer / shibresponder が起動しない

  • supervisord.conf は shibauthorizer と shibresponder を /usr/lib/x86_64-linux-gnu/shibboleth/ から起動する。arm64 では実体が /usr/lib/aarch64-linux-gnu/shibboleth/ にあるため、2つとも FATAL になる。
  • その結果 /secure/ の shib_request が通らない。2021 年からある問題で、1. とは別件。

3. AMS 用イメージ(nginx/Dockerfile.ams)が arm64 でビルドできない

  • pagespeed モジュール(incubator-pagespeed-ngx)が、x86_64 専用の PSOL(1.13.35.2-x64)を取り込むため、arm64 ではコンパイルできない。
  • ビルドした .deb を focal_amd64.deb という名前で決め打ちしているため、arm64 では COPY に失敗する。
  • AMS 用イメージも同じ supervisord.conf を使うので、2. と同じ問題もある。

変更内容

  • nginx/Dockerfile と nginx/Dockerfile.arm64
    • fcgiwrap と python3-requests を入れ、secure/login.py を配置する(chmod 755)。
    • ビルド時に uname -m を使って、supervisord.conf の shibboleth のパスを実行環境のアーキテクチャに合わせて書き換える。x86_64 では何も変わらない。
    • 2つの Dockerfile は同じ内容に保つ(1. は2つの内容がずれたことが原因のため)。
  • login.php による運用は終わっているので、PHP を取り除く。
    • 3つの Dockerfile から php-fpm・php-curl のインストールと、php-fpm の設定書き換えを削除する。
    • supervisord.conf から [program:php-fpm] を削除する。
    • weko-ams.conf と weko-ams-restricted.conf から .php 用の location を削除する。weko.conf のコメントアウト済みの同じ location も削除する。
    • nginx/login.php、index.php、phpinfo.php を削除する。
  • login.py が使う requests は、pip ではなく apt の python3-requests で入れる。python3-pip は不要になる。Dockerfile.ams の pip3 install requests も同じ方法に置き換える。
  • nginx/Dockerfile.ams(3.)
    • pagespeed モジュールを組み込まない。AMS の設定でも使っておらず、Dockerfile からはすでに外されている。
    • .deb をワイルドカード(nginx_1.20.1-1~focal_*.deb)で取得する。
    • Dockerfile と同じく、ビルド時に supervisord.conf の shibboleth のパスを書き換える。
    • nginx 1.18.0 時代のコメントアウト行を削除する。

関連Issue / チケット (Related Issues)

  • なし

変更タイプ (Type of Change)

  • 🚀 新機能追加 (Feature)
  • 🐛 バグ修正 (Bug Fix)
  • 🔒 セキュリティ修正 (Security Fix)
  • 🚫 機能のクローズ・非公開化・削除 (Feature Deprecation/Disable)
  • ⚠️ 破壊的変更・データ移行を伴う修正 (Breaking Change / Migration)
  • 📚 仕様書・マニュアル・APIリストの更新 (Documentation)

🤖 0. CI 自動チェック (API Inventory Drift)

  • CI が PASS している、または FAIL の各項目に対処済み

API を追加・変更した場合(必須)

対象外。nginx イメージの構成だけの変更で、WEKO の API(Blueprint・View・REST)は変更していない。


🔒 1. セキュリティ & API アクセス制御チェック (必須)

対象外(WEKO の API に変更はない)。/secure/ は従来どおり shib_request /shibauthorizer を通る。arm64 では、この PR で初めて shibauthorizer が動く。

🧪 2. テストコード観点チェック

対象外(Python コードに変更はない)。

🛡️ 3. データ保護 & 破壊的変更防止チェック

対象外。

⚙️ 4. マイグレーション & システム影響チェック

  • DB/検索インデックス:変更なし。
  • 既存環境の更新:nginx イメージの再ビルドが必要。weko.conf などを環境ごとに変更している場合は、.php 用 location の削除を反映すること(残っていても、.php ファイルが無いので動作に影響はない)。

📚 5. ドキュメント・仕様書更新チェック (weko-document)

  • 更新不要な場合(理由): 機能・API・画面に変更はない。weko-document の v2.0.4→v2.1.0 アップデート手順書には「nginx/Dockerfile をビルド前に手で直す」手順を書いてあるので、この PR が取り込まれたら別途書き換える。

📋 6. 動作検証エビデンス (Verification Evidence)

aarch64(arm64)の機械で、キャッシュを使わずに(--no-cache)ビルドして確認した。nginx 1.20.1 のソースからのコンパイルも、実際に実行している。

nginx/Dockerfile.arm64(修正後の nginx/Dockerfile も同じ内容)

  • ビルド:成功。nginx_1.20.1-1~focal_arm64.deb と nginx-dbg_1.20.1-1~focal_arm64.deb が作られた。
  • nginx -V:headers-more、nginx-http-shibboleth、http-auth-digest、ngx_cache_purge の4モジュールが組み込まれている。
  • イメージの中身
    • /usr/share/nginx/html/secure/login.py が -rwxr-xr-x で配置されている。
    • /usr/sbin/fcgiwrap がある。php-fpm は入っていない。
    • import requests(2.22.0)と urllib3・http.cookiejar が読み込める。
  • 起動(上流ホストは --add-host でダミーにした)
    • nginx -t は成功した。
    • supervisord の shibd・shibauthorizer・shibresponder・fcgiwrap・nginx がすべて RUNNING。修正前は aarch64 で shibauthorizer と shibresponder が FATAL だった。
    • curl -k https://127.0.0.1/secure/login.py?next=%2F は、shibauthorizer を経由して IdP の SSOService への 302 になった。
    • login.py を CGI として直接実行すると、属性が無い場合の応答(Permission is invalid)が返った。

nginx/Dockerfile.ams

  • ビルド:成功。nginx は arm64 の .deb で作られ、AMS フロントエンドの npm install と npm run build も通った。
  • 起動
    • nginx -t は成功した。
    • supervisord の5プロセスがすべて RUNNING。
    • pm2 の AMS(Nuxt)が online で、http://127.0.0.1:3000/ は 200。
    • /secure/login.py?next=ams は IdP への 302。
    • secure/ には login.py だけが置かれ、php-fpm は入っていない。

未確認

  • 実際の IdP でログインを最後まで通すこと。
  • x86_64 でのビルド。x86_64 ではパスの書き換えは何もしない。

🤖 Generated with Claude Code

mhaya and others added 2 commits October 5, 2026 05:45
d6d92a5 / 3de23b2(fix build error)で nginx/Dockerfile が旧
nginx/Dockerfile.arm64 と同じ内容に置き換わり、7e536799c で行った
login.php → login.py の切り替えが失われていた。weko.conf の /secure/、
supervisord.conf の fcgiwrap、WEKO_ACCOUNTS_SHIB_IDP_LOGIN_URL は
login.py を前提にしているため、このままでは Shibboleth でログインできない。

- nginx/Dockerfile, Dockerfile.arm64: fcgiwrap と python3-requests を入れ、
  secure/login.py を配置する
- login.php による運用は終わっているので PHP を取り除く
  - php-fpm / php-curl のインストールと php-fpm の設定書き換えを削除
  - supervisord.conf の php-fpm を削除
  - weko-ams.conf / weko-ams-restricted.conf の .php 用 location と、
    weko.conf のコメントアウト済みの同 location を削除
  - nginx/login.php, index.php, phpinfo.php を削除
- login.py が使う requests は pip ではなく apt の python3-requests で入れる
  (Dockerfile.ams の python3-pip / pip3 install requests も置き換え)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
supervisord.conf は shibauthorizer / shibresponder を
/usr/lib/x86_64-linux-gnu/shibboleth/ から起動するが、arm64 では
/usr/lib/aarch64-linux-gnu/shibboleth/ にあるため FATAL になり、
/secure/ の shib_request が通らず Shibboleth でログインできなかった。

supervisord.conf は Dockerfile と Dockerfile.arm64 で共有しているので、
ビルド時に uname -m でパスを書き換える。x86_64 では書き換わらない。
両 Dockerfile は同じ内容に保つ。

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

sourcery-ai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Shibboleth ログインを login.py + fcgiwrap に戻し、PHP 実行経路を完全に削除するとともに、supervisord の Shibboleth バイナリパスをビルドアーキテクチャに応じて調整して arm64 でも認証サービスが起動するようにした。

Sequence diagram for Shibboleth login through login.py

sequenceDiagram
    participant Client
    participant Nginx
    participant Shibauthorizer
    participant Fcgiwrap
    participant LoginPy
    participant IdP

    Client->>Nginx: GET /secure/login.py
    Nginx->>Shibauthorizer: shib_request /shibauthorizer
    Shibauthorizer-->>Nginx: Authentication result
    Nginx->>Fcgiwrap: FastCGI request
    Fcgiwrap->>LoginPy: Execute login.py
    LoginPy->>IdP: Redirect to SSOService
    IdP-->>Client: 302 SSO redirect
Loading

File-Level Changes

Change Details Files
Shibboleth のログイン処理を PHP から Python CGI に統一し、必要な実行依存関係をイメージへ追加している。
  • fcgiwrap と apt 版 python3-requests をインストール
  • login.py を secure 配下へ配置して実行権限を付与
  • PHP-FPM、PHP 依存関係、pip 経由の requests 導入を削除
nginx/Dockerfile
nginx/Dockerfile.arm64
nginx/Dockerfile.ams
nginx/login.py
arm64 環境でも Shibboleth の認証プロセスが起動できるよう、ライブラリパスをビルドアーキテクチャに合わせて解決している。
  • uname -m の結果を使って shibauthorizer と shibresponder のパスを置換
  • x86_64 では既存パスを維持し、aarch64 では対応する Debian ライブラリディレクトリを使用
nginx/Dockerfile
nginx/Dockerfile.arm64
nginx/supervisord.conf
Nginx と Supervisor の構成から廃止済みの PHP ログイン経路を除去し、Python 経路に整理している。
  • php-fpm の Supervisor プログラムを削除
  • 各 Nginx 設定から .php 用 secure location と不要なコメントを削除
  • login.php、index.php、phpinfo.php を削除
nginx/supervisord.conf
nginx/weko.conf
nginx/weko-ams.conf
nginx/weko-ams-restricted.conf
nginx/login.php
nginx/index.php
nginx/phpinfo.php

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 5, 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: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1d22c4f6-5957-426d-af08-e57daa9a2dd0

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.

@sourcery-ai sourcery-ai Bot 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.

Hey - I've reviewed your changes and they look great!

Fixed security issues:

  • SSL verification is disabled but should not be (currently CURLOPT_SSL_VERIFYPEER= false) (link)
  • The 'phpinfo' function may reveal sensitive information about your environment. (link)

Sourcery assessment

Needs a human reviewer. The deployed authentication path changes from PHP-FPM to fcgiwrap running login.py, while also changing the Shibboleth module library path and Python dependency. If the new handler or architecture-specific configuration is wrong, users could be unable to log in or authorization-related attributes could be mishandled; reverting restores the previous PHP path, but any incorrect authentication or access decisions made before the revert would not be undone.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

- incubator-pagespeed-ngx は x86_64 用の PSOL (1.13.35.2-x64) を取り込む
  ため arm64 ではコンパイルできない。weko-ams.conf などでも使っていない
  ので、Dockerfile と同じく組み込まないようにする
- ビルドした .deb を focal_amd64.deb と決め打ちせず、ワイルドカードで取る
- supervisord.conf の shibauthorizer / shibresponder のパスを、Dockerfile と
  同じくビルド時に uname -m で書き換える
- nginx 1.18.0 時代のコメントアウト行を削除する

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mhaya mhaya changed the title fix(nginx): Shibboleth ログインスクリプトを login.py に戻し、PHP を取り除く(arm64 の shibauthorizer も修正) fix(nginx): Shibboleth ログインスクリプトを login.py に戻し、PHP を取り除く(arm64 対応を含む) Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

🔍 Claude レビュー統合

指摘はありません。


次にすること: 自分で挙げる指摘はありません。既存レビューのうち、スレッド ID を持つものは無く、裁定の対象はありませんでした。Sourcery が挙げた SSL 検証無効と phpinfo の2件は、login.php と phpinfo.php を削除したことで解消しています。nginx 配下に php や pagespeed を参照する設定が残っていないことも確認しました。マージ前に、arm64 と amd64 で実際にビルドして Shibboleth ログインが通ることを確かめてください。


モデル sonnet / 2 回実行して和集合 / コスト $0.3230。同じ入力でも結果が揺れるため複数回まわし、一部のパスでしか挙がらなかったものには回数を添えています

他レビューを踏まえた自動レビューです。誤りが含まれることがあります。

@mhaya

mhaya commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

x86 64でのビルドおよびプロセス起動に問題ないことを確認した。

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

台帳ブランチ: develop_v2.1.0

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

(生成されませんでした)

台帳との突き合わせ

(生成されませんでした)

ソース由来の経路検知

(生成されませんでした)

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

API インベントリ差分(件数のみ)

台帳ブランチ: develop_v2.1.0

明細は公開できないため件数のみ表示しています。該当箇所はプライベートリポジトリ側の台帳・レポートで確認してください。

ベースラインとの差分

API インベントリ差分レポート

  • 旧: b572c442d v2.0.4-577-gb572c442d (profile=default) endpoints=933 (外部ライブラリ由来 359)
  • 新: 5db10639b v2.0.4-661-g5db10639b (profile=default) endpoints=933 (外部ライブラリ由来 359)

判定: ❌ FAIL (FAIL 1 / WARN 2)

サマリ

分類 件数
ADDED 0
REMOVED 0
RULE_CHANGED 0
METHODS_CHANGED 0
AUTH_CHANGED 36
IMPL_CHANGED 8
ATTRS_UNKNOWN_NEW 0
ModelView 追加 0
ModelView 削除 0
ModelView フラグ変化 0
config 変化 2
コメントアウト認証の増加 0
依存パッケージの版変化 0

[FAIL] G2 認証系デコレータが削除された — 3件

件数のみ。該当の経路名はプライベートリポジトリ側の完全版レポートを参照。

[WARN] W2 実装本体が変化(data_op / 情報露出を再確認) — 8件

件数のみ。該当の経路名はプライベートリポジトリ側の完全版レポートを参照。

[WARN] W5 監視対象 config が変化した — 2件

件数のみ。該当の経路名はプライベートリポジトリ側の完全版レポートを参照。


台帳との突き合わせ

(生成されませんでした)

ソース由来の経路検知

(生成されませんでした)

@ivis-miyachi
ivis-miyachi merged commit 3af98d0 into develop_v2.1.0 Oct 5, 2026
145 of 158 checks passed
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.

2 participants