Skip to content

Instantly share code, notes, and snippets.

Created June 14, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2931127 to your computer and use it in GitHub Desktop.
Save anonymous/2931127 to your computer and use it in GitHub Desktop.
require 'rack/openid'
require 'rack/session/cookie'
require './dashboard-metrics'
check_app = lambda do |env|
path = env['PATH_INFO']
script = env['SCRIPT_NAME']
out = ""
return [200, {"Content-Type" => "text/html"}, [out]]
end
home_app = lambda do |env|
path = env['PATH_INFO']
script = env['SCRIPT_NAME']
out = ""
return [302, {"Location" => "/fnordmetrics"}, [out]]
end
metrics_app = lambda do |env|
if resp = env["rack.openid.response"]
case resp.status
when :success
FnordMetric.embedded
when :failure
[401, {}, ["Authentication failed."]]
end
else
[401, {
"WWW-Authenticate" => Rack::OpenID.build_header(
:identifier => "https://www.google.com/accounts/o8/id",
:required => ["http://axschema.org/contact/email"],
:return_to => '/fnordmetrics',
:method => 'POST')
}, []]
end
end
use Rack::Session::Cookie
use Rack::OpenID
run Rack::URLMap.new("/" => home_app, "/check" => check_app, "/fnordmetrics" => metrics_app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment