Class: Auther::Gatekeeper
- Inherits:
-
Object
- Object
- Auther::Gatekeeper
- Defined in:
- lib/auther/gatekeeper.rb
Overview
Rack middleware that guards access to sensitive routes. rubocop:disable Metrics/ClassLength
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.
11 12 13 14 |
# File 'lib/auther/gatekeeper.rb', line 11 def initialize application, settings = {} @application = application @settings = Auther::Settings.new settings end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
7 8 9 |
# File 'lib/auther/gatekeeper.rb', line 7 def application @application end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
7 8 9 |
# File 'lib/auther/gatekeeper.rb', line 7 def environment @environment end |
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
7 8 9 |
# File 'lib/auther/gatekeeper.rb', line 7 def settings @settings end |
Instance Method Details
#call(environment) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/auther/gatekeeper.rb', line 16 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.auth_url denied_response.finish end end |