instance method
allow_request_origin?
Ruby on Rails edge
Since edgeSignature
allow_request_origin?(env)
Check if the request origin is allowed to connect to the Action Cable server.
Parameters
-
envreq
Source
# File actioncable/lib/action_cable/server/base.rb, line 155
def allow_request_origin?(env)
return true if config.disable_request_forgery_protection
request = ActionDispatch::Request.new(env)
proto = request.ssl? ? "https" : "http"
if config.allow_same_origin_as_host && env["HTTP_ORIGIN"] == "#{proto}://#{request.host_with_port}"
true
elsif Array(config.allowed_request_origins).any? { |allowed_origin| allowed_origin === env["HTTP_ORIGIN"] }
true
else
logger.error("Request origin not allowed: #{env['HTTP_ORIGIN']}")
false
end
end
Defined in actioncable/lib/action_cable/server/base.rb line 155
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionCable::Server::ThreadedExecutor::Base