aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_controller.rb
diff options
context:
space:
mode:
authorSeb Bacon <seb.bacon@gmail.com>2011-07-06 12:00:26 +0100
committerSeb Bacon <seb.bacon@gmail.com>2011-07-06 12:00:26 +0100
commit732b3e5c430a83f72adb44dc621d48edb86f081f (patch)
tree63e77046c96d31081579853decc1b8cef2affc94 /app/controllers/admin_controller.rb
parent737f5967131120adab322adf3dbdbd4f40426499 (diff)
fix up basic auth for admin settings: get credentials from config, cause default (where no config) to skip authorization completely, add tests for these
Diffstat (limited to 'app/controllers/admin_controller.rb')
-rw-r--r--app/controllers/admin_controller.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 75658f6de..8598091d9 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -10,8 +10,7 @@ require 'fileutils'
class AdminController < ApplicationController
layout "admin"
- before_filter :authenticate
- USER_NAME, PASSWORD = "sadminiz", "w5x^H^<{J231s3"
+ before_filter :authenticate
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# action to take if expecting an authenticity token and one isn't received
@@ -47,9 +46,13 @@ class AdminController < ApplicationController
end
private
def authenticate
- authenticate_or_request_with_http_basic do |user_name, password|
- user_name == USER_NAME && password == PASSWORD
- end
+ username = MySociety::Config.get('ADMIN_USERNAME', '')
+ password = MySociety::Config.get('ADMIN_PASSWORD', '')
+ if !(username && password).empty?
+ authenticate_or_request_with_http_basic do |user_name, password|
+ user_name == username && password == password
+ end
+ end
end
end