@bren2010/cf-access-jwt
v1.0.0
Published
Tiny lib for verifying Cloudflare Access JWTs.
Downloads
25
Maintainers
Readme
cf-access-jwt
Tiny lib for decoding Cloudflare Access JWTs and verifying signatures, using native crypto APIs.
Currently supports alg:'RS256'
only.
const jwt = request.headers.get('Cf-Access-Jwt-Assertion');
const result = await parseJwt(jwt, issuer, audience);
if (!result.valid) {
console.log(result.reason); // Invalid issuer/audience, expired, etc
} else {
console.log(result.payload); // { iss, sub, aud, iat, exp, ...claims }
}
Code shamelessly stolen from: https://github.com/cfworker/cfworker/