Parent

Files

Merb::Authentication::Strategies::Basic::OpenID

Public Instance Methods

customize_openid_request!(openid_request) click to toggle source

Overwrite this to add extra options to the OpenID request before it is made.

@example request.return_to_args[“remember_me“] = 1 # remember_me=1 is added when returning from the OpenID provider.

@api overwritable

    # File lib/merb-auth-more/strategies/basic/openid.rb, line 68
68:         def customize_openid_request!(openid_request)
69:         end
find_user_by_identity_url(url) click to toggle source

Overwrite this to support an ORM other than DataMapper

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 134
134:         def find_user_by_identity_url(url)
135:           user_class.first(:identity_url => url)
136:         end
on_cancel!(response) click to toggle source

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 113
113:         def on_cancel!(response)
114:           request.session.authentication.errors.clear!
115:           request.session.authentication.errors.add(:openid, 'OpenID rejected our request')
116:           nil
117:         end
on_failure!(response) click to toggle source

Overwrite the on_failure! method with the required behavior for failed logins

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 97
 97:         def on_failure!(response)
 98:           session.authentication.errors.clear!
 99:           session.authentication.errors.add(:openid, 'OpenID verification failed, maybe the provider is down? Or the session timed out')
100:           nil
101:         end
on_setup_needed!(response) click to toggle source

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 105
105:         def on_setup_needed!(response)
106:           request.session.authentication.errors.clear!
107:           request.session.authentication.errors.add(:openid, 'OpenID does not seem to be configured correctly')
108:           nil
109:         end
on_success!(response, sreg_response) click to toggle source

Overwrite the on_success! method with the required behavior for successful logins

@api overwritable

    # File lib/merb-auth-more/strategies/basic/openid.rb, line 82
82:         def on_success!(response, sreg_response)
83:           if user = find_user_by_identity_url(response.identity_url)
84:             user
85:           else
86:             request.session[:'openid.url'] = response.identity_url
87:             required_reg_fields.each do |f|
88:               session[:"openid.#{f}"] = sreg_response.data[f] if sreg_response.data[f]
89:             end if sreg_response
90:             redirect!(Merb::Router.url(:signup))
91:           end
92:         end
openid_callback_url() click to toggle source

Used to define the callback url for the openid provider. By default it is set to the named :openid route.

@api overwritable

    # File lib/merb-auth-more/strategies/basic/openid.rb, line 75
75:         def openid_callback_url
76:           "#{request.protocol}://#{request.host}#{Merb::Router.url(:openid)}"
77:         end
openid_store() click to toggle source

Overwrite this method to set your store

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 141
141:         def openid_store
142:           ::OpenID::Store::Filesystem.new("#{Merb.root}/tmp/openid")
143:         end
optional_reg_fields() click to toggle source

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 127
127:         def optional_reg_fields
128:           ['fullname']
129:         end
required_reg_fields() click to toggle source

@api overwritable

     # File lib/merb-auth-more/strategies/basic/openid.rb, line 121
121:         def required_reg_fields
122:           ['nickname', 'email']
123:         end
run!() click to toggle source
    # File lib/merb-auth-more/strategies/basic/openid.rb, line 29
29:         def run!
30:           if request.params[:'openid.mode']
31:             response = consumer.complete(request.send(:query_params), "#{request.protocol}://#{request.host}" + request.path)
32:             case response.status.to_s
33:             when 'success'
34:               sreg_response = ::OpenID::SReg::Response.from_success_response(response)
35:               result = on_success!(response, sreg_response)
36:               Merb.logger.info "\n\n#{result.inspect}\n\n"
37:               result
38:             when 'failure'
39:               on_failure!(response)
40:             when  'setup_needed'
41:               on_setup_needed!(response)
42:             when 'cancel'
43:               on_cancel!(response)
44:             end
45:           elsif identity_url = params[:openid_url]
46:             begin
47:               openid_request = consumer.begin(identity_url)
48:               openid_reg = ::OpenID::SReg::Request.new
49:               openid_reg.request_fields(required_reg_fields, true)
50:               openid_reg.request_fields(optional_reg_fields)
51:               openid_request.add_extension(openid_reg)
52:               customize_openid_request!(openid_request)
53:               redirect!(openid_request.redirect_url("#{request.protocol}://#{request.host}", openid_callback_url))
54:             rescue ::OpenID::OpenIDError => e
55:               request.session.authentication.errors.clear!
56:               request.session.authentication.errors.add(:openid, 'The OpenID verification failed')
57:               nil
58:             end
59:           end
60:         end

Private Instance Methods

consumer() click to toggle source
     # File lib/merb-auth-more/strategies/basic/openid.rb, line 146
146:         def consumer
147:           @consumer ||= ::OpenID::Consumer.new(request.session, openid_store)
148:         end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.