Sha256: 2c4119db860624fd031ba43bdaead05898195b5e26acdf6543bae402651c5ed3
Contents?: true
Size: 728 Bytes
Versions: 2
Compression:
Stored size: 728 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 TypeError, "expected Proc callback, got #{callback.class}" unless callback.is_a?(Proc) @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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails-auth-2.0.2 | lib/rails/auth/monitor/middleware.rb |
rails-auth-2.0.1 | lib/rails/auth/monitor/middleware.rb |