Class: SSO::Server::Warden::Hooks::AfterAuthentication
- Inherits:
-
Object
- Object
- SSO::Server::Warden::Hooks::AfterAuthentication
- Includes:
- Logging
- Defined in:
- lib/sso/server/warden/hooks/after_authentication.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#warden ⇒ Object
readonly
Returns the value of attribute warden.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user:, warden:, options:) ⇒ AfterAuthentication
constructor
A new instance of AfterAuthentication.
Methods included from Logging
#debug, #error, #fatal, #info, #logger, #progname, #warn
Constructor Details
#initialize(user:, warden:, options:) ⇒ AfterAuthentication
Returns a new instance of AfterAuthentication.
21 22 23 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 21 def initialize(user:, warden:, options:) @user, @warden, @options = user, warden, end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 8 def @options end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
8 9 10 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 8 def user @user end |
#warden ⇒ Object (readonly)
Returns the value of attribute warden.
8 9 10 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 8 def warden @warden end |
Class Method Details
.to_proc ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 10 def self.to_proc proc do |user, warden, | begin new(user: user, warden: warden, options: ).call rescue => exception ::SSO.config.exception_handler.call exception # The show must go on end end end |
Instance Method Details
#call ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sso/server/warden/hooks/after_authentication.rb', line 25 def call debug { 'Starting hook because this is considered the first login of the current session...' } request = warden.request session = warden.env['rack.session'] debug { "Generating a passport for user #{user.id.inspect} for the session with the SSO server..." } attributes = { owner_id: user.id, ip: request.ip, agent: request.user_agent } generation = SSO::Server::Passports.generate attributes if generation.success? debug { "Passport with ID #{generation.object.inspect} generated successfuly. Persisting it in session..." } session[:passport_id] = generation.object else fail generation.code.inspect + generation.object.inspect end debug { 'Finished.' } end |