Bypass JWT signature verification in Nestjs with passport-jwt

I am faced with a challenge where I need to access a user's secret stored in Redis by parsing the token body. Is there a more elegant solution available without having to write an entire new strategy from scratch? I am using nestjs for my architecture.

export class JwtStrategy ext...

Answer №1

After conducting further investigation, I stumbled upon this solution

      secretOrKeyProvider(request: any, rawJwtToken: string, done: any) {
        const [, body] = rawJwtToken.split('.');

        const bodyJSON = JSON.parse(btoa(body)) as UserType;

        const { sub } = bodyJSON;

        authService
          .findUserSecret(sub)
          .then(secret => secret || Promise.reject())
          .then(secret => done(null, secret))
          .catch(error => done(error, null));
      },

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Updating a database with a loop of React Material UI toggle switches

I am trying to implement a material UI switch feature that can update the Active and De-Active status of users in the database directly from the Admin Panel. Currently, the database updates are functioning correctly when toggling the switches. However, th ...

The projection of state in NGRX Store.select is not accurately reflected

Every time I run the following code: valueToDisplay$ =store.select('model','sub-model') The value stored in valueToDisplay$ always corresponds to 'model'. Despite trying various approaches to properly project the state, it s ...

Issue with validating alphanumeric value with multiple regex patterns that allow special characters

I have created a regular expression to validate input names that must start with an alphanumeric character and allow certain special characters. However, it seems to be accepting invalid input such as "sample#@#@invalid" even though I am only allowing sp ...

Mastering HTML5 Video: A guide to smoothly playing multiple videos in a loop fashion

Although similar questions have been raised in the past, none has successfully addressed this particular issue; they only provide partial solutions. The objective is as follows: We possess a collection of videos referred to as video1, video2, video3, vid ...

JSONP OpenWeather API

I've been trying to access and retrieve weather data from OpenWeather using their API, but unfortunately, I'm facing some difficulties in getting it to work. It seems like there might be an issue with the way I am fetching the JSON data. To quer ...

What is the method for determining the new point coordinates and direction vector after a rotation of degrees in three.js?

How can I determine the coordinates of point A to H after rotating a certain number of degrees and aligning them with direction vector (-42, 51, 11) using three.js? Thank you in advance for your help and please forgive any mistakes in my English. Best reg ...

Slider-activated Pie Chart Controller

I have successfully created a pie chart using highchart and javascript, allowing me to adjust each slice individually using a slider. However, I am facing an issue where I want the maximum value of the pie to be 100%, with the other sliders contributing to ...

Accessing a function from a separate module in Angular 2

I am encountering an error message stating "has no exported member test" when trying to import test from ConfigAppProviderModule. Could there be a mistake in how I am writing the service with config in the module? import { NgModule ,InjectionToken,Injec ...

Is there a way to trigger js function calls upon the loading of my .js file?

How can I ensure that the following function calls are executed when the .js file is loaded? Layout.Controls.sidebar(Button.Add); Layout.Controls.sidebar(Button.Init); Layout.Controls.printScreen(Button.Add); Layout.Controls.theme(Button.Add); Layout.Cont ...

Attempting to forward an image in a node-js/express application

I am facing an issue with a broken image link when trying to access it through Express: app.get('/fileThumbnail', function(req, res) { var url = proxiedURL +"?" + querystring.stringify(req.query); logger.info('/fileThumbnail going to url& ...

Tips for modifying the main color of the React integrated Bootstrap

Currently, I am utilizing React's built-in Bootstrap (the version that doesn't require any additional library or package installation) for my website. I'm looking to customize the primary color - any suggestions on how to go about this? ...

What is the best way to attach a tag or label onto multiple objects so that it remains facing the camera whenever the user interacts with the objects?

My goal is to create a tag or label that always faces the camera when a user clicks on an object, even if that object is rotated. How can I achieve this? I've been advised to use an Orthogonal camera, but I'm not sure how to do that. Additionall ...

Exploring the Issue of Flickering in 3D Models with Three.js and Potree

Currently, I am working with a gltf model from this link: using Three.js and Potree. However, I am facing an issue with the model flickering. I have gone through similar posts on this topic like Flickering planes and Texture/model flickering in distance ( ...

What could be the reason for receiving a Firebase INVALID_DYNAMIC_LINK_DOMAIN error message?

I'm having trouble implementing email verification in my React website. Whenever I use the sendSignInLinkToEmail function, I encounter the following error: XHRPOSThttps://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=xxxxxxxxxxxxxxxxxxx [ ...

What is the best way to incorporate new data into localstorage in a React application?

My attempt to implement and add data into local storage has not been successful as it keeps updating the old data instead of adding new ones. Can someone please explain how to store an array of objects entered by a user in local storage using React JS? ...

Exported Members or Node Modules are not available

Starting out with Angular 2 / Typescript and following the 5 Minute Quickstart guide located here. I've come across a common issue, but with a slight twist. I'm running into several "No Exported Member" problems. For example: In app.module.ts: ...

Is the script failing to retrieve the innerHTML content?

Here is a snippet of HTML code: <div id="team_players"> <h3>Players</h3> <button class="bold-btn" onclick="teamAct('player_list');">Refresh List ↻</button> <table> <thead> <tr> ...

Hiding Bootstrap Popover When User Clicks Outside of it

My webpage has dynamically loaded content featuring popovers which need to be bound to the body for correct loading and appearance. I am looking for a solution to hide the popovers when a user clicks outside them or on another popover trigger. After some ...

What is the procedure to reduce my final search result by 1?

When the search is triggered, I want to filter the images by name. However, the issue arises when trying to make everything disappear on filter addition. <ul id="list2"> <li class="in2"> An extra number is added ...

Tween.js - Can you animate a variable using tweens?

Recently, I've been experimenting with three.js and tween.js and I'm curious if it's possible to animate a variable using tweening? Here are some of my attempts: 1) tween = new TWEEN.Tween(renderergl.toneMappingExposure).to( "0.001&qu ...