lato 3.23.0 → 3.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 926e453e02a52408f23980d6ed7e0e74c40de3f4e5841a911420ea1b3df25128
4
- data.tar.gz: 179a8b9e1959c8c734e92a17eec7c30e640da7f65df7b266e35f8f257d75094b
3
+ metadata.gz: 731f545c5ecf6168cae73f2ee10f5c2ba75cd81309e875797f7ea3a4e2e10511
4
+ data.tar.gz: 074c63ac0af5081662ee78b7ae54379208e8fc8e459ff4f4cb901d964f2bbf04
5
5
  SHA512:
6
- metadata.gz: ed3a9f66a07bac72a2bba82dcfb2db645574b0c26e5860bccb72f21da54a14fc273554935408226365bcbc3b17b64b559298c7e32c4a3a0eae815271c0086c37
7
- data.tar.gz: 02b9de09b5551dec982080c649f0e767faf3cb75c8c735fae962a30249095e3129ec7d2aa76cbdac8417931b1f1acea88f2a84691a492604aa81368610b9d5b8
6
+ metadata.gz: 99fd531e97c8bd89263351d4dbe953bcdb7e39dd6256219faca2e0e5dc480c64b0833b9f293fc71cb28de493bc262dce0bbd5474cf94dd9e44ffa2d6bd723a03
7
+ data.tar.gz: 68cf424eceb523273689aa3da4abb6d8096a3f4e0786efae77fe9e1b235a0ad7d31f0740a4acdfc92cd2ce4e3849405e1c7bca7897c83b37a7f7b9803a7d5ddd
@@ -240,6 +240,12 @@ module Lato
240
240
  return
241
241
  end
242
242
 
243
+ # Global cap checked before user lookup: the error is the same for every email, so it reveals nothing.
244
+ if recover_password_hourly_limit_reached?
245
+ errors.add(:base, :password_update_global_limit)
246
+ return
247
+ end
248
+
243
249
  user = Lato::User.find_by(email: email)
244
250
  return true unless user
245
251
 
@@ -252,6 +258,7 @@ module Lato
252
258
 
253
259
  # Async delivery keeps response time independent from email existence.
254
260
  Lato::UserMailer.password_update_mail(user.id, code).deliver_later
261
+ Rails.cache.increment(recover_password_hourly_cache_key, 1, expires_in: 1.hour)
255
262
 
256
263
  true
257
264
  end
@@ -451,6 +458,19 @@ module Lato
451
458
  # Cache
452
459
  ##
453
460
 
461
+ # Fixed hourly window shared by all users: stops mass mailing when an attacker knows many registered emails.
462
+ def recover_password_hourly_cache_key
463
+ "Lato::User/recover_password_hourly_count/#{Time.now.utc.strftime('%Y%m%d%H')}"
464
+ end
465
+
466
+ def recover_password_hourly_limit_reached?
467
+ limit = Lato.config.auth_recover_password_hourly_limit
468
+ return false if limit.nil?
469
+
470
+ # raw: true reads counters written by increment on stores that keep them unserialized (Redis, Memcache).
471
+ Rails.cache.read(recover_password_hourly_cache_key, raw: true).to_i >= limit
472
+ end
473
+
454
474
  def c_email_verification_semaphore(value = nil)
455
475
  cache_key = "Lato::User/c_email_verification_semaphore/#{id}"
456
476
  return Rails.cache.read(cache_key) if value.nil?
@@ -140,6 +140,7 @@ en:
140
140
  email_verification_code_invalid: Email verification code is invalid
141
141
  password_update_code_expired: Verification code has expired
142
142
  password_update_code_invalid: Verification code is invalid or expired
143
+ password_update_global_limit: Too many password recovery requests, please retry later
143
144
  credentials_not_correct: Email or password not correct
144
145
  privacy_policy_invalid: To accept the privacy policy you must select the confirmation checkbox
145
146
  terms_and_conditions_invalid: To accept the terms and conditions you must select the confirmation checkbox
@@ -147,6 +147,7 @@ fr:
147
147
  email_verification_code_invalid: Le code de vérification de l'e-mail n'est pas valide
148
148
  password_update_code_expired: Le code de vérification a expiré
149
149
  password_update_code_invalid: Le code de vérification n'est pas valide ou a expiré
150
+ password_update_global_limit: Trop de demandes de récupération de mot de passe, veuillez réessayer plus tard
150
151
  credentials_not_correct: E-mail ou mot de passe incorrect
151
152
  privacy_policy_invalid: Pour accepter la politique de confidentialité, vous devez cocher la case de confirmation
152
153
  terms_and_conditions_invalid: Pour accepter les conditions générales, vous devez cocher la case de confirmation
@@ -147,6 +147,7 @@ it:
147
147
  email_verification_code_invalid: Il codice di verifica email non risulta valido
148
148
  password_update_code_expired: Il codice di verifica risulta scaduto
149
149
  password_update_code_invalid: Il codice di verifica non risulta valido o è scaduto
150
+ password_update_global_limit: Troppe richieste di recupero password, riprova più tardi
150
151
  credentials_not_correct: Email o password non corretti
151
152
  privacy_policy_invalid: Per accettare la privacy policy devi selezionare la checkbox di conferma
152
153
  terms_and_conditions_invalid: Per accettare i termini e condizioni devi selezionare la checkbox di conferma
@@ -147,6 +147,7 @@ ro:
147
147
  email_verification_code_invalid: Codul de verificare email nu este valid
148
148
  password_update_code_expired: Codul de verificare a expirat
149
149
  password_update_code_invalid: Codul de verificare nu este valid sau a expirat
150
+ password_update_global_limit: Prea multe cereri de recuperare a parolei, încearcă din nou mai târziu
150
151
  credentials_not_correct: Email sau parolă incorectă
151
152
  privacy_policy_invalid: Pentru a accepta politica de confidențialitate trebuie să bifezi căsuța de confirmare
152
153
  terms_and_conditions_invalid: Pentru a accepta termenii și condițiile trebuie să bifezi căsuța de confirmare
data/lib/lato/config.rb CHANGED
@@ -12,6 +12,9 @@ module Lato
12
12
  # Authentication configs
13
13
  attr_accessor :auth_disable_signup, :auth_disable_recover_password, :auth_disable_web3, :auth_disable_authenticator, :auth_disable_webauthn, :auth_disable_signin_success_mail
14
14
 
15
+ # Max password recovery emails sent per hour across all users (nil disables the cap)
16
+ attr_accessor :auth_recover_password_hourly_limit
17
+
15
18
  # Hcaptcha configs
16
19
  attr_accessor :hcaptcha_site_key, :hcaptcha_secret
17
20
 
@@ -49,6 +52,7 @@ module Lato
49
52
  @auth_disable_authenticator = false
50
53
  @auth_disable_webauthn = false
51
54
  @auth_disable_signin_success_mail = false
55
+ @auth_recover_password_hourly_limit = 100
52
56
 
53
57
  @hcaptcha_site_key = nil
54
58
  @hcaptcha_secret = nil
data/lib/lato/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lato
2
- VERSION = "3.23.0"
2
+ VERSION = "3.23.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.23.0
4
+ version: 3.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante