Neon OAuth: Allow client_id and client_secret in headers
Some checks failed
Docker Build and Push / Docker Build and Push Server (push) Has been cancelled
Runs E2E API Tests / build (20.x) (push) Has been cancelled
Runs E2E API Tests / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (20.x) (push) Has been cancelled
Lint & build / lint_and_build (22.x) (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled

This commit is contained in:
Konstantin Wohlwend 2024-12-04 10:52:35 -08:00
parent 85260a97ff
commit 33d7d99070

View File

@ -1,6 +1,6 @@
import { prismaClient } from "@/prisma-client";
import { createSmartRouteHandler } from "@/route-handlers/smart-route-handler";
import { yupMixed, yupNumber, yupObject, yupString, yupUnion } from "@stackframe/stack-shared/dist/schema-fields";
import { yupMixed, yupNumber, yupObject, yupString, yupTuple, yupUnion } from "@stackframe/stack-shared/dist/schema-fields";
import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env";
import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors";
@ -14,10 +14,11 @@ export const POST = createSmartRouteHandler({
grant_type: yupString().oneOf(["authorization_code"]).defined(),
code: yupString().defined(),
code_verifier: yupString().defined(),
client_id: yupString().defined(),
client_secret: yupString().defined(),
redirect_uri: yupString().defined(),
}).defined(),
headers: yupObject({
authorization: yupTuple([yupString().defined()]).defined(),
}).defined(),
}),
response: yupUnion(
yupObject({
@ -41,6 +42,7 @@ export const POST = createSmartRouteHandler({
body: new URLSearchParams(req.body).toString(),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: req.headers.authorization[0],
},
});
if (!tokenResponse.ok) {