Class: Auther::Gatekeeper
- Inherits:
-
Object
- Object
- Auther::Gatekeeper
- Defined in:
- lib/auther/gatekeeper.rb
Overview
Rack middleware that guards access to sensitive routes.
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
Instance Method Summary collapse
- #call(environment) ⇒ Object
-
#initialize(application, settings = {}) ⇒ Gatekeeper
constructor
A new instance of Gatekeeper.
Constructor Details
#initialize(application, settings = {}) ⇒ Gatekeeper
Returns a new instance of Gatekeeper.
10 11 12 13 |
# File 'lib/auther/gatekeeper.rb', line 10 def initialize application, settings = {} @application = application @settings = Auther::Settings.new settings end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
6 7 8 |
# File 'lib/auther/gatekeeper.rb', line 6 def application @application end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
6 7 8 |
# File 'lib/auther/gatekeeper.rb', line 6 def environment @environment end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
6 7 8 |
# File 'lib/auther/gatekeeper.rb', line 6 def settings @settings end |
Instance Method Details
#call(environment) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/auther/gatekeeper.rb', line 15 def call environment @environment = environment if request.path application.call environment else session[Auther::Keymaster.redirect_url_key] = request.path denied_response = response denied_response.redirect settings.url denied_response.finish end end |