Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Warden::Strategies.add(:openid) do
def valid?
!params["openid_identifier"].blank?
end
def authenticate!
if resp = env[Rack::OpenID::RESPONSE]
RAILS_DEFAULT_LOGGER.info "Attempting OpenID auth: #{env["rack.openid.response"].inspect}"
case resp.status
when :success
u = Person.find_for_authentication(:openid_url => resp.identity_url)
success!(u)
when :cancel
fail!("OpenID auth cancelled")
when :failure
fail!("OpenID auth failed")
end
else
header_data = Rack::OpenID.build_header(:identifier => params["openid_identifier"])
RAILS_DEFAULT_LOGGER.info header_data
custom!([401, {
Rack::OpenID::AUTHENTICATE_HEADER => header_data
}, "Sign in with OpenID"])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.