Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
sharedlimit "git.sendico.io/tech/sxchnge/bff/edge/shared/interface/ratelimit"
|
||||
)
|
||||
|
||||
type VerificationRateLimitsConfig struct {
|
||||
PerDestination sharedlimit.WindowConfig `yaml:"per_destination"`
|
||||
PerIP sharedlimit.WindowConfig `yaml:"per_ip"`
|
||||
}
|
||||
|
||||
type VerificationRateLimits struct {
|
||||
PerDestination sharedlimit.Window
|
||||
PerIP sharedlimit.Window
|
||||
}
|
||||
|
||||
func DefaultVerificationRateLimits() VerificationRateLimits {
|
||||
return VerificationRateLimits{
|
||||
PerDestination: sharedlimit.Window{Limit: 5, Window: time.Hour},
|
||||
PerIP: sharedlimit.Window{Limit: 20, Window: time.Hour},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *VerificationConfig) ResolveRateLimits() (VerificationRateLimits, error) {
|
||||
if c == nil || c.RateLimits == nil {
|
||||
return DefaultVerificationRateLimits(), nil
|
||||
}
|
||||
destination, err := sharedlimit.ResolveWindow(c.RateLimits.PerDestination, "verification.rate_limits.per_destination")
|
||||
if err != nil {
|
||||
return VerificationRateLimits{}, err
|
||||
}
|
||||
ip, err := sharedlimit.ResolveWindow(c.RateLimits.PerIP, "verification.rate_limits.per_ip")
|
||||
if err != nil {
|
||||
return VerificationRateLimits{}, err
|
||||
}
|
||||
return VerificationRateLimits{PerDestination: destination, PerIP: ip}, nil
|
||||
}
|
||||
Reference in new issue
Block a user