セキュリティに問題のあるネットワークを通過するcookieは盗聴可能です。無線LANは、まさにそのようなネットワークの一例です。特に
暗号化されていない無線LAN
では、接続されているクライアントのすべてのトラフィックを簡単に傍聴できてしまいます。Webアプリケーションの開発者にとっては、これはSSLによる安全な接続
の提供が必要であるということです。Rails 3.1以降では、アプリケーションの設定ファイルで以下のようにSSL接続を強制
することによって達成できます。
- 暗号化されていない無線LAN
下図
これらがないと盗聴される
- Webアプリケーションの開発者にとっては、これはSSLによる安全な接続
- アプリケーションの設定ファイルで以下のようにSSL接続を強制
This middleware is added to the stack when config.force_ssl = true, and is passed the options set in config.ssl_options. It does three jobs to enforce secure HTTP requests:
TLS redirect: Permanently redirects http:// requests to https:// with the same URL host, path, etc. Enabled by default. Set config.ssl_options to modify the destination URL (e.g. redirect: { host: "secure.widgets.com", port: 8080 }), or set redirect: false to disable this feature.
...Secure cookies: Sets the secure flag on cookies to tell browsers they must not be sent along with http:// requests. Enabled by default. Set config.ssl_options with secure_cookies: false to disable this feature.
...HTTP Strict Transport Security (HSTS): Tells the browser to remember this site as TLS-only and automatically redirect non-TLS requests. Enabled by default. Configure config.ssl_options with hsts: false to disable.
感想
LAN内のセキュリティ、HTTPのセキュリティを同時にして安全にデータを届けることができる。