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



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

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

#init_authenticator(request, env, username) ⇒ Object



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

def init_authenticator(request, env, username)
  @request  = request
  @env      = env
  @username = username
end

#other_phaseObject



58
59
60
61
62
63
64
# File 'lib/omniauth/strategies/kerberos.rb', line 58

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



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

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
  @username || request&.params[username_id]&.to_s
end

#username_idObject



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

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