A simple OpenID middleware that restricts access to a single identifier.
use Rack::OpenID::SimpleAuth, "http://example.org"
SimpleAuth will automatically insert the
required Rack::OpenID middleware, so use
Rack::OpenID
is unnecessary.
# File lib/rack/openid/simple_auth.rb, line 14 def self.new(*args) Rack::OpenID.new(super) end
# File lib/rack/openid/simple_auth.rb, line 20 def initialize(app, identifier) @app = app @identifier = identifier end
# File lib/rack/openid/simple_auth.rb, line 25 def call(env) if session_authenticated?(env) app.call(env) elsif successful_response?(env) authenticate_session(env) redirect_to requested_url(env) else authentication_request end end