Created
September 10, 2011 19:05
-
-
Save sevennineteen/1208656 to your computer and use it in GitHub Desktop.
Basic security check to prevent cross-site requests (using Sinatra)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "sinatra" | |
require "json" | |
require "haml" | |
get '/' do | |
CURRENT_HOST = env['SERVER_NAME'] == 'localhost' ? "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}" : env['SERVER_NAME'] | |
haml :home | |
end | |
get '/test_json' do | |
halt 403, "DENIED: unknown referrer" unless request.referer && request.referer.match(request.host) | |
return JSON 'test' => 123 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment