mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 06:42:32 -05:00
add ratelimit
This commit is contained in:
1 parent
a8433e9bd3
commit
218c22da21
2 files changed
+7
-2
No files matched your search
@@ -10,6 +10,8 @@ class SubmitFormEmail2fasController < ApplicationController
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
RateLimit.call("verify-2fa-code-#{@submitter.id}", limit: 2, ttl: 45.seconds, enabled: true)
|
RateLimit.call("verify-2fa-code-#{@submitter.id}", limit: 2, ttl: 45.seconds, enabled: true)
|
||||||
|
RateLimit.call("verify-2fa-code-1h-#{@submitter.id}", limit: 10, ttl: 1.hour, enabled: true)
|
||||||
|
RateLimit.call("verify-2fa-code-1d-#{@submitter.id}", limit: 20, ttl: 1.day, enabled: true)
|
||||||
|
|
||||||
value = [@submitter.email.downcase.strip, @submitter.slug].join(':')
|
value = [@submitter.email.downcase.strip, @submitter.slug].join(':')
|
||||||
|
|
||||||
|
|||||||
+5
-2
@@ -277,8 +277,11 @@ module Submitters
|
|||||||
def verify_link_otp!(otp, submitter)
|
def verify_link_otp!(otp, submitter)
|
||||||
return false if otp.blank?
|
return false if otp.blank?
|
||||||
|
|
||||||
RateLimit.call("verify-2fa-code-#{Digest::MD5.base64digest(submitter.email.downcase.squish)}",
|
email_digest = Digest::MD5.base64digest(submitter.email.downcase.squish)
|
||||||
limit: 2, ttl: 45.seconds, enabled: true)
|
|
||||||
|
RateLimit.call("verify-2fa-code-#{email_digest}", limit: 2, ttl: 45.seconds, enabled: true)
|
||||||
|
RateLimit.call("verify-2fa-code-1h-#{email_digest}", limit: 10, ttl: 1.hour, enabled: true)
|
||||||
|
RateLimit.call("verify-2fa-code-1d-#{email_digest}", limit: 20, ttl: 1.day, enabled: true)
|
||||||
|
|
||||||
link_2fa_key = [submitter.email.downcase.squish, submitter.submission.template.slug].join(':')
|
link_2fa_key = [submitter.email.downcase.squish, submitter.submission.template.slug].join(':')
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user