Skip to content

Instantly share code, notes, and snippets.

@mpugach
Created November 1, 2014 15:34
Show Gist options
  • Select an option

  • Save mpugach/0622dc8b1139d678f781 to your computer and use it in GitHub Desktop.

Select an option

Save mpugach/0622dc8b1139d678f781 to your computer and use it in GitHub Desktop.
Rails basic auth
class ApplicationController < ActionController::Base
before_filter :enable_http_auth, if: :use_http_auth?
private
def use_http_auth?
Rails.env.production?
end
def enable_http_auth
authenticate_or_request_with_http_basic('Application') do |name, password|
name == 'ved_akadem' && password == 'secret123!'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment