Module: Monban
- Defined in:
- lib/monban.rb,
lib/monban/railtie.rb,
lib/monban/version.rb,
lib/monban/back_door.rb,
lib/monban/field_map.rb,
lib/monban/failure_app.rb,
lib/monban/test/helpers.rb,
lib/monban/warden_setup.rb,
lib/monban/configuration.rb,
lib/monban/services/sign_in.rb,
lib/monban/services/sign_up.rb,
lib/monban/param_transformer.rb,
lib/monban/services/sign_out.rb,
lib/monban/controller_helpers.rb,
lib/monban/constraints/signed_in.rb,
lib/monban/constraints/signed_out.rb,
lib/monban/services/authentication.rb,
lib/monban/services/password_reset.rb,
lib/monban/test/controller_helpers.rb,
lib/monban/strategies/password_strategy.rb
Overview
Monban is an authentication toolkit designed to allow developers to create their own authentication solutions. If you’re interested in a default implementation try Monban Generators
Defined Under Namespace
Modules: Constraints, ControllerHelpers, Services, Strategies, Test Classes: BackDoor, Configuration, FailureApp, FieldMap, ParamTransformer, Railtie, WardenSetup
Constant Summary collapse
- VERSION =
1.0.0
"1.0.0"
Class Method Summary collapse
-
.compare_token(digest, token) ⇒ Boolean
compares the token (undigested password) to a digested password.
-
.configure {|configuration| ... } ⇒ Object
Configures monban.
-
.hash_token(token) ⇒ String
hashes a token.
-
.initialize(warden_config) ⇒ Object
initialize Monban.
-
.lookup(params, field_map) ⇒ User?
finds a user based on their credentials.
-
.test_mode! ⇒ Object
Puts monban into test mode.
-
.test_reset! ⇒ Object
Resets monban in between tests.
-
.user_class ⇒ Class
deprecated
Deprecated.
Use Monban.config.user_class instead
Class Method Details
.compare_token(digest, token) ⇒ Boolean
compares the token (undigested password) to a digested password
45 46 47 |
# File 'lib/monban.rb', line 45 def self.compare_token(digest, token) config.token_comparison.call(digest, token) end |
.configure {|configuration| ... } ⇒ Object
Configures monban
102 103 104 105 |
# File 'lib/monban.rb', line 102 def self.configure(&block) self.config ||= Monban::Configuration.new yield self.config end |
.hash_token(token) ⇒ String
hashes a token
54 55 56 |
# File 'lib/monban.rb', line 54 def self.hash_token(token) config.hashing_method.call(token) end |
.initialize(warden_config) ⇒ Object
This is used in Railtie in order to bootstrap Monban
initialize Monban. Sets up warden and the default configuration.
34 35 36 37 |
# File 'lib/monban.rb', line 34 def self.initialize warden_config setup_config setup_warden_config(warden_config) end |
.lookup(params, field_map) ⇒ User?
finds a user based on their credentials
76 77 78 79 80 81 |
# File 'lib/monban.rb', line 76 def self.lookup(params, field_map) if params.present? fields = FieldMap.new(params, field_map).to_fields self.config.find_method.call(fields) end end |
.test_mode! ⇒ Object
You must call this if you want to use monban in your tests
Puts monban into test mode. This will disable hashing passwords
85 86 87 88 89 90 91 92 |
# File 'lib/monban.rb', line 85 def self.test_mode! Warden.test_mode! self.config ||= Monban::Configuration.new config.hashing_method = ->(password) { password } config.token_comparison = ->(digest, undigested_password) do digest == undigested_password end end |
.test_reset! ⇒ Object
You must call this between tests
Resets monban in between tests.
109 110 111 |
# File 'lib/monban.rb', line 109 def self.test_reset! Warden.test_reset! end |
.user_class ⇒ Class
Use Monban.config.user_class instead
the user class
63 64 65 66 67 |
# File 'lib/monban.rb', line 63 def self.user_class warn "#{Kernel.caller.first}: [DEPRECATION] " + 'Accessing the user class through the Monban module is deprecated. Use Monban.config.user_class instead.' config.user_class end |