I m 试图在instructions heret_t_t_t_t_t rel=
我知道,我可以使用消防基地verificationSessionCookie。 事实上,这是我目前所做的事,也是行之有效的。 英国护堤 s慢,无法在Vercel的边缘时间执行。 这一议题略高于我的头部,但在这里,我所尝试的是。 在很大程度上,这只是很多东西方和勘探,但我think。 我需要用<代码>createRemoteJWKSet建立一个遥远的钥匙,这是我可以走过的一步。Why?
export async function getDecodedSessionCookie() {
// Get the sessionCookie
const sessionCookie = cookies().get("sessionCookie")
if (sessionCookie === undefined) return null
// Verify the cookie but don t check if the cookie has
// been revoked not sure if this is a security risk,
// but it appears to add significant latency
return (
adminAuth
.verifySessionCookie(sessionCookie.value, false)
// If the cookie is verified, return the decodedClaims
.then((decodedClaims) => {
return decodedClaims
})
.catch((e) => console.log("error", e))
)
}
What I ve Tried
export async function getDecodedSessionCookie2() {
// Return null if the cookie doesn t exist or it s invalid
const sessionCookie = cookies().get("sessionCookie")
if (sessionCookie === undefined) return null
// Decode the header (this works)
const header = jose.decodeProtectedHeader(sessionCookie.value)
console.log("header", header)
// Decode the cookie (this works)
const sessionCookieDecoded = jose.decodeJwt(sessionCookie.value)
console.log("sessionCookieDecoded", sessionCookieDecoded)
// Create the remote key set
// (This errors with message: JSON Web Key Set malformed)
const JWKS = jose.createRemoteJWKSet(
new URL(
"https://www.googleapis.com/robot/v1/metadata/x509/[email protected]"
)
)
const keyset = await JWKS()
console.log("keyset", keyset)
// Never made it here
const audience = process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID
const issuer = `https://securetoken.google.com/${audience}`
// Never made it here
const { payload, protectedHeader } = await jose.jwtVerify(
sessionCookie.value,
JWKS,
{
issuer,
audience,
}
)
console.log("protectedHeader", protectedHeader)
console.log("payload", payload)
// Not sure if this is needed?
// const x509 = certificates["7cf7f8727091e4c77aa995db60743b7dd2bb70b5"]
// const ecPublicKey = await jose.importX509(x509, algorithm)
return sessionCookieDecoded
}
Additional notes
kid
in the header.
kid: lk02Aw
. As far as I can tell, this does not correspond to any of the public keyskid
does not exist.Updates
I am building a web application using NodeJS splitting the application into a back-end to handle database queries with MongoDB and a front end via a node based webserver that uses interactjs with ...