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

- (SimpleAuth) initialize(app, identifier)



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

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

Instance Attribute Details

- (Object) app (readonly)

Returns the value of attribute app



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

def app
  @app
end

- (Object) identifier (readonly)

Returns the value of attribute identifier



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

def identifier
  @identifier
end

Class Method Details

+ (Object) new(*args)



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

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

Instance Method Details

- (Object) call(env)



25
26
27
28
29
30
31
32
33
34
# 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