LoginSignup
3
0

More than 3 years have passed since last update.

mod_auth_openidcとChromeのバージョン問題(SameSite=Noneの互換性)

Posted at

発端

Apacheのリバースプロキシにmod_auth_openidcを入れて、Keycloakで認証を連携を構築している。
前回の話で、
mod_auth_openidc を最新のVer2.4.2.1にしたところ、
Internal server error でアクセスできない事象が起きた。

Apacheのエラーログはこんな感じ。

oidc_restore_proto_state: no "mod_auth_openidc_state_XXX” state cookie found, referer: XXX
oidc_unsolicited_proto_state: could not parse JWT from state: invalid unsolicited response: [src/jose/apr_jwt.c:749:oidc_jwt_parse]: cjose_jws_import_failed:invalid argument [file: jws.c, function]cjose_jws_import, 787]¥n¥n, referXXX
oidc_authorization_response_match_state: unable to restore state, referer: XXX
oidc_handle_authorization_response: invalid authorization response state and no default SSO URL is set, sending an error..., referer: XXX

ログレベルをdebugにして、怪しそうなログ

oidc_proto_peek_jwt_header: could not parse first element separated by "." from input, refer:XXX

切り分け:バージョンによる現象発生の違い

同じコンフィグでmod_auth_openidc のバージョンを変えてみると、以下のようになった。

  • Ver 2.4.2.1 事象再現
  • Ver 2.4.1.1 事象再現
  • Ver 2.3.11 事象が起きない

コミュニティへのメールとブラウザの違い

上記のバージョンの事象再現の違いを、
mod_auth_openidcのGithubにコミュニティのMLに投げて見た。

Community Support
For generic questions, see the Wiki pages with Frequently Asked Questions at:
https://github.com/zmartzone/mod_auth_openidc/wiki
There is a Google Group/mailing list at:
mod_auth_openidc@googlegroups.com
The corresponding forum/archive is at:
https://groups.google.com/forum/#!forum/mod_auth_openidc
Any questions/issues should go to the mailing list.

すぐに返事がきて、ブラウザの違いを聞かれたので確認したところ、
以下の違いが出た。
※クローズドな環境でブラウザは最新ではない

  • Chrome 65.0.3325.146 64bit 事象再現
  • Firefox 55.0.2 64bit 事象が起きない
  • IE11 11.0.170 事象が起きない

また、mod_auth_openidc-2.4.0.1では、Chromeでも事象が起きないことを確認した。

原因

コミュニティサポートの回答で、原因が判明した。
https://www.chromium.org/updates/same-site/incompatible-clients

Chromeの51~66のブラウザは、
SameSite=Noneを指定するとリジェクトする仕様で、
これに対し、mod_auth_openidc Ver 2.4.1以降は互換性がない。

mod_auth_openidcのrelease 2.4.1の下記の部分が関連する説明。

always add a SameSite value (default None) to the Set-Cookie header value; this can be overridden by using the environment variable OIDC_SET_COOKIE_APPEND, e.g.:
SetEnvIf User-Agent ".IOS." OIDC_SET_COOKIE_APPEND=;

日本語の解説だと、
https://qiita.com/ahera/items/0c8276da6b0bed2b580c
の下の方にあるユーザーエージェント判定についての箇所が上記リンクをうまく日本語にしている。

Noneを指定すると拒否する。
Chromium由来の古いバージョンのブラウザーとAndroid WebViewも同様
これは当時Noneが仕様に無かったから。
なお51未満は無視されるのでNoneと同じ動作になる。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0