Skip to content

Instantly share code, notes, and snippets.

@ursm
Forked from kamal/gist:269412
Created January 12, 2010 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ursm/274806 to your computer and use it in GitHub Desktop.
Save ursm/274806 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment