88
99// Use [NewServer].
1010type ServerStruct struct {
11- mainStorage MainStorageInterface
12- cache CacheInterface
11+ storage StorageInterface
1312
1413 userStore UserStoreInterface
1514
@@ -30,18 +29,14 @@ type ServerStruct struct {
3029
3130// All interfaces must be defined and cannot be nil.
3231//
33- // Storage entry keys are not globally-scoped. Different entries in mainStorage, cache, and rateLimitStorage may share the same key.
34- //
3532// maxConcurrentPasswordHashingProcesses defines the maximum number of concurrent processes for user password and temporary password hashing.
3633//
3734// emailAddressChecker is used for checking email addresses for signup and new email addresses of user email address updates.
3835// It is not used in for sign ins or user password resets.
3936//
4037// InactivityTimeout and ActivityCheckInterval should be a non-zero value in sessionConfig.
4138func NewServer (
42- mainStorage MainStorageInterface ,
43- cache CacheInterface ,
44- rateLimitStorage RateLimitStorageInterface ,
39+ storage StorageInterface ,
4540 userStore UserStoreInterface ,
4641 errorLogger ActionErrorLoggerInterface ,
4742 userPasswordHashAlgorithms []PasswordHashAlgorithmInterface ,
@@ -52,14 +47,13 @@ func NewServer(
5247 emailSender EmailSenderInterface ,
5348 sessionConfig SessionConfigStruct ,
5449) * ServerStruct {
55- verifyUserPasswordRateLimit := newTokenBucketRateLimit (rateLimitStorage , rateLimitStorageKeyPrefixVerifyUserPasswordRateLimit , clock , 5 , time .Minute )
56- sendEmailRateLimit := newTokenBucketRateLimit (rateLimitStorage , rateLimitStorageKeyPrefixSendEmailRateLimit , clock , 5 , 30 * time .Minute )
57- verifyEmailAddressVerificationCodeEmailAddressRateLimit := newTokenBucketRateLimit (rateLimitStorage , rateLimitStorageKeyPrefixVerifyEmailAddressVerificationCodeEmailAddressRateLimit , clock , 5 , time .Minute )
58- verifyUserPasswordResetTemporaryPasswordUserRateLimit := newTokenBucketRateLimit (rateLimitStorage , rateLimitStorageKeyPrefixVerifyUserPasswordResetTemporaryPasswordUserRateLimit , clock , 5 , time .Minute )
50+ verifyUserPasswordRateLimit := newTokenBucketRateLimit (storage , storageKeyPrefixVerifyUserPasswordTokenBucket , clock , 5 , time .Minute )
51+ sendEmailRateLimit := newTokenBucketRateLimit (storage , storageKeyPrefixSendEmailTokenBucket , clock , 5 , 30 * time .Minute )
52+ verifyEmailAddressVerificationCodeEmailAddressRateLimit := newTokenBucketRateLimit (storage , storageKeyPrefixVerifyEmailAddressVerificationCodeEmailAddressTokenBucket , clock , 5 , time .Minute )
53+ verifyUserPasswordResetTemporaryPasswordUserRateLimit := newTokenBucketRateLimit (storage , storageKeyPrefixVerifyUserPasswordResetTemporaryPasswordUserTokenBucket , clock , 5 , time .Minute )
5954
6055 action := & ServerStruct {
61- mainStorage : mainStorage ,
62- cache : cache ,
56+ storage : storage ,
6357 userStore : userStore ,
6458 errorLogger : errorLogger ,
6559 userPasswordHashAlgorithms : userPasswordHashAlgorithms ,
0 commit comments