Class: Aserto::Authorization
- Inherits:
-
Object
- Object
- Aserto::Authorization
- Defined in:
- lib/aserto/authorization.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) {|@config| ... } ⇒ Authorization
constructor
A new instance of Authorization.
Constructor Details
#initialize(app, options = {}) {|@config| ... } ⇒ Authorization
Returns a new instance of Authorization.
7 8 9 10 11 |
# File 'lib/aserto/authorization.rb', line 7 def initialize(app, = {}) @app = app @config = Aserto.config() yield @config if block_given? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/aserto/authorization.rb', line 5 def config @config end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/aserto/authorization.rb', line 13 def call(env) request = Rack::Request.new(env) allowed = if enabled?(request) Aserto.logger.debug("Aserto authorization enabled") client = Aserto::AuthClient.new(request) res = client.is Aserto.logger.debug("Aserto authorization result -> allowed: #{res}") res else Aserto.logger.debug("Aserto authorization not enabled") true end return @app.call env if allowed config..call(env) end |