Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Subdomain boxing was inspired by Egor Homakov's post on pageboxing. Subdomain boxing limits the reach of any XSS attacks. If an attacker manages to insert javascript onto a page of your application, the javascript on that page will be unable to read data from or post data to any pages on different subdomains in your application. POST protection is achieved by creating a separate CSRF token for each subdomain. CSRF protection is also strengthened by changing the CSRF token based on session id (request.session_options[:id]).
Demo: http://app.subdomainbox.com
The subdomainbox gem is simple to add even to existing Rails applications:
class ApplicationController
# set up a default subdomain box for all controllers that won't get an explicit subdomain box
# this protects regular pages that don't get a dedicated subdomain box from being accessed
# from a subdomain boxed page
default_subdomainbox ''
...
end
class DocsController < ApplicationController
subdomainbox 'posts', :except => [:edit, :update, :show]
subdomainbox 'edit-%{id}', :only => [:edit, :update]
subdomainbox 'preview-%{id}', :only => :show
...
end
class Admin::DocsController < ApplicationController
subdomainbox 'admin', :only => :index
subdomainbox 'admin-%{doc_id}', :except => :index
...
end
class AvatarIcon < ApplicationController
# for controllers that need to be accessed from many places, that don't need boxing
# protection, the default subdomain box can be removed (thereby allowing ajax calls
# from any subdomain)
remove_default_subdomainbox
...
end
There is no need to adjust your routes or your path / url helpers. Subdomainbox automatically redirects the browser as needed based on your subdomainbox directives.
Add subdomainbox to your gemfile and bundle install
Run the generator (for generating the CSRF token secret):
$ rails generate subdomainbox
Make sure the root domain of your application has a wildcard SSL certificate
Set the domain of your session cookie to the root domain
if Rails.env.development?
cookie_domain = 'lvh.me'
elsif Rails.env.production?
cookie_domain = 'mydomain.com'
end
MyApp::Application.config.session_store :cookie_store, key: '_myapp_session', :domain => cookie_domain
If you use Google Analytics, set up (cross subdomain tracking)[https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#domainSubDomains]
Use lvh.me:3000 instead of localhost:3000 since localhost doesn't support subdomains
In controller specs, we don't want to worry about subdomain-boxing, so stub it out:
controller.stub(:subdomainbox)
Request/feature/integration specs are vital when using subdomain boxing. Non-javascript Capybara + Rack should work out of the box, but Capybara + Selenium/Webkit javascript driver requires modification of the test machine in order for it to work with subdomains:
brew install dnsmasq
mkdir -pv $(brew --prefix)/etc/
echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
-- source http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again
Written by Daniel Nelson. Inspired by Egor Homakov's post on pageboxing.
FAQs
Unknown package
We found that subdomainbox demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.