Skip to content

Instantly share code, notes, and snippets.

@mcka1n
Created April 15, 2016 21:26
Show Gist options
  • Save mcka1n/8dda2b0859b7b9e51d685d9ec76346d8 to your computer and use it in GitHub Desktop.
Save mcka1n/8dda2b0859b7b9e51d685d9ec76346d8 to your computer and use it in GitHub Desktop.
Rails Basic Auth
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate
private
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "tu_user" && password == "tu_password"
end
warden.custom_failure! if performed?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment