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!, #callback_url, #fail!, #full_host, included, #redirect, #request, #session, #user_info
Constructor Details
#initialize(app, secret = 'changethisappsecret', options = {}) ⇒ Password
Returns a new instance of Password.
9
10
11
12
13
|
# File 'lib/omniauth/strategies/password.rb', line 9
def initialize(app, secret = 'changethisappsecret', options = {})
@options = options
@secret = secret
super(app, :password)
end
|
Instance Attribute Details
#secret ⇒ Object
Returns the value of attribute secret.
15
16
17
|
# File 'lib/omniauth/strategies/password.rb', line 15
def secret
@secret
end
|
Instance Method Details
#auth_hash(crypted_password) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/omniauth/strategies/password.rb', line 26
def auth_hash(crypted_password)
OmniAuth::Utils.deep_merge(super(), {
'uid' => crypted_password,
'user_info' => {
@options[:identifier_key] => request[:identifier]
}
})
end
|
#callback_phase ⇒ Object
35
36
37
|
# File 'lib/omniauth/strategies/password.rb', line 35
def callback_phase
call_app!
end
|
#encrypt(identifier, password) ⇒ Object
39
40
41
|
# File 'lib/omniauth/strategies/password.rb', line 39
def encrypt(identifier, password)
Digest::SHA1.hexdigest([identifier, password, secret].join('::'))
end
|
#request_phase ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/omniauth/strategies/password.rb', line 17
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
|