Class: RackMyOpenid::Provider

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/rack_my_openid/provider.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Provider

Options can contain

  • :credentials (required) - ‘md5 -s ’username:realm:password’‘

  • :openid (required) - the OpenID you want to authorize

  • :realm (optional, the default is “rack_my_openid”) - an arbitrary resource name for HTTP Authentication



24
25
26
27
28
29
30
31
32
# File 'lib/rack_my_openid/provider.rb', line 24

def initialize(options = {})
  super()
  @options = default_options.merge options
  @auth = Rack::Auth::Digest::MD5.new(lambda{|e| true}, @options[:realm]) do
    @options[:credentials]
  end
  @auth.opaque = $$.to_s
  @auth.passwords_hashed = true
end

Instance Method Details

#authorize!Object

authorization



12
13
14
15
16
17
# File 'lib/rack_my_openid/provider.rb', line 12

def authorize!
  response = @auth.call(request.env)
  unless response===true
    throw(:halt, response)
  end
end

#default_optionsObject



86
87
88
89
90
# File 'lib/rack_my_openid/provider.rb', line 86

def default_options
  {
    :realm => 'rack_my_openid'
  }
end

#render_openid_response(response) ⇒ Object



80
81
82
83
84
# File 'lib/rack_my_openid/provider.rb', line 80

def render_openid_response(response)
  status response.code
  headers response.headers
  body response.body
end