mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Basic authentication helpers
This commit is contained in:
parent
81bbf9ecba
commit
049cd824c0
3 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
module ActionCable
|
||||
module Connection
|
||||
autoload :Authorization, 'action_cable/connection/authorization'
|
||||
autoload :Base, 'action_cable/connection/base'
|
||||
autoload :Heartbeat, 'action_cable/connection/heartbeat'
|
||||
autoload :Identification, 'action_cable/connection/identification'
|
||||
|
|
13
lib/action_cable/connection/authorization.rb
Normal file
13
lib/action_cable/connection/authorization.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
module ActionCable
|
||||
module Connection
|
||||
module Authorization
|
||||
class UnauthorizedError < StandardError; end
|
||||
|
||||
private
|
||||
def reject_unauthorized_connection
|
||||
logger.error "An unauthorized connection attempt was rejected"
|
||||
raise UnauthorizedError
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -3,6 +3,7 @@ module ActionCable
|
|||
class Base
|
||||
include Identification
|
||||
include InternalChannel
|
||||
include Authorization
|
||||
|
||||
attr_reader :server, :env
|
||||
delegate :worker_pool, :pubsub, to: :server
|
||||
|
@ -85,6 +86,9 @@ module ActionCable
|
|||
heartbeat.start
|
||||
|
||||
message_buffer.process!
|
||||
rescue ActionCable::Connection::Authorization::UnauthorizedError
|
||||
respond_to_invalid_request
|
||||
close
|
||||
end
|
||||
|
||||
def on_message(message)
|
||||
|
|
Loading…
Reference in a new issue