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.1.1
"1.1.1"
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.
-
.transform_params(params) ⇒ Hash
performs transformations on params for signing up and signing in.
-
.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
46 47 48 |
# File 'lib/monban.rb', line 46 def self.compare_token(digest, token) config.token_comparison.call(digest, token) end |
.configure {|configuration| ... } ⇒ Object
Configures monban
114 115 116 117 |
# File 'lib/monban.rb', line 114 def self.configure(&block) self.config ||= Monban::Configuration.new yield self.config end |
.hash_token(token) ⇒ String
hashes a token
55 56 57 |
# File 'lib/monban.rb', line 55 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 38 |
# File 'lib/monban.rb', line 34 def self.initialize warden_config warn "[DEPRECATION] Monban has been renamed to oath, please update your Gemfile" setup_config setup_warden_config(warden_config) end |
.lookup(params, field_map) ⇒ User?
finds a user based on their credentials
88 89 90 91 92 93 |
# File 'lib/monban.rb', line 88 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
97 98 99 100 101 102 103 104 |
# File 'lib/monban.rb', line 97 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.
121 122 123 |
# File 'lib/monban.rb', line 121 def self.test_reset! Warden.test_reset! end |
.transform_params(params) ⇒ Hash
performs transformations on params for signing up and signing in
66 67 68 |
# File 'lib/monban.rb', line 66 def self.transform_params(params) ParamTransformer.new(params, config.param_transformations).to_h end |
.user_class ⇒ Class
Use Monban.config.user_class instead
the user class
75 76 77 78 79 |
# File 'lib/monban.rb', line 75 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 |