Fix api rate limit
This commit is contained in:
parent
3cac8a756f
commit
02596be702
3 changed files with 2 additions and 10 deletions
|
@ -96,10 +96,8 @@ describe('Test application behind a reverse proxy', function () {
|
||||||
it('Should rate limit logins', async function () {
|
it('Should rate limit logins', async function () {
|
||||||
const user = { username: 'root', password: 'fail' }
|
const user = { username: 'root', password: 'fail' }
|
||||||
|
|
||||||
for (let i = 0; i < 20; i++) {
|
for (let i = 0; i < 18; i++) {
|
||||||
try {
|
await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
||||||
await server.login.login({ user, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
|
|
||||||
} catch {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
|
await server.login.login({ user, expectedStatus: HttpStatusCode.TOO_MANY_REQUESTS_429 })
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { FileStorage, HttpStatusCode, UserExportRequest, UserExportRequestResult, UserExportState } from '@peertube/peertube-models'
|
import { FileStorage, HttpStatusCode, UserExportRequest, UserExportRequestResult, UserExportState } from '@peertube/peertube-models'
|
||||||
import {
|
import {
|
||||||
apiRateLimiter,
|
|
||||||
asyncMiddleware,
|
asyncMiddleware,
|
||||||
authenticate,
|
authenticate,
|
||||||
userExportDeleteValidator,
|
userExportDeleteValidator,
|
||||||
|
@ -16,8 +15,6 @@ import { CONFIG } from '@server/initializers/config.js'
|
||||||
|
|
||||||
const userExportsRouter = express.Router()
|
const userExportsRouter = express.Router()
|
||||||
|
|
||||||
userExportsRouter.use(apiRateLimiter)
|
|
||||||
|
|
||||||
userExportsRouter.post('/:userId/exports/request',
|
userExportsRouter.post('/:userId/exports/request',
|
||||||
authenticate,
|
authenticate,
|
||||||
asyncMiddleware(userExportRequestValidator),
|
asyncMiddleware(userExportRequestValidator),
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import {
|
import {
|
||||||
apiRateLimiter,
|
|
||||||
asyncMiddleware,
|
asyncMiddleware,
|
||||||
authenticate
|
authenticate
|
||||||
} from '../../../middlewares/index.js'
|
} from '../../../middlewares/index.js'
|
||||||
|
@ -20,8 +19,6 @@ import { saveInTransactionWithRetries } from '@server/helpers/database-utils.js'
|
||||||
|
|
||||||
const userImportRouter = express.Router()
|
const userImportRouter = express.Router()
|
||||||
|
|
||||||
userImportRouter.use(apiRateLimiter)
|
|
||||||
|
|
||||||
userImportRouter.post('/:userId/imports/import-resumable',
|
userImportRouter.post('/:userId/imports/import-resumable',
|
||||||
authenticate,
|
authenticate,
|
||||||
asyncMiddleware(userImportRequestResumableInitValidator),
|
asyncMiddleware(userImportRequestResumableInitValidator),
|
||||||
|
|
Loading…
Add table
Reference in a new issue