Module: AuthHMAC::Rails::ControllerFilter::ClassMethods

Defined in:
lib/auth-hmac.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#with_auth_hmac(credentials, options = {}) ⇒ Object

Call within a Rails Controller to initialize HMAC authentication for the controller.

  • credentials must be a hash that indexes secrets by their access key id.

  • options supports the following arguments:

    • failure_message: The text to use when authentication fails.

    • only: A list off actions to protect.

    • except: A list of actions to not protect.

    • hmac: Options for HMAC creation. See AuthHMAC#initialize for options.



256
257
258
259
260
261
262
263
264
265
# File 'lib/auth-hmac.rb', line 256

def with_auth_hmac(credentials, options = {})
  unless credentials.nil?
    self.credentials = credentials
    self.authhmac_failure_message = (options.delete(:failure_message) or "HMAC Authentication failed")
    self.authhmac = AuthHMAC.new(self.credentials, options.delete(:hmac))
    before_filter(:hmac_login_required, options)
  else
    $stderr.puts("with_auth_hmac called with nil credentials - authentication will be skipped")
  end
end