Commit Graph

390 Commits

Author SHA1 Message Date
bogdanvlviv
6673cf7071
Use require_relative instead of require with full path 2017-06-14 12:10:17 +03:00
Genadi Samokovarov
b6b0c99ff3 Use mattr_accessor default: option throughout the project 2017-06-03 13:52:48 +03:00
David Heinemeier Hansson
1c275d812f Add option for class_attribute default (#29270)
* Allow a default value to be declared for class_attribute

* Convert to using class_attribute default rather than explicit setter

* Removed instance_accessor option by mistake

* False is a valid default value

* Documentation
2017-05-29 18:01:50 +02:00
bogdanvlviv
40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df003a96f0e490c43559747618d10f5f
2017-05-23 00:53:51 +03:00
Akira Matsuda
f31ad74f7b identifiers is already defined via Connection::Identification module 2017-05-21 12:37:18 +09:00
Koichi ITO
89e097fa46 Suppress warning: assigned but unused variable - stdout 2017-05-12 15:37:42 +09:00
Ryuta Kamizono
89389428b5 Cleanup CHANGELOGs [ci skip]
* Remove trailing spaces.
* Add backticks around method and command.
* Fix indentation.
2017-04-30 02:41:44 +09:00
edwardmp
fc416d3721 Log any errors originating from the socket 2017-04-16 20:14:28 +02:00
Matthew Draper
fd097cff79 Work around all the things 2017-04-06 07:19:58 +09:30
Matthew Draper
c866cf9df8 Avoid "can't modify frozen IOError" failures
https://bugs.ruby-lang.org/issues/13239
2017-04-05 06:27:52 +09:30
Ryuta Kamizono
bdbee0b8e5 Rename local variable name current_user to verified_user [ci skip]
Assigning local variable named `current_user` in the condition is
confusing.
2017-03-25 20:48:34 +09:00
Kasper Timm Hansen
b242796765 Revert "Merge pull request #28569 from HarryCollins/patch-1"
This reverts commit 296d024b4e91c4891ae0b010249193513e63b921, reversing
changes made to e341d835070c7ef9990f41e02bbf46536be0aee7.

We aren't trying to compare to current_user, we're assigning that variable.
2017-03-25 12:40:53 +01:00
HarryCollins
591891e51e Update Action Cable README.md - typo fix 2017-03-25 10:45:31 +00:00
T.J. Schuck
11a09dbe53 Document AC::Connection::Authorization#reject_unauthorized_connection
This method is repeatedly used throughout the docs (in the [AC::Connection docs](12b6849858/actioncable/lib/action_cable/connection/base.rb (L28)), the [AC README](12b6849858/actioncable/README.md (a-full-stack-example)), the [AC Guides](12b6849858/guides/source/action_cable_overview.md (connection-setup))), but not actually documented itself and seemingly not supported for public use based on its current `private` status.

This actually makes the method public and documents it.  The actual behavior that’s documented here is implemented [here](12b6849858/actioncable/lib/action_cable/connection/base.rb (L213-L219)), via [this rescuing of the UnauthorizedError](3dd1de8ba4/actioncable/lib/action_cable/connection/base.rb (L172)).

The method is [already tested here](25473baf40/actioncable/test/connection/authorization_test.rb (L17-L29)).
2017-03-22 19:30:49 -04:00
Matthew Draper
62a8e838e0 Fix a race in ActionCable stream tests
These tests double-stub connection.pubsub, so we need to ensure the
first call's completed before we set up for the second.
2017-03-23 05:52:38 +10:30
Matthew Draper
6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
Javan Makhmali
2d2b3025ec Restore action_cable.js UMD module support. Fixes #28366 2017-03-11 16:12:36 -05:00
Rafael Mendonça França
8bb0b99a4a
Update package.json 2017-02-23 15:03:20 -05:00
Rafael Mendonça França
f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
Matthew Draper
3721b859b6 Deprecate the EventedRedis subscription adapter
Unlike Faye support, it seems a bit too documented to remove without
warning. So, here's a warning.
2017-02-23 10:48:30 +10:30
Martijn Storck
963572b2a4 Move some ActionCable logs to debug level 2017-02-06 12:05:54 +01:00
Akira Matsuda
c684f4f3da bin/test for Active Job and Action Cable tests
According to the commit comment on 54d84cbb77a7fbc6359eda4eb40cc7da29c426e1, AJ/bin/test was intentionally not added,
but AJ tests doesn't actually do anything special other than specifying ENV['AJ_ADAPTER'],
which can be easily done via command line environment variable.
2017-02-02 16:27:42 +09:00
yuuji.yaginuma
c42bd31977 correctly check error message
`assert_raise` does not check error message. However, in some tests,
it seems like expecting error message checking with `assert_raise`.
Instead of specifying an error message in `assert_raise`, modify to use
another assert to check the error message.
2017-01-25 09:58:15 +09:00
Chad Ingram
36a80b41dc Add changelog entry for #27425 [ci skip] 2017-01-21 22:04:03 -05:00
Chad Ingram
a9c4dcee8d Add channel_prefix support to ActionCable redis/evented_redis adapters. 2017-01-17 23:21:39 -05:00
Eugene
39c739161d Fix missing bracket.
Fix missing left bracket in exception message.
2017-01-14 01:52:27 +03:00
Akira Matsuda
b70fc698e1 Reduce string objects by using \ instead of + or << for concatenating strings
(I personally prefer writing one string in one line no matter how long it is, though)
2017-01-12 17:45:37 +09:00
Duncan Grazier
23e3e2bc2b ActionCable should not raise when a connection is already open
ActionCable was throwing a "Existing connection must be closed before
opening" exception which was being picked up as a production issue in
our error monitoring software. Since this happens pretty often on any
device that allows the browser to sleep (mobile) this error was getting
triggered often.

This change removes the exception, but keeps logging the occurrence. We
now return `false` to let the caller now that `open` failed.
2017-01-06 12:49:58 -05:00
Akira Matsuda
5473e390d3 self. is not needed when calling its own instance method
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
2017-01-05 19:58:52 +09:00
Rafael França
a27c040cc3 Merge pull request #25626 from maclover7/jm-standardize-ac-readme
Standardize Action Cable README.md
2017-01-03 19:35:39 -05:00
Jon Moss
37d956f45f Bump license years for 2017
Per https://www.timeanddate.com/counters/firstnewyear.html, it's already
2017 in a lot of places, so we should bump the Rails license years to
2017.

[ci skip]
2016-12-31 08:34:08 -05:00
Tony Arcieri
c434b97628 Upgrade to nio4r 2.0.0
nio4r 2.0.0 primarily includes new features and bugfixes, with few breaking
changes. The primary reason for bumping the major version is dropping support
for all Ruby versions prior to 2.2.2, so as to match Rails 5.

Full release announcement here:

https://groups.google.com/forum/#!topic/socketry/ZDIUj1ufiJ8
2016-12-28 19:45:39 -08:00
Jon Moss
d99c772da0 Small edits to actioncable/CHANGELOG.md
[ci skip]

- capitalize WebSocket
2016-12-27 08:41:28 -05:00
Akira Matsuda
91fa2b71c3 Privatize unneededly protected methods in Action Cable 2016-12-24 22:16:43 +09:00
Akira Matsuda
79c17a2d91 Privatize unneededly protected methods in Action Cable tests 2016-12-24 00:15:24 +09:00
Akira Matsuda
21e5fd4a2a Describe what we are protecting 2016-12-23 23:48:54 +09:00
Carlos Eduardo Monti
2b39b5bfa1 Fix typo in channel generator usage message 2016-12-19 12:31:42 -03:00
MSP-Greg
7257306623 ActionCable::Connection::Base doc code sample syntax error 2016-12-06 10:35:36 -06:00
Matthew Draper
162e889f16 Prevent race condition when launching EventMachine reactor
reactor_running? will be true just after the thread enters
EventMachine.run; reactor_thread only gets set after the internal
initialize_event_machine method has been called, the C extension is set
up, and it is entering its run loop.
2016-11-30 22:55:04 +10:30
Javan Makhmali
7083fa27a4 Add more Action Cable JavaScript tests 2016-11-21 09:50:00 -05:00
yuuji.yaginuma
7c7f4f96df use correct value in example [ci skip]
Need to specify `reload` from turbolinks 5.
Ref: 7225f0bb9fd1d71a7a37b53815c90178cc7319bd
2016-11-14 09:45:28 +09:00
Vipul A M
7e7d6ccf34
Changelog edits 2016-11-12 13:14:49 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Charles Oliver Nutter
51de32b2ec Lazy-load blade for actioncable tests; no blade on JRuby. 2016-10-21 17:19:44 -05:00
Matthew Draper
dae4044734 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.
2016-10-11 12:51:10 +10:30
Matthew Draper
f8c53eff7b Merge pull request #26568 from skateman/cable-sameorigin-as-host
Optionally allow ActionCable requests from the same host as origin
2016-10-11 12:28:38 +10:30
Matthew Draper
3a11c5b626 Merge pull request #26714 from matthewd/close-race
Work around read/close race (x2)
2016-10-07 04:30:08 +10:30
Matthew Draper
1fe967d0c9 Wait for the socket to be closed asynchronously 2016-10-06 13:12:35 +10:30
Matthew Draper
acd7ba795e Use a branch of websocket-client-simple, to work around read/close race 2016-10-06 12:51:26 +10:30
Matthew Draper
4a7c5685c8 Close the IO from the read loop thread
IO#close and IO#read across threads don't get along so well:

After T1 enters #read and releases the GVL, T2 can call #close on the
IO, thereby both closing the fd and freeing the buffer while T1 is using
them.
2016-10-06 10:31:14 +10:30