Module: Oath
- Defined in:
- lib/oath.rb,
lib/oath/railtie.rb,
lib/oath/version.rb,
lib/oath/back_door.rb,
lib/oath/field_map.rb,
lib/oath/failure_app.rb,
lib/oath/test/helpers.rb,
lib/oath/warden_setup.rb,
lib/oath/configuration.rb,
lib/oath/services/sign_in.rb,
lib/oath/services/sign_up.rb,
lib/oath/param_transformer.rb,
lib/oath/services/sign_out.rb,
lib/oath/controller_helpers.rb,
lib/oath/constraints/signed_in.rb,
lib/oath/constraints/signed_out.rb,
lib/oath/services/authentication.rb,
lib/oath/services/password_reset.rb,
lib/oath/test/controller_helpers.rb,
lib/oath/strategies/password_strategy.rb
Overview
Oath is an authentication toolkit designed to allow developers to create their own authentication solutions. If you’re interested in a default implementation try Oath Generators
Defined Under Namespace
Modules: Constraints, ControllerHelpers, Services, Strategies, Test Classes: BackDoor, Configuration, FailureApp, FieldMap, ParamTransformer, Railtie, WardenSetup
Constant Summary collapse
- VERSION =
1.1.0
"1.1.0"
Class Method Summary collapse
-
.compare_token(digest, token) ⇒ Boolean
compares the token (undigested password) to a digested password.
-
.configure {|configuration| ... } ⇒ Object
Configures oath.
-
.hash_token(token) ⇒ String
hashes a token.
-
.initialize(warden_config) ⇒ Object
initialize Oath.
-
.lookup(params, field_map) ⇒ User?
finds a user based on their credentials.
-
.test_mode! ⇒ Object
Puts oath into test mode.
-
.test_reset! ⇒ Object
Resets oath in between tests.
-
.transform_params(params) ⇒ Hash
performs transformations on params for signing up and signing in.
-
.user_class ⇒ Class
deprecated
Deprecated.
Use Oath.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/oath.rb', line 45 def self.compare_token(digest, token) config.token_comparison.call(digest, token) end |
.configure {|configuration| ... } ⇒ Object
Configures oath
112 113 114 115 |
# File 'lib/oath.rb', line 112 def self.configure(&block) self.config ||= Oath::Configuration.new yield self.config end |
.hash_token(token) ⇒ String
hashes a token
54 55 56 |
# File 'lib/oath.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 Oath
initialize Oath. Sets up warden and the default configuration.
34 35 36 37 |
# File 'lib/oath.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
86 87 88 89 90 91 |
# File 'lib/oath.rb', line 86 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 oath in your tests
Puts oath into test mode. This will disable hashing passwords
95 96 97 98 99 100 101 102 |
# File 'lib/oath.rb', line 95 def self.test_mode! Warden.test_mode! self.config ||= Oath::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 oath in between tests.
119 120 121 |
# File 'lib/oath.rb', line 119 def self.test_reset! Warden.test_reset! end |
.transform_params(params) ⇒ Hash
performs transformations on params for signing up and signing in
64 65 66 |
# File 'lib/oath.rb', line 64 def self.transform_params(params) ParamTransformer.new(params, config.param_transformations).to_h end |
.user_class ⇒ Class
Use Oath.config.user_class instead
the user class
73 74 75 76 77 |
# File 'lib/oath.rb', line 73 def self.user_class warn "#{Kernel.caller.first}: [DEPRECATION] " + 'Accessing the user class through the Oath module is deprecated. Use Oath.config.user_class instead.' config.user_class end |