Sha256: 866930bc2196a6de817cf5e75cc751175307f806e4ba86cdf669f7a6970bcc07
Contents?: true
Size: 724 Bytes
Versions: 6
Compression:
Stored size: 724 Bytes
Contents
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