Skip to content

Instantly share code, notes, and snippets.

@jamiew
Created April 30, 2011 04:54
Show Gist options
  • Save jamiew/949435 to your computer and use it in GitHub Desktop.
Save jamiew/949435 to your computer and use it in GitHub Desktop.
Devise HTTP auth + rememberable monkeypatching attempts...
# Monkeypatch Devise so HTTP Basic auth remembers you!
# config/initializers/devise_http_rememberable.rb
# Try 1...
module Devise
module Hooks
module Rememberable
def remember_me?
STDERR.puts "******* Devise::Hooks::Rememberable.remember_me?"
true
end
end
end
end
# Try 2...
module Devise
module Strategies
class Rememberable < Authenticatable
def remember_me?
STDERR.puts "WAAAAAAAAAAAAT remember_me?"
true
end
def remember_cookie
STDERR.puts "WAAAAAAAAAAAAT remember_cookie"
@remember_cookie ||= cookies.signed[remember_key]
end
end
end
end
# Try 3...
module Devise
module Strategies
class Authenticatable < Base
# Extract a hash with attributes:values from the http params.
def http_auth_hash
keys = [authentication_keys.first, :password]
wat = Hash[*keys.zip(decode_credentials).flatten]
wat[:remember_me] = 1
STDERR.puts "CUSTOM http_auth_hash, wat=#{wat.inspect}"
return wat
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment