Class: Sso::Warden::Hooks::AfterAuthentication
- Inherits:
-
Object
- Object
- Sso::Warden::Hooks::AfterAuthentication
show all
- Includes:
- Logging
- Defined in:
- lib/sso/warden/hooks/after_authentication.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
#debug, #error, #fatal, #info, #warn
Constructor Details
Returns a new instance of AfterAuthentication.
17
18
19
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 17
def initialize(user, warden, options)
@user, @warden, @options = user, warden, options
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7
8
9
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 7
def options
@options
end
|
#user ⇒ Object
Returns the value of attribute user.
7
8
9
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 7
def user
@user
end
|
#warden ⇒ Object
Returns the value of attribute warden.
7
8
9
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 7
def warden
@warden
end
|
Class Method Details
.to_proc ⇒ Object
11
12
13
14
15
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 11
def self.to_proc
proc do |user, warden, options|
new(user, warden, options).call
end
end
|
Instance Method Details
#call ⇒ Object
21
22
23
24
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 21
def call
debug { "Starting hook because this is considered the first login of the current session..." }
generate_session
end
|
#generate_session ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 26
def generate_session
debug { "Generating a Sso:Session for user #{user.id.inspect} for the session cookie at the Sso server..." }
attributes = { ip: request.ip, agent: request.user_agent }
sso_session = Sso::Session.generate_master(user, attributes)
debug { "Sso:Session with ID #{sso_session.id} generated successfuly. Persisting it in session..." }
session["sso_session_id"] = sso_session.id.to_s
end
|
#logged_in? ⇒ Boolean
43
44
45
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 43
def logged_in?
warden.authenticated?(scope) && session && user
end
|
#scope ⇒ Object
35
36
37
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 35
def scope
scope = options[:scope]
end
|
#session ⇒ Object
39
40
41
|
# File 'lib/sso/warden/hooks/after_authentication.rb', line 39
def session
warden.session(scope)
end
|