package
0.0.0-20250226171102-4db14ec44d68
Repository: https://github.com/cozy/cozy-stack.git
Documentation: pkg.go.dev

# Functions

GetMaximumLimit returns the limit of a CounterType.
IsLimitReachedOrExceeded return true if the limit has been reached or exceeded, false otherwise.
NewInMemory returns a in-memory counter.
NewRateLimiter instantiate a new [RateLimiter].
NewRedis returns a counter that can be mutualized between several cozy-stack processes by using redis.
SetMaximumLimit sets a new limit for a CounterType.

# Constants

AuthType is used for counting the number of login attempts.
ConfirmFlagshipType is used when the user is asked to manually certify that an OAuth client is the flagship app.
ExportType is used for creating an export of the data.
JobCleanClientType is used for cleaning unused OAuth clients.
JobClientType is used for the jobs associated to a @client trigger.
JobKonnectorType is used for counting the number of konnector executions.
JobNotesPersistType is used for saving notes to the VFS.
JobNotificationType is used for mobile notifications pushing.
JobSendMailType is used for mail sending.
JobServiceType is used for generic services Ex: categorization or matching for banking.
JobShareReplicateType is used for counting the number of replications.
JobShareTrackType is used for counting the number of updates of the io.cozy.shared database.
JobShareUploadType is used for counting the file uploads.
JobThumbnailType is used for counting the number of thumbnail jobs executed by an instance.
JobZipType is used for cozies exports.
MagicLinkType is used when sending emails with a magic link that can authenticate the user into a Cozy.
OAuthClientType is used for counting the number of OAuth clients.
ResendOnboardingMailType is used for resending the onboarding link by email.
SendHintByMail is used for sending the password hint by email.
SharingInviteType is used for counting the number of sharing invitations sent to a given instance.
SharingPublicLinkType is used for counting the number of public sharing link consultations.
TwoFactorGenerationType is used for counting the number of times a 2FA is generated.
TwoFactorType is used for counting the number of 2FA attempts.
WebhookTriggerType is used for calling a webhook trigger.

# Variables

ErrRateLimitExceeded is the error returned when the limit was already reached before the check.
ErrRateLimitReached is the error returned when we were under the limit before the check, and reach the limit.

# Structs

InMemory implementation ofr [Counter].
RateLimiter allow to rate limite the access to some resource.
Redis implementation of [Counter].

# Interfaces

Counter is an interface for counting number of attempts that can be used to rate limit the number of logins and 2FA tries, and thus block bruteforce attacks.

# Type aliases

CounterType os an enum for the type of counters used by rate-limiting.