Skip to content

Instantly share code, notes, and snippets.

@qichunren
Created March 9, 2011 09:24
Show Gist options
  • Save qichunren/861931 to your computer and use it in GitHub Desktop.
Save qichunren/861931 to your computer and use it in GitHub Desktop.
login from http basic authcation
class ApplicationController < ActionController::Base
USER_NAME, PASSWORD = "xx", "secret"
protect_from_forgery
before_filter :login_from_http_auth
protected
def login_from_http_auth
authenticate_or_request_with_http_basic do |user_name, password|
user_name == USER_NAME && password == PASSWORD
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment