Skip to content

Commit

Permalink
secure cron job
Browse files Browse the repository at this point in the history
  • Loading branch information
dohaki committed Sep 12, 2024
1 parent bbc2ea8 commit b997ae2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion api/cron-cache-balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import mainnetChains from "../src/data/chains_1.json";

const handler = async (
_: TypedVercelRequest<Record<string, never>>,
request: TypedVercelRequest<Record<string, never>>,
response: VercelResponse
) => {
const logger = getLogger();
Expand All @@ -21,6 +21,14 @@ const handler = async (
message: "Starting cron job...",
});
try {
const authHeader = (request.headers as any)?.get("authorization");
if (
!process.env.CRON_SECRET ||
authHeader !== `Bearer ${process.env.CRON_SECRET}`
) {
return response.status(401).json({ success: false });
}

const {
REACT_APP_FULL_RELAYERS, // These are relayers running a full auto-rebalancing strategy.
REACT_APP_TRANSFER_RESTRICTED_RELAYERS, // These are relayers whose funds stay put.
Expand Down

0 comments on commit b997ae2

Please sign in to comment.