Skip to content

Instantly share code, notes, and snippets.

@obfusk
Created November 18, 2013 21:31
Show Gist options
  • Save obfusk/7535687 to your computer and use it in GitHub Desktop.
Save obfusk/7535687 to your computer and use it in GitHub Desktop.
[OBSOLETE: NOW THAT PULL REQUEST IS MERGED, YOU CAN USE BCRYPT w/ COMFORTABLE-MEXICAN-SOFA] comfortable-mexican-sofa http auth w/ bcrypt
# Gemfile:
# gem 'bcrypt-ruby'
#
# config/initializers/comfortable_mexican_sofa.rb:
# config.admin_auth = 'ComfortableMexicanSofa::HttpAuthBCrypt'
# ComfortableMexicanSofa::HttpAuthBCrypt.username = 'myname'
# ComfortableMexicanSofa::HttpAuthBCrypt.password = BCrypt::Password.new '...hash...'
require 'bcrypt'
module ComfortableMexicanSofa::HttpAuthBCrypt
mattr_accessor :username, :password
def authenticate
authenticate_or_request_with_http_basic do |username, password|
self.username == username && self.password == password
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment