Skip to content

Instantly share code, notes, and snippets.

@technicalpickles
Created September 18, 2014 20:08
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 technicalpickles/396a55d2c7198cd7090b to your computer and use it in GitHub Desktop.
Save technicalpickles/396a55d2c7198cd7090b to your computer and use it in GitHub Desktop.
Rails ENV based HTTP auth
class PostsController < ApplicationController
if ENV['HTTP_AUTH_USERNAME'].present? && ENV['HTTP_AUTH_PASSWORD'].present?
http_basic_authenticate_with name: ENV['HTTP_AUTH_USERNAME'], password: ENV['HTTP_AUTH_PASSWORD']
def index
render plain: "Everyone can see me!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment