Class: OmniAuth::Strategies::Kerberos

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

Instance Method Summary collapse

Constructor Details

#initialize(app, *args, &block) ⇒ Kerberos

Returns a new instance of Kerberos.



15
16
17
18
# File 'lib/omniauth/strategies/kerberos.rb', line 15

def initialize(app, *args, &block)
  super
  @krb5 = ::Krb5Auth::Krb5.new
end

Instance Method Details

#callback_phaseObject



36
37
38
39
40
41
42
# File 'lib/omniauth/strategies/kerberos.rb', line 36

def callback_phase
  if authenticate(username, password)
    super
  else
    fail!(:invalid_credentials)
  end
end

#other_phaseObject



52
53
54
55
56
57
58
# File 'lib/omniauth/strategies/kerberos.rb', line 52

def other_phase
  if on_request_path?
    request_phase
  else
    call_app!
  end
end

#passwordObject



32
33
34
# File 'lib/omniauth/strategies/kerberos.rb', line 32

def password
  request&.params[password_id]
end

#password_idObject



24
25
26
# File 'lib/omniauth/strategies/kerberos.rb', line 24

def password_id
  options[:fields][1]&.to_s || 'password'
end

#request_phaseObject



44
45
46
47
48
49
50
# File 'lib/omniauth/strategies/kerberos.rb', line 44

def request_phase
  form = OmniAuth::Form.build(title: options.title, url: callback_url) do |f|
    f.text_field     'Username', username_id
    f.password_field 'Password', password_id
  end
  form.to_response
end

#usernameObject



28
29
30
# File 'lib/omniauth/strategies/kerberos.rb', line 28

def username
  request&.params[username_id]
end

#username_idObject



20
21
22
# File 'lib/omniauth/strategies/kerberos.rb', line 20

def username_id
  options[:fields][0]&.to_s || 'username'
end