Created
June 13, 2011 15:56
-
-
Save sorentwo/1023055 to your computer and use it in GitHub Desktop.
Patch devise authenticatable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/application.rb | |
module MyApp | |
class Application < Rails::Application | |
require 'devise/authenticatable' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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