Class: OpenRosa::Middleware::Configuration
- Inherits:
-
Object
- Object
- OpenRosa::Middleware::Configuration
- Defined in:
- lib/open_rosa/middleware.rb
Overview
Configuration object for the middleware
Instance Attribute Summary collapse
-
#authentication_handler ⇒ Object
Returns the value of attribute authentication_handler.
-
#authentication_realm ⇒ Object
Returns the value of attribute authentication_realm.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#forms ⇒ Object
Returns the value of attribute forms.
-
#max_submission_size ⇒ Object
Returns the value of attribute max_submission_size.
-
#mount_path ⇒ Object
Returns the value of attribute mount_path.
-
#skip_authentication_for ⇒ Object
Returns the value of attribute skip_authentication_for.
-
#submission_handler ⇒ Object
Returns the value of attribute submission_handler.
Instance Method Summary collapse
-
#authenticate {|env| ... } ⇒ Object
Set the authentication handler callback.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#on_submission {|submission| ... } ⇒ Object
Set the submission handler callback.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
312 313 314 315 316 317 318 319 320 321 |
# File 'lib/open_rosa/middleware.rb', line 312 def initialize @forms = [] @mount_path = "/openrosa" @base_url = nil @submission_handler = nil @max_submission_size = 10_485_760 # 10MB default @authentication_handler = nil @skip_authentication_for = [] @authentication_realm = "OpenRosa" end |
Instance Attribute Details
#authentication_handler ⇒ Object
Returns the value of attribute authentication_handler.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def authentication_handler @authentication_handler end |
#authentication_realm ⇒ Object
Returns the value of attribute authentication_realm.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def authentication_realm @authentication_realm end |
#base_url ⇒ Object
Returns the value of attribute base_url.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def base_url @base_url end |
#forms ⇒ Object
Returns the value of attribute forms.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def forms @forms end |
#max_submission_size ⇒ Object
Returns the value of attribute max_submission_size.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def max_submission_size @max_submission_size end |
#mount_path ⇒ Object
Returns the value of attribute mount_path.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def mount_path @mount_path end |
#skip_authentication_for ⇒ Object
Returns the value of attribute skip_authentication_for.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def skip_authentication_for @skip_authentication_for end |
#submission_handler ⇒ Object
Returns the value of attribute submission_handler.
309 310 311 |
# File 'lib/open_rosa/middleware.rb', line 309 def submission_handler @submission_handler end |
Instance Method Details
#authenticate {|env| ... } ⇒ Object
Set the authentication handler callback
Example:
config.authenticate do |env|
request = Rack::Request.new(env)
auth = Rack::Auth::Basic::Request.new(env)
if auth.provided? && auth.basic?
username, password = auth.credentials
User.authenticate(username, password) # Returns user object or nil
end
end
347 348 349 |
# File 'lib/open_rosa/middleware.rb', line 347 def authenticate(&block) @authentication_handler = block end |
#on_submission {|submission| ... } ⇒ Object
Set the submission handler callback
328 329 330 |
# File 'lib/open_rosa/middleware.rb', line 328 def on_submission(&block) @submission_handler = block end |