Skip to content

Instantly share code, notes, and snippets.

@mupkoo
Created May 30, 2014 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mupkoo/9e7b28753c75fbcabf95 to your computer and use it in GitHub Desktop.
Save mupkoo/9e7b28753c75fbcabf95 to your computer and use it in GitHub Desktop.
HTTP Auth for Rails
class ApplicationController < ActionController::Base
include HttpAuthConcern
# the rest of your code
end
module HttpAuthConcern
extend ActiveSupport::Concern
included do
before_action :http_authenticate
end
def http_authenticate
return true unless Rails.env == 'production'
authenticate_or_request_with_http_basic do |username, password|
username == 'username' && password == 'password'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment