From 75ab4de41fcd7036c33bcd4821ec684209356d9d Mon Sep 17 00:00:00 2001 From: Johann150 Date: Wed, 19 Jul 2023 09:43:17 +0200 Subject: [PATCH] server: limit caching time for public keys --- packages/backend/src/remote/activitypub/misc/auth-user.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/remote/activitypub/misc/auth-user.ts b/packages/backend/src/remote/activitypub/misc/auth-user.ts index 94c60ef00..13140031f 100644 --- a/packages/backend/src/remote/activitypub/misc/auth-user.ts +++ b/packages/backend/src/remote/activitypub/misc/auth-user.ts @@ -5,6 +5,7 @@ import { UserPublickey } from '@/models/entities/user-publickey.js'; import { uriPersonCache, userByIdCache } from '@/services/user-cache.js'; import { createPerson } from '@/remote/activitypub/models/person.js'; import { Resolver } from '@/remote/activitypub/resolver.js'; +import { HOUR } from '@/const.js'; export type AuthUser = { user: IRemoteUser; @@ -12,11 +13,11 @@ export type AuthUser = { }; const publicKeyCache = new Cache( - Infinity, + 2 * HOUR, (keyId) => UserPublickeys.findOneBy({ keyId }).then(x => x ?? undefined), ); const publicKeyByUserIdCache = new Cache( - Infinity, + 2 * HOUR, (userId) => UserPublickeys.findOneBy({ userId }).then(x => x ?? undefined), );