mirror of
https://github.com/betagouv/mon-entreprise
synced 2025-03-11 06:25:05 +00:00
Improve privacy with hash of the body
This commit is contained in:
parent
23bebf94d4
commit
c61144abfc
1 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import { createHash } from 'crypto'
|
||||
|
||||
import Router from '@koa/router'
|
||||
import IORedis from 'ioredis'
|
||||
import IORedisMock from 'ioredis-mock'
|
||||
|
@ -27,7 +29,10 @@ export const redisCacheMiddleware = () => {
|
|||
return
|
||||
}
|
||||
|
||||
const cacheKey = JSON.stringify(ctx.request.body)
|
||||
const cacheKey = createHash('sha1')
|
||||
.update(JSON.stringify(ctx.request.body))
|
||||
.digest('base64')
|
||||
|
||||
const cachedResponse = await redis.get(cacheKey)
|
||||
if (cachedResponse) {
|
||||
ctx.body = JSON.parse(cachedResponse) as unknown
|
||||
|
|
Loading…
Add table
Reference in a new issue