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