assert uid for each request

This commit is contained in:
Sha Zhou
2025-05-09 18:42:35 +08:00
parent 5674402bb1
commit 6f41539587

View File

@@ -86,10 +86,10 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
[RPC_CALL_ENVIRONMENT]: { req, res } [RPC_CALL_ENVIRONMENT]: { req, res }
}); });
const uid = await authDto.solveUID(); const uid = await authDto.assertUID();
if (!uid && !ctx.ip) { // if (!uid && !ctx.ip) {
throw new OperationNotAllowedError(`Missing IP information for anonymous user`); // throw new OperationNotAllowedError(`Missing IP information for anonymous user`);
} // }
let rateLimitPolicy let rateLimitPolicy
if (uid) { if (uid) {
const user = await authDto.assertUser(); const user = await authDto.assertUser();
@@ -110,7 +110,7 @@ export const jinaAiMiddleware = (req: Request, res: Response, next: NextFunction
} else { } else {
rateLimitPolicy = [ rateLimitPolicy = [
RateLimitDesc.from({ RateLimitDesc.from({
occurrence: 1, occurrence: 0,
periodSeconds: 120 periodSeconds: 120
}) })
] ]