Here are some ideas:
class ApplicationController < ActionController::Base
http_basic_authenticate_with :name => "frodo", :password => "thering", :if => :admin_controller?
def admin_controller?
self.class < ActiveAdmin::BaseController
end
Or version of monkeypatching
class ActiveAdmin::BaseController
http_basic_authenticate_with :name => "frodo", :password => "thering"
end
If you only want to protect certain resources, you can use the controller block:
ActiveAdmin.register Users do
controller do
http_basic_authenticate_with :name => "frodo", :password => "thering"
end
end
, config/initializers/active_admin.rb , :
ActiveAdmin.setup do |config|
config.controller do
http_basic_authenticate_with :name => "frodo", :password => "thering"
end
end
, , ActiveAdmin ( , , - -...)
, , .
: :
: before_filter activeadmin .
ActiveAdmin.setup do |config|
config.before_filter do
authenticate_or_request_with_http_basic("Whatever") do |name, password|
name == "frodo" && password == "thering"
end
end
end
... . , - application_controller, , :
class ApplicationController < ActionController::Base
def authenticate_admin
authenticate_or_request_with_http_basic("Whatever") do |name, password|
name == "frodo" && password == "thering"
end
end
end
ActiveAdmin.setup do |config|
config.authentication_method = :authenticate_admin
end