Class: OmniAuth::Strategies::PAM

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/pam.rb

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/omniauth/strategies/pam.rb', line 22

def callback_phase
  rpam_opts = Hash.new
  rpam_opts[:service] = options[:service] unless options[:service].nil?

  unless Rpam.auth(request['username'], request['password'], rpam_opts)
    return fail!(:invalid_credentials)
  end

  super
end

#parse_gecosObject



33
34
35
36
37
38
39
40
41
# File 'lib/omniauth/strategies/pam.rb', line 33

def parse_gecos
  if options[:gecos_map].kind_of?(Array)
    begin
      gecos = Etc.getpwnam(uid).gecos.split(',')
      Hash[options[:gecos_map].zip(gecos)].delete_if { |k, v| v.nil? }
    rescue
    end
  end
end

#request_phaseObject



12
13
14
15
16
17
18
19
20
# File 'lib/omniauth/strategies/pam.rb', line 12

def request_phase
  OmniAuth::Form.build(
    :title => (options[:title] || "Authenticate"), 
    :url => callback_path
  ) do |field|
    field.text_field 'Username', 'username'
    field.password_field 'Password', 'password'
  end.to_response
end