Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(docs): add cronjob to drop webauthn KV daily
- Loading branch information
Showing
4 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createClient } from "@vercel/kv" | ||
import { NextResponse, NextRequest } from "next/server" | ||
|
||
export async function GET(req: NextRequest) { | ||
// Check Authorization | ||
const authHeader = req.headers.get("authorization") | ||
if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) { | ||
return new NextResponse("Unauthorized", { | ||
status: 401, | ||
}) | ||
} | ||
|
||
// Get Vercel KV client | ||
const webAuthnKV = createClient({ | ||
url: process.env.KV_REST_API_URL!, | ||
token: process.env.KV_REST_API_TOKEN!, | ||
}) | ||
|
||
// Drop all WebAuthn authenticators | ||
await webAuthnKV.flushall() | ||
|
||
// Verify | ||
const allKeys = await webAuthnKV.keys("*") | ||
|
||
if (!allKeys.length) { | ||
return NextResponse.json({ ok: true }) | ||
} else { | ||
return new NextResponse("Flush Failed", { | ||
status: 500, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.