Class: OmniContacts::Middleware::BaseOAuth
- Inherits:
-
Object
- Object
- OmniContacts::Middleware::BaseOAuth
- Defined in:
- lib/omnicontacts/middleware/base_oauth.rb
Instance Attribute Summary collapse
-
#ssl_ca_file ⇒ Object
readonly
Returns the value of attribute ssl_ca_file.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Rack callback.
- #class_name ⇒ Object
-
#initialize(app, options) ⇒ BaseOAuth
constructor
A new instance of BaseOAuth.
Constructor Details
#initialize(app, options) ⇒ BaseOAuth
Returns a new instance of BaseOAuth.
14 15 16 17 18 |
# File 'lib/omnicontacts/middleware/base_oauth.rb', line 14 def initialize app, @app = app @listening_path = MOUNT_PATH + class_name @ssl_ca_file = [:ssl_ca_file] end |
Instance Attribute Details
#ssl_ca_file ⇒ Object (readonly)
Returns the value of attribute ssl_ca_file.
12 13 14 |
# File 'lib/omnicontacts/middleware/base_oauth.rb', line 12 def ssl_ca_file @ssl_ca_file end |
Instance Method Details
#call(env) ⇒ Object
Rack callback. It handles three cases:
-
user visit middleware entry point. In this case request_authorization_from_user is called
-
user is redirected back to the application from the authorization site. In this case the list of contacts is fetched and stored in the variables omnicontacts.contacts within the Rack env variable. Once that is done the next middleware component is called.
-
user visits any other resource. In this case the request is simply forwarded to the next middleware component.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/omnicontacts/middleware/base_oauth.rb', line 34 def call env @env = env if env["PATH_INFO"] =~ /^#{@listening_path}\/?$/ session['omnicontacts.params'] = Rack::Request.new(env).params handle_initial_request elsif env["PATH_INFO"] =~ /^#{redirect_path}/ env['omnicontacts.params'] = session.delete('omnicontacts.params') handle_callback else @app.call(env) end end |
#class_name ⇒ Object
20 21 22 |
# File 'lib/omnicontacts/middleware/base_oauth.rb', line 20 def class_name self.class.name.split('::').last.downcase end |