Class: OmniAuth::Strategies::Password
- Inherits:
-
Object
- Object
- OmniAuth::Strategies::Password
show all
- Includes:
- OmniAuth::Strategy
- Defined in:
- lib/omniauth/strategies/password.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#call, #call!, #call_app!, #call_through_to_app, #callback_path, #callback_url, #current_path, #fail!, #full_host, included, #mock_call!, #path_prefix, #query_string, #redirect, #request, #request_path, #script_name, #session, #setup_path, #setup_phase, #user_info
Constructor Details
#initialize(app, secret = 'changethisappsecret', options = {}, &block) ⇒ Password
Returns a new instance of Password.
9
10
11
12
|
# File 'lib/omniauth/strategies/password.rb', line 9
def initialize(app, secret = 'changethisappsecret', options = {}, &block)
@secret = secret
super(app, :password, options, &block)
end
|
Instance Attribute Details
#secret ⇒ Object
Returns the value of attribute secret.
14
15
16
|
# File 'lib/omniauth/strategies/password.rb', line 14
def secret
@secret
end
|
Instance Method Details
#auth_hash(crypted_password) ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/omniauth/strategies/password.rb', line 25
def auth_hash(crypted_password)
OmniAuth::Utils.deep_merge(super(), {
'uid' => crypted_password,
'user_info' => {
@options[:identifier_key] => request[:identifier]
}
})
end
|
#callback_phase ⇒ Object
34
35
36
|
# File 'lib/omniauth/strategies/password.rb', line 34
def callback_phase
call_app!
end
|
#encrypt(identifier, password) ⇒ Object
38
39
40
|
# File 'lib/omniauth/strategies/password.rb', line 38
def encrypt(identifier, password)
Digest::SHA1.hexdigest([identifier, password, secret].join('::'))
end
|
#request_phase ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/omniauth/strategies/password.rb', line 16
def request_phase
return fail!(:missing_information) unless request[:identifier] && request[:password]
return fail!(:password_mismatch) if request[:password_confirmation] && request[:password_confirmation] != '' && request[:password] != request[:password_confirmation]
env['REQUEST_METHOD'] = 'GET'
env['PATH_INFO'] = request.path + '/callback'
env['omniauth.auth'] = auth_hash(encrypt(request[:identifier], request[:password]))
call_app!
end
|