-
-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Looks like you have to do a little parsing to get hold of the contents of the authentication token.
const authHeader = Array.isArray(ctx.req.headers["authorization"])
? ctx.req.headers["authorization"][0]
: ctx.req.headers["authorization"];
const accessToken: string | undefined = authHeader?.split(" ")[1];
const decoded = decoder.decode(accessToken);
const audience = decoded!["......"]; // claim
Suggestion to improve this in the SDKs by exposing the auth header tokens a little more cleanly.
If you've got your middleware in the same file as your handler, it can be a little messy with the imports as well since we have a naming conflict with jwt.
import { api, jwt } from "@nitric/sdk";
import { jwt as decoder } from "jsonwebtoken";
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request