Skip to content

Instantly share code, notes, and snippets.

@sorentwo
Created June 13, 2011 15:56
Show Gist options
  • Save sorentwo/1023055 to your computer and use it in GitHub Desktop.
Save sorentwo/1023055 to your computer and use it in GitHub Desktop.
Patch devise authenticatable
# config/application.rb
module MyApp
class Application < Rails::Application
require 'devise/authenticatable'
end
end
# lib/devise/authenticatble.rb
# Monkeypatch devise to accept a raw token without Base64 encoding and with the
# identifier 'token'.
module Devise
module Strategies
class Authenticatable < Base
private
# Helper to decode credentials from HTTP.
def decode_credentials
case request.authorization
when /^Basic (.*)/mi
ActiveSupport::Base64.decode64($1).split(/:/, 2)
when /^Token (\w*)/mi
[$1, '']
else
[]
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment