Skip to content

Instantly share code, notes, and snippets.

@kamal
Created January 5, 2010 14:40
Show Gist options
  • Save kamal/269412 to your computer and use it in GitHub Desktop.
Save kamal/269412 to your computer and use it in GitHub Desktop.
require "rack/openid"
require "warden"
use Rack::OpenID
use Warden::Manager do |manager|
Warden::Strategies.add(:openid) do
def authenticate!
if resp = env["rack.openid.response"]
case resp.status
when :success
u = User.find_by_identity_url(resp.identity_url)
success!(u)
when :cancel
fail!("OpenID auth cancelled")
when :failure
fail!("OpenID auth failed")
end
else
custom!([401, {"WWW-Authenticate" => 'OpenID identifier="https://www.google.com/accounts/o8/id"'}, "OpenID plz"])
end
end
end
manager.default_strategies :openid
manager.failure_app = lambda do
Rack::Response.new("Failed").finish
end
end
@geetfun
Copy link

geetfun commented Apr 22, 2010

This code is awesome. Thanks kamal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment