I am dealing with oauth 1.0 (twitter and flickr). Website works at port 80 and oauth server works at port 8080
Algorithm:
It uses sinatra + rack:session + rack::session::sequel + sqlite to store sessions. It sends Set-Cookie: rack.session=id
in each response
I am using 2 types of request: crossdomain ajax with jquery and usual request with window.open. I have a big security problem passing cookies to crossdomain ajax request.
No matter that server's response headers contains
Access-Control-Allow-Headers: *
chromium will throw security error:
Refused to set unsafe header "Cookie"
I want to avoid this problem by passing rack.session=id to post data and load it:
before "/twitter/connect.json" do
session = Rack::Session::something(params["rack.session"])
end
But I cant find in documentation how to do this
Rack::Session::Abstract::ID
has an option called cookie_only
that allows the session id to be passed in via the params. However, it defaults to true, and most session middleware implementations don't bother to override it.
Your best bet is probably to monkey patch Rack::Session::Abstract::ID
to default cookie_only
to false.
Rack::Session::Abstract::ID::DEFAULT_OPTIONS.merge! :cookie_only => false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With