authlogic-nicho 6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/lib/authlogic/acts_as_authentic/base.rb +116 -0
  3. data/lib/authlogic/acts_as_authentic/email.rb +30 -0
  4. data/lib/authlogic/acts_as_authentic/logged_in_status.rb +85 -0
  5. data/lib/authlogic/acts_as_authentic/login.rb +63 -0
  6. data/lib/authlogic/acts_as_authentic/magic_columns.rb +38 -0
  7. data/lib/authlogic/acts_as_authentic/password.rb +357 -0
  8. data/lib/authlogic/acts_as_authentic/perishable_token.rb +122 -0
  9. data/lib/authlogic/acts_as_authentic/persistence_token.rb +70 -0
  10. data/lib/authlogic/acts_as_authentic/queries/case_sensitivity.rb +53 -0
  11. data/lib/authlogic/acts_as_authentic/queries/find_with_case.rb +83 -0
  12. data/lib/authlogic/acts_as_authentic/session_maintenance.rb +186 -0
  13. data/lib/authlogic/acts_as_authentic/single_access_token.rb +83 -0
  14. data/lib/authlogic/config.rb +43 -0
  15. data/lib/authlogic/controller_adapters/abstract_adapter.rb +119 -0
  16. data/lib/authlogic/controller_adapters/rack_adapter.rb +72 -0
  17. data/lib/authlogic/controller_adapters/rails_adapter.rb +47 -0
  18. data/lib/authlogic/controller_adapters/sinatra_adapter.rb +67 -0
  19. data/lib/authlogic/cookie_credentials.rb +63 -0
  20. data/lib/authlogic/crypto_providers/bcrypt.rb +113 -0
  21. data/lib/authlogic/crypto_providers/md5/v2.rb +35 -0
  22. data/lib/authlogic/crypto_providers/md5.rb +36 -0
  23. data/lib/authlogic/crypto_providers/scrypt.rb +92 -0
  24. data/lib/authlogic/crypto_providers/sha1/v2.rb +41 -0
  25. data/lib/authlogic/crypto_providers/sha1.rb +42 -0
  26. data/lib/authlogic/crypto_providers/sha256/v2.rb +58 -0
  27. data/lib/authlogic/crypto_providers/sha256.rb +59 -0
  28. data/lib/authlogic/crypto_providers/sha512/v2.rb +39 -0
  29. data/lib/authlogic/crypto_providers/sha512.rb +38 -0
  30. data/lib/authlogic/crypto_providers.rb +87 -0
  31. data/lib/authlogic/errors.rb +50 -0
  32. data/lib/authlogic/i18n/translator.rb +18 -0
  33. data/lib/authlogic/i18n.rb +100 -0
  34. data/lib/authlogic/random.rb +18 -0
  35. data/lib/authlogic/session/base.rb +2207 -0
  36. data/lib/authlogic/session/magic_column/assigns_last_request_at.rb +46 -0
  37. data/lib/authlogic/test_case/mock_api_controller.rb +52 -0
  38. data/lib/authlogic/test_case/mock_controller.rb +58 -0
  39. data/lib/authlogic/test_case/mock_cookie_jar.rb +109 -0
  40. data/lib/authlogic/test_case/mock_logger.rb +12 -0
  41. data/lib/authlogic/test_case/mock_request.rb +35 -0
  42. data/lib/authlogic/test_case/rails_request_adapter.rb +39 -0
  43. data/lib/authlogic/test_case.rb +215 -0
  44. data/lib/authlogic/version.rb +22 -0
  45. data/lib/authlogic.rb +44 -0
  46. metadata +382 -0
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Authlogic
4
+ module I18n
5
+ # The default translator used by authlogic/i18n.rb
6
+ class Translator
7
+ # If the I18n gem is present, calls +I18n.translate+ passing all
8
+ # arguments, else returns +options[:default]+.
9
+ def translate(key, options = {})
10
+ if defined?(::I18n)
11
+ ::I18n.translate key, **options
12
+ else
13
+ options[:default]
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "authlogic/i18n/translator"
4
+
5
+ module Authlogic
6
+ # This class allows any message in Authlogic to use internationalization. In
7
+ # earlier versions of Authlogic each message was translated via configuration.
8
+ # This cluttered up the configuration and cluttered up Authlogic. So all
9
+ # translation has been extracted out into this class. Now all messages pass
10
+ # through this class, making it much easier to implement in I18n library /
11
+ # plugin you want. Use this as a layer that sits between Authlogic and
12
+ # whatever I18n library you want to use.
13
+ #
14
+ # By default this uses the rails I18n library, if it exists. If it doesn't
15
+ # exist it just returns the default English message. The Authlogic I18n class
16
+ # works EXACTLY like the rails I18n class. This is because the arguments are
17
+ # delegated to this class.
18
+ #
19
+ # Here is how all messages are translated internally with Authlogic:
20
+ #
21
+ # Authlogic::I18n.t('error_messages.password_invalid', :default => "is invalid")
22
+ #
23
+ # If you use a different I18n library just replace the build-in
24
+ # I18n::Translator class with your own. For example:
25
+ #
26
+ # class MyAuthlogicI18nTranslator
27
+ # def translate(key, options = {})
28
+ # # you will have key which will be something like:
29
+ # # "error_messages.password_invalid"
30
+ # # you will also have options[:default], which will be the default
31
+ # # English version of the message
32
+ # # do whatever you want here with the arguments passed to you.
33
+ # end
34
+ # end
35
+ #
36
+ # Authlogic::I18n.translator = MyAuthlogicI18nTranslator.new
37
+ #
38
+ # That it's! Here is a complete list of the keys that are passed. Just define
39
+ # these however you wish:
40
+ #
41
+ # authlogic:
42
+ # error_messages:
43
+ # login_blank: can not be blank
44
+ # login_not_found: is not valid
45
+ # login_invalid: should use only letters, numbers, spaces, and .-_@+ please.
46
+ # consecutive_failed_logins_limit_exceeded: >
47
+ # Consecutive failed logins limit exceeded, account is disabled.
48
+ # email_invalid: should look like an email address.
49
+ # email_invalid_international: should look like an international email address.
50
+ # password_blank: can not be blank
51
+ # password_invalid: is not valid
52
+ # not_active: Your account is not active
53
+ # not_confirmed: Your account is not confirmed
54
+ # not_approved: Your account is not approved
55
+ # no_authentication_details: You did not provide any details for authentication.
56
+ # general_credentials_error: Login/Password combination is not valid
57
+ # session_invalid: Your session is invalid and has the following errors:
58
+ # models:
59
+ # user_session: UserSession (or whatever name you are using)
60
+ # attributes:
61
+ # user_session: (or whatever name you are using)
62
+ # login: login
63
+ # email: email
64
+ # password: password
65
+ # remember_me: remember me
66
+ module I18n
67
+ @@scope = :authlogic
68
+ @@translator = nil
69
+
70
+ class << self
71
+ # Returns the current scope. Defaults to :authlogic
72
+ def scope
73
+ @@scope
74
+ end
75
+
76
+ # Sets the current scope. Used to set a custom scope.
77
+ def scope=(scope)
78
+ @@scope = scope
79
+ end
80
+
81
+ # Returns the current translator. Defaults to +Translator+.
82
+ def translator
83
+ @@translator ||= Translator.new
84
+ end
85
+
86
+ # Sets the current translator. Used to set a custom translator.
87
+ def translator=(translator)
88
+ @@translator = translator
89
+ end
90
+
91
+ # All message translation is passed to this method. The first argument is
92
+ # the key for the message. The second is options, see the rails I18n
93
+ # library for a list of options used.
94
+ def translate(key, options = {})
95
+ translator.translate key, { scope: I18n.scope }.merge(options)
96
+ end
97
+ alias t translate
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "securerandom"
4
+
5
+ module Authlogic
6
+ # Generates random strings using ruby's SecureRandom library.
7
+ module Random
8
+ def self.hex_token
9
+ SecureRandom.hex(64)
10
+ end
11
+
12
+ # Returns a string in base64url format as defined by RFC-3548 and RFC-4648.
13
+ # We call this a "friendly" token because it is short and safe for URLs.
14
+ def self.friendly_token
15
+ SecureRandom.urlsafe_base64(15)
16
+ end
17
+ end
18
+ end