🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

symblight-fastify-oauth2-jwt

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

symblight-fastify-oauth2-jwt

### Requirements

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

Getting started

Requirements

This package supports the following tooling versions:

  • Node.js: ^12.19.0 || ^14.15.0 || ^16.13.0 || ^18.12.0

Installation

Using npm in your project directory run the following command:

npm install symblight-fastify-oauth2-jwt

Getting started

Environment Variables

ISSUER_BASE_URL=https://YOUR_ISSUER_DOMAIN
AUDIENCE=https://my-api.com
const { fastifyOauth2 } = require("symblight-fastify-oauth2-jwt");
app.register(fastifyOauth2, {
  audience: "",
  issuerBaseURL: ``,
  jwksUri: "",
  algorithms: ["RS256"],
});
const checkJwt = async (req, reply) => {
  const jwt = app.Oauth2.getToken(
    req.headers,
    req.query,
    req.body,
    !!reply.header("Content-type", "urlencoded")
  );
  return await app.Oauth2.verifyJwt(jwt);
};

app.get("/", async function (request, reply) {
  request.auth = await checkJwt(request, reply);
  return reply
    .status(200)
    .header("Content-Type", "application/json; charset=utf-8")
    .send(request.auth?.payload);
});

FAQs

Package last updated on 13 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts