Class: OmniAuth::Strategies::Krb5

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Krb5.



12
13
14
15
16
# File 'lib/omniauth/strategies/krb5.rb', line 12

def initialize( app, *args, &block )
  super
  @krb5 = Kerberos::Krb5.new
  @krb5.set_default_realm(options.realm)             
end

Instance Method Details

#callback_phaseObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/omniauth/strategies/krb5.rb', line 25

def callback_phase
  begin
    return fail!(:invalid_credentials) unless username && password
    @krb5.get_init_creds_password(username_with_realm, password)          
    super          
  rescue Exception => e
    return fail!(:invalid_credentials, e)
  ensure
    @krb5.close
  end
end

#realmObject



45
46
47
# File 'lib/omniauth/strategies/krb5.rb', line 45

def realm           
  @krb5.get_default_realm
end

#request_phaseObject



18
19
20
21
22
23
# File 'lib/omniauth/strategies/krb5.rb', line 18

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