aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/README.md
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-11 12:51:10 +1030
committerMatthew Draper <matthew@trebex.net>2016-10-11 12:51:10 +1030
commitdae404473409fcab0e07976aec626df670e52282 (patch)
tree996635fbf7b16974d98683235dc57ea3f88b0ab8 /actioncable/README.md
parentf8c53eff7be9a5670e3c0da5851312977becb308 (diff)
downloadrails-dae404473409fcab0e07976aec626df670e52282.tar.gz
rails-dae404473409fcab0e07976aec626df670e52282.tar.bz2
rails-dae404473409fcab0e07976aec626df670e52282.zip
Permit same-origin connections by default
WebSocket always defers the decision to the server, because it didn't have to deal with legacy compatibility... but the same-origin policy is still a reasonable default. Origin checks do not protect against a directly connecting attacker -- they can lie about their host, but can also lie about their origin. Origin checks protect against a connection from 3rd-party controlled script in a context where a victim browser's cookies will be passed along. And if an attacker has breached that protection, they've already compromised the HTTP session, so treating the WebSocket connection in the same way seems reasonable. In case this logic proves incorrect (or anyone just wants to be more paranoid), we retain a config option to disable it.
Diffstat (limited to 'actioncable/README.md')
-rw-r--r--actioncable/README.md13
1 files changed, 9 insertions, 4 deletions
diff --git a/actioncable/README.md b/actioncable/README.md
index 30b86edd2e..8ad9aeb1f1 100644
--- a/actioncable/README.md
+++ b/actioncable/README.md
@@ -326,7 +326,10 @@ Rails.application.paths.add "config/cable", with: "somewhere/else/cable.yml"
### Allowed Request Origins
-Action Cable will only accept requests from specified origins, which are passed to the server config as an array. The origins can be instances of strings or regular expressions, against which a check for match will be performed.
+Action Cable will only accept requests from specific origins.
+
+By default, only an origin matching the cable server itself will be permitted.
+Additional origins can be specified using strings or regular expressions, provided in an array.
```ruby
Rails.application.config.action_cable.allowed_request_origins = ['http://rubyonrails.com', /http:\/\/ruby.*/]
@@ -334,15 +337,17 @@ Rails.application.config.action_cable.allowed_request_origins = ['http://rubyonr
When running in the development environment, this defaults to "http://localhost:3000".
-To disable and allow requests from any origin:
+To disable protection and allow requests from any origin:
```ruby
Rails.application.config.action_cable.disable_request_forgery_protection = true
```
-It is also possible to allow origins that are starting with the actual HTTP HOST header:
+To disable automatic access for same-origin requests, and strictly allow
+only the configured origins:
+
```ruby
-Rails.application.config.action_cable.allow_same_origin_as_host = true
+Rails.application.config.action_cable.allow_same_origin_as_host = false
```
### Consumer Configuration