normalize username before ratelimiting

This commit is contained in:
Thibault Duplessis 2018-05-06 21:42:58 +02:00
parent 043d00395f
commit 0f7b806d99

View file

@ -111,7 +111,7 @@ object PasswordHasher {
def rateLimit[A: Zero](username: String, req: RequestHeader)(run: RateLimit.Charge => Fu[A]): Fu[A] = {
val cost = 1
val ip = HTTPRequest lastRemoteAddress req
rateLimitPerUser(username, cost = cost) {
rateLimitPerUser(User normalize username, cost = cost) {
rateLimitPerIP.chargeable(ip, cost = cost) { charge =>
rateLimitPerUA(~HTTPRequest.userAgent(req), cost = cost, msg = ip.value) {
rateLimitGlobal("-", cost = cost, msg = ip.value) {