Sha256: 5c4f8fd4454f41e7a18899e5e4617c004967e149faa56820828330abfbce91d8
Contents?: true
Size: 755 Bytes
Versions: 6
Compression:
Stored size: 755 Bytes
Contents
# frozen_string_literal: true module Rails module Auth module Monitor # Fires a user-specified callback which reports on authorization success # or failure. Useful for logging or monitoring systems for AuthZ failures class Middleware def initialize(app, callback) raise ArgumentError, "callback must respond to :call" unless callback.respond_to?(:call) @app = app @callback = callback end def call(env) begin result = @app.call(env) rescue Rails::Auth::NotAuthorizedError @callback.call(env, false) raise end @callback.call(env, true) result end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems