Class: ROM::Auth::System
- Inherits:
-
Object
- Object
- ROM::Auth::System
- Defined in:
- lib/rom/auth/system.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
Instance Method Summary collapse
-
#authenticate(credentials) ⇒ Object
def authenticators Authenticators::Authenticator.descendants.inject({}) do |acc, desc| acc.merge(desc.shorthand_symbol => desc) end end.
-
#initialize(config) ⇒ System
constructor
A new instance of System.
- #inspect ⇒ Object
- #logger ⇒ Object
- #migrate!(setup) ⇒ Object
Constructor Details
#initialize(config) ⇒ System
Returns a new instance of System.
7 8 9 10 11 12 |
# File 'lib/rom/auth/system.rb', line 7 def initialize(config) raise ArgumentError unless config.is_a?(Configuration) @configuration = config load_plugins! end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/rom/auth/system.rb', line 5 def configuration @configuration end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
5 6 7 |
# File 'lib/rom/auth/system.rb', line 5 def plugins @plugins end |
Instance Method Details
#authenticate(credentials) ⇒ Object
def authenticators
Authenticators::Authenticator.descendants.inject({}) do |acc, desc|
acc.merge(desc.shorthand_symbol => desc)
end
end
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/rom/auth/system.rb', line 26 def authenticate(credentials) raise ArgumentError unless credentials success = false now = Time.now user = identify_user(credentials) on_authentication_attempt(credentials) if user authenticated = run_authentication_check(credentials) if authenticated on_authentication_success(credentials) if (user, credentials) (credentials) success = true else (credentials) end else on_authentication_failure(credentials) end else on_identification_failure(credentials) end on_authentication_completed( identifier: credentials.identifier, user_id: (user[:id] if user), started_at: now, ended_at: Time.now, type: credentials.type, authenticated: authenticated, success: success ) user if success end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/rom/auth/system.rb', line 71 def inspect "#<ROM::Auth::AuthenticationSystem plugins: #{plugins.keys}>" end |
#logger ⇒ Object
67 68 69 |
# File 'lib/rom/auth/system.rb', line 67 def logger configuration.logger end |
#migrate!(setup) ⇒ Object
14 15 16 17 18 |
# File 'lib/rom/auth/system.rb', line 14 def migrate!(setup) plugins.each do |_type, plugin| plugin.migrate(setup) end end |