3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

UserAgentの廃止について調べた

Posted at

※この記事は、素人がパッとググった内容ですので、確かな情報ではありません

背景

  • UserAgentでブラウザ判定しているシステムで不具合があった
    • Windwos11にもかかわらずWindows10と表示される
    • Android10あたりからバージョン番号が更新されなくなっていた

UserAgent(UA)とは

  • よく見るのは、HTTPリクエストヘッダに埋め込まれ、サーバーのログに出ている
  • WEBサイト側の管理者が、ユーザーがどんなブラウザやOSからアクセスしてきたのか分かる
  • 参考|Apache WEBサーバーのアクセスログ例
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1"

UA廃止の動き

  • 2020年8月ChromeブラウザがUAサポート終了を決定

    • UserAgent文字列が複雑怪奇
    • プライバシー侵害を懸念
      • UAがフィンガープリントとして機能することでユーザーを追跡できる
      • デバイス種別によりユーザー層を推定できる など
  • UAが無くなるわけではなく、情報を削っていき最終的に固定化凍結された(Chrome110ですでに実施済) 

UA廃止(固定化)の具体例

Desktop (user on Windows 8.1, for example)

  • Old UA
Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.1234.56 Safari/537.36
  • Final Reduced UA
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.0.0 Safari/537.36

Mobile (user on Samsung Galaxy, for example)

  • Old UA
Mozilla/5.0 (Linux; Android 9; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.1234.56 Mobile Safari/537.36
  • Final Reduced UA
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.0.0 Mobile Safari/537.36

出典:https://www.chromium.org/updates/ua-reduction/

UAに代わるブラウザ判定方法

  • User Agent Client Hints(UA-CH)がリリースされている

    • HTTP応答ヘッダで追加要求する
    Accept-CH: Sec-CH-UA-Model
    
    • JavaScript API で情報を取得する
    navigator.userAgentData
    

詳しい実装:https://techblog.yahoo.co.jp/entry/2022121930384728/

今後のブラウザ判定はどう実装するのか

  • Accept-CHやNavigator.userAgentDataは、Chrome/Edgeは対応しているが、FirefoxやSafariは未対応
    https://developer.mozilla.org/ja/docs/Web/API/Navigator/userAgentData

  • UA-CHを取ってみて、ダメなら従来のUAを見るという実装にする?

  • そもそもプライバシーにうるさくなっているということは、ユーザーの情報を取るべきではない?

引き続き要調査

3
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?