Skip to content

Commit 55db24a

Browse files
authored
Merge pull request #505 from mchangrh/tokenValidateRegex
add fast fails for local and gumroad license keys
2 parents 1c1496a + 551e103 commit 55db24a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/routes/verifyToken.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export async function verifyTokenRequest(req: VerifyTokenRequest, res: Response)
1818
if (!licenseKey) {
1919
return res.status(400).send("Invalid request");
2020
}
21+
const licenseRegex = new RegExp(/[a-zA-Z0-9]{40}|[A-Z0-9-]{35}/);
22+
if (!licenseRegex.test(licenseKey)) {
23+
return res.status(200).send({
24+
allowed: false
25+
});
26+
}
2127

2228
const tokens = (await privateDB.prepare("get", `SELECT "accessToken", "refreshToken", "expiresIn" from "oauthLicenseKeys" WHERE "licenseKey" = ?`
2329
, [licenseKey])) as {accessToken: string, refreshToken: string, expiresIn: number};

0 commit comments

Comments
 (0)