Skip to content

Instantly share code, notes, and snippets.

@vcavallo
Created December 8, 2014 21:37
Show Gist options
  • Save vcavallo/80f01ad6fb4b90993dfd to your computer and use it in GitHub Desktop.
Save vcavallo/80f01ad6fb4b90993dfd to your computer and use it in GitHub Desktop.
password protect any site without devise users
class AnyController < ApplicationController
# HTTP authentication should be used for staging to prevent unauthorized outside access to application.
before_filter :authenticate if Rails.env.staging?
private
def authenticate
authenticate_or_request_with_http_basic do |user,pass|
user == "usernamehere" && pass == "passwordhere"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment