Parent

Files

Devise::Strategies::Unix2ChkpwdAuthenticatable

Public Instance Methods

authenticate!() click to toggle source
# File lib/devise_unix2_chkpwd_authenticatable/strategy.rb, line 13
def authenticate!
  credentials = params[scope]

  # credentials are empty when using HTTP auth
  if credentials.nil?
    # only HTTP Basic authentication is supported
    request.authorization =~ /^Basic (.*)/
    usrname, pwd = Base64.decode64($1).split(/:/, 2)
    credentials = {:username => usrname, :password => pwd}
  end

  if resource = mapping.to.authenticate_with_unix2_chkpwd(credentials)
    Rails.logger.info "*** Success!"
    success!(resource)
  else
    Rails.logger.error "*** Invalid!"
    fail(:invalid)
  end
end
valid?() click to toggle source
# File lib/devise_unix2_chkpwd_authenticatable/strategy.rb, line 7
def valid?
  valid = (valid_params? || valid_http_auth?) && mapping.to.respond_to?(:authenticate_with_unix2_chkpwd)
  Rails.logger.debug "valid?: #{valid}"
  valid
end

Protected Instance Methods

valid_controller?() click to toggle source
# File lib/devise_unix2_chkpwd_authenticatable/strategy.rb, line 35
def valid_controller?
  params[:controller] == 'devise/sessions'
end
valid_http_auth?() click to toggle source
# File lib/devise_unix2_chkpwd_authenticatable/strategy.rb, line 43
def valid_http_auth?
  # HTTP authentication enabled and credentials present in the request
  mapping.to.http_authenticatable?(:unix2chkpwd) && request.authorization && request.authorization.match(/^Basic (.*)/)
end
valid_params?() click to toggle source
# File lib/devise_unix2_chkpwd_authenticatable/strategy.rb, line 39
def valid_params?
  params[scope] && params[scope][:password].present?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.