Repository navigation
Conversation
|
| try { | ||
| TokenGenerator tokenGenerator = tokenGeneratorFactory.createGenerator(scheme); | ||
| return tokenGenerator.generate(token); | ||
| } catch (AuthenticationException | ResponseStatusException e) { | ||
| failedAuthRateLimiter.recordFailedAttempt(ip, username); | ||
| throw e; | ||
| } | ||
| } |
There was a problem hiding this comment.
so here we return a auth token and in case of an error - go into the catch. The catch then internally calls failedAuthRateLimiter.recordFailedAttempt and following the methods in it, it uses the consumeToken method which can throw a OperationLimitExceeded exception and if that happens, we would directly exit the catch and the final line "throw e" - will not be reached at all. THis way we lose the original exception and just get a simple rate limit one. Maybe try to come up with a way to preserve the whole original exception or at least its message or code etc.
| private static final Duration REFILL_PERIOD = Duration.ofHours(1); | ||
| private static final long TOKENS_PER_ATTEMPT = 1; |
There was a problem hiding this comment.
maybe extract these constants so both AnonymousrateLimiter and the FailedAuthRateLimiter can share them.
| * {@link OperationRateLimitExceededException} is raised. Throttling is a no-op unless explicitly enabled. | ||
| */ | ||
| @Named | ||
| public class FailedAuthRateLimiter { |
There was a problem hiding this comment.
Right now the OperationRateLimiter and AnonymousRateLimiter and FailedAuthRateLimiter all use the same table to store their entries the operation_rate_limit_bucket table - how is the table cleaned since the CleanUpJob goes through the list of cleaners and the OperationRateLimitBucketCleaner does not implement the Cleaner interface.
I see that it is now set to go every hour, but at the begining we have a guard for the OPERATION_RATE_LIMITING_ENABLED boolean and it is by default set to false and if it is false for the deploy-service, then this cleaner does not execute at all.
Maybe add checks for this particular cleaner to be started if we have FAILED_AUTH_RATE_LIMITING_ENABLED enabled and also it is not part of your code change but I think It would be better to make the cleaner go with all the other cleaners executed by the clean up job - by making it implement the Cleaner interface as well.


No description provided.