Skip to content

Commit

Permalink
Simple authentication using translate/current hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
gudata committed Jan 16, 2012
1 parent 0a33ce9 commit d394f7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/controllers/translate_controller.rb
@@ -1,7 +1,17 @@
class TranslateController < ActionController::Base
# It seems users with active_record_store may get a "no :secret given" error if we don't disable csrf protection,
skip_before_filter :verify_authenticity_token

before_filter :authenticate

protected

def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "translate" && password == `hostname`.chomp
end
end

prepend_view_path(File.join(File.dirname(__FILE__), "..", "views"))
layout 'translate'

Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -2,4 +2,4 @@
match 'translate' => 'translate#index', :as => :translate_list
match 'translate/translate' => 'translate#translate', :as => :translate
match 'translate/reload' => 'translate#reload', :as => :translate_reload
end if Rails.env.development?
end

0 comments on commit d394f7d

Please sign in to comment.