Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3249454
D5979.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D5979.diff
View Options
diff --git a/keyserver/src/cron/cron.js b/keyserver/src/cron/cron.js
--- a/keyserver/src/cron/cron.js
+++ b/keyserver/src/cron/cron.js
@@ -16,6 +16,7 @@
deleteOrphanedSessions,
deleteOldWebSessions,
} from '../deleters/session-deleters';
+import { deleteStaleSIWENonceEntries } from '../deleters/siwe-nonce-deleters.js';
import { deleteInaccessibleThreads } from '../deleters/thread-deleters';
import { deleteExpiredUpdates } from '../deleters/update-deleters';
import { deleteUnassignedUploads } from '../deleters/upload-deleters';
@@ -43,6 +44,7 @@
await deleteOldWebSessions();
await deleteExpiredUpdates();
await deleteUnassignedUploads();
+ await deleteStaleSIWENonceEntries();
} catch (e) {
console.warn('encountered error while trying to clean database', e);
}
diff --git a/keyserver/src/deleters/siwe-nonce-deleters.js b/keyserver/src/deleters/siwe-nonce-deleters.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/deleters/siwe-nonce-deleters.js
@@ -0,0 +1,17 @@
+// @flow
+
+import { dbQuery, SQL } from '../database/database';
+
+// 30 minutes = 30min * 60sec * 1000ms
+export const nonceLifetime = 30 * 60 * 1000;
+
+async function deleteStaleSIWENonceEntries(): Promise<void> {
+ const earliestValidCreationTime = Date.now() - nonceLifetime;
+ const query = SQL`
+ DELETE FROM siwe_nonces
+ WHERE creation_time < ${earliestValidCreationTime}
+ `;
+ await dbQuery(query);
+}
+
+export { deleteStaleSIWENonceEntries };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 2:50 PM (21 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2498098
Default Alt Text
D5979.diff (1 KB)
Attached To
Mode
D5979: [keyserver] Clean up stale (>30min old) SIWE nonces
Attached
Detach File
Event Timeline
Log In to Comment