Class: Rack::OpenID::SimpleAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/openid/simple_auth.rb

Overview

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, identifier) ⇒ SimpleAuth

Returns a new instance of SimpleAuth.



19
20
21
22
# File 'lib/rack/openid/simple_auth.rb', line 19

def initialize(app, identifier)
  @app        = app
  @identifier = identifier
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



17
18
19
# File 'lib/rack/openid/simple_auth.rb', line 17

def app
  @app
end

#identifierObject (readonly)

Returns the value of attribute identifier.



17
18
19
# File 'lib/rack/openid/simple_auth.rb', line 17

def identifier
  @identifier
end

Class Method Details

.new(*args) ⇒ Object



13
14
15
# File 'lib/rack/openid/simple_auth.rb', line 13

def self.new(*args)
  Rack::OpenID.new(super)
end

Instance Method Details

#call(env) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/rack/openid/simple_auth.rb', line 24

def call(env)
  if session_authenticated?(env)
    app.call(env)
  elsif successful_response?(env)
    authenticate_session(env)
    app.call(env)
  else
    authentication_request
  end
end