Skip to content

Commit

Permalink
Attempt to fix DoS issue oakserver/oak#500
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Jan 30, 2024
1 parent 0c601da commit e41d47c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/server/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import 'dotenv/load.ts';
import * as uuid from 'uuid/mod.ts';
import { Application, Context, CookiesSetDeleteOptions, Middleware, Router, Status, STATUS_TEXT } from 'oak/mod.ts';
import { ResponseBody, ResponseBodyFunction } from 'oak/response.ts';
import { Response, ResponseBody, ResponseBodyFunction } from 'oak/response.ts';
import Session from 'oak_sessions/src/Session.ts';
import CookieStore from 'oak_sessions/src/stores/CookieStore.ts';
import { oakCors } from 'cors/mod.ts';
Expand Down Expand Up @@ -89,6 +89,13 @@ const B2_ENABLED = Deno.env.get('B2_ENABLED')!.toLowerCase() === 'true';
const B2_BUCKET_ID = Deno.env.get('B2_BUCKET_ID')!;
const BOARD_INTEGRATION_START_DATE = '2023-08-25';

(() => {
const originalDestroy = Response.prototype.destroy;
Response.prototype.destroy = function () {
originalDestroy.bind(this)(true); // Always close resources
};
})();

const cookieOptions: CookiesSetDeleteOptions = {
expires: new Date(Date.now() + 86_400_000 * 30),
sameSite: 'lax',
Expand Down

0 comments on commit e41d47c

Please sign in to comment.