Skip to content

Instantly share code, notes, and snippets.

@talsafran
Last active December 22, 2015 18:09
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 talsafran/dd1d9102e4354444d84c to your computer and use it in GitHub Desktop.
Save talsafran/dd1d9102e4354444d84c to your computer and use it in GitHub Desktop.
Adding HTTP authentication to protect your posts
# Add this to app/controllers/posts_controller.rb, right after the PostsController
# class is declared.
http_basic_authenticate_with name: "some_username", password: "some_password", only: [:index, :new, :create, :edit, :update, :destroy]
# Of course, you can also use this shorter method
http_basic_authenticate_with name: "some_username", password: "some_password", except: :show
# For more information, check out this Rails Guide
# http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment