Skip to content

Instantly share code, notes, and snippets.

@davidcornu
Created March 21, 2012 19:35
Show Gist options
  • Save davidcornu/2151803 to your computer and use it in GitHub Desktop.
Save davidcornu/2151803 to your computer and use it in GitHub Desktop.
http basic auth with rails
# -*- encoding : utf-8 -*-
class StaticController < ApplicationController
before_filter :admin_authentication, :only => :api_test
def index
end
def getting_started
end
def hardware
end
def pricing
end
def product_tour
end
def contact
end
def api_test
render :layout => false
end
private
def admin_authentication
authenticate_or_request_with_http_basic do |username, password|
credentials = Ambrosia::Application.config.admin_credentials
username == credentials['username'] && password == credentials['password']
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment