Class: RackMyOpenid::Provider
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- RackMyOpenid::Provider
- Defined in:
- lib/rack_my_openid/provider.rb
Instance Method Summary collapse
-
#authorize! ⇒ Object
authorization.
- #default_options ⇒ Object
-
#initialize(options = {}) ⇒ Provider
constructor
Options can contain.
- #render_openid_response(response) ⇒ Object
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( = {}) super() @options = .merge @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 response = @auth.call(request.env) unless response===true throw(:halt, response) end end |
#default_options ⇒ Object
86 87 88 89 90 |
# File 'lib/rack_my_openid/provider.rb', line 86 def { :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 |