Is it permissible to use multiple JWT tokens in the HTTP header?

Currently, I have implemented the jwt access and refresh token pattern for client-server communication. The method involves sending two jwt tokens in the header: the access token and the refresh token. This is done by adding the following code to the header:

'Authorization': 'Bearer ' + user.accessToken + ' ' + user.refreshToken

On the server side, I split the request authorization header in order to separate the access token and refresh token. Although this method works for me, I am concerned about its security implications. As a beginner in fetching/auth practices, I want to ensure that I am following recommended security standards. While I understand that my approach may deviate from the norm of using 'Bearer', it has been effective so far. Since I am not integrating with OAuth2 and implementing authentication independently, I would like to continue using this solution if there are no significant security risks associated with it.

Answer №1

I have implemented a unique access and refresh token strategy I apologize, but that statement is incorrect. The method you are using for token management is inefficient, insecure, and ultimately does not provide any benefits. Here's why:

The purpose of the access token is to allow third-party services to authenticate the user.

The purpose of the refresh token is to enable users to generate a new set of access/refresh tokens at any time.

Here's what you're doing wrong:

  1. You are essentially giving both access and refresh tokens to any third party, which means a malicious entity could use the refresh token to maintain control over the user in their system indefinitely by constantly updating their own access token.
  2. You are unnecessarily doubling the size of the token added to the header, creating larger request headers. This exacerbates the issue since normally the refresh token is almost as large as the access token.
  3. Overall, there is no clear benefit to this approach. What exactly do you gain from it?

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

When using `backbone model.save()`, the response body of the express server is not updated by body parser

Attempting to persist a Backbone model by using model.save(). The Model: Backbone.Model.extend({ urlRoot: '/project/', defaults: { projectname: "default projectname" } }); Code snippet for saving the model (within my Backbone.router o ...

Verify the presence of the promotion code and redirect accordingly

I have created a special promotion page that I want to restrict access to only users who have received a unique code from me via email. To achieve this, I have designed the following form: <form accept-charset="UTF-8" action="promotion.php" method="po ...

Unable to invoke the jQuery datetimepicker function within a personalized directive

I have created a unique time picker directive in AngularJS to display a datetimepicker. app.directive("timePicker", function() { return { restrict: "A", link: function(scope, elem, attrs) { / ...

What is the best way to update and add data with just one click using jQuery?

Trying to dynamically add text to textboxes by clicking an "add" button. The code allows for adding/removing textboxes that save values to and delete from a database. Upon page load, a function called showitem creates textboxes dynamically and populates th ...

Grouping items by a key in Vue and creating a chart to visualize similarities among those keys

I am working with an object that has the following structure; { SensorA: [ { id: 122, valueA: 345, "x-axis": 123344 }, { id: 123, valueA: 125, "x-axis": 123344 }, { id: 123, valueA: 185, "x-axis": 123344 }, { ...

Using AngularJS to bind models to a multidimensional array

As I am new to angular js, please bear with me. In my view, I have a grid of text input boxes that I would like to map to a 2D array in my controller or something similar in java script. The code in my view is as follows: <div ng-repeat="row in [1,2,3, ...

Node.js is utilized to power the widgets template system, which incorporates dust server-side templates

My goal is to design a webpage with widgets using Node.js and Dust as the template engine. I want these widgets to be self-contained with their own CSS, JS, and HTML. Among the three methods listed below, which one is considered the best? And which one of ...

What is the purpose of including an es directory in certain npm packages?

Why do developers sometimes have duplicated code in an es folder within libraries? Here are a few examples: https://i.stack.imgur.com/BWF6H.png https://i.stack.imgur.com/3giNC.png ...

Node.js Express and Socket.io are currently awaiting the local host, but no data has been transmitted

I'm at a loss as to why my connection keeps waiting for localhost and then eventually timing out. I've reviewed my code countless times but still can't figure it out. Any assistance would be greatly appreciated. The error message mentions th ...

How can I detect Mongoose events through syntax?

Is there a way to detect the open event in Mongoose based on their documentation located here? According to the documentation, once connected, the open event is fired on the Connection instance. If you're using mongoose.connect, the Connection is m ...

Are there any instances of a race condition present in the following?

In the express server code snippet provided, there is a common object that is being manipulated in three different RESTful endpoints. Given that all HTTP requests in Node.js are asynchronous, it's possible to have simultaneous PUT and GET requests occ ...

Handling typeError in Vue.js JavaScript filter for object manipulation

I need to sort an object based on state names (e.g. Berlin, Bayern ...). Below is the API response I received. "states":{ "Bayern":{ "total":13124737, "rs":"09", "va ...

Transfer a file to another user via a secure service without storing it locally, and seamlessly integrate it with express js and busboy

I have a service that receives a post request with both a file and json data. To handle this, I am using the body-parser package in my app.js. My goal is to send the file to a "filer" service and then process the response without piping the request, as I a ...

Unable to utilize the 'require' function in subdirectories within the node_modules directory

In the development of my express api, I have set up routes as a dependency within the main project. The main project contains a config folder with an index.js file that exports an object serving as the route configuration. While I can access this exported ...

What strategies can I use to keep an element in place while implementing parallax scrolling?

Looking for some assistance with my Codepen project. I am attempting to replicate a layout similar to this BBC article design from the past, but hitting a roadblock with getting my image to be position fixed based on scrolling. I believe that if I can suc ...

Updating inner text content dynamically can be accomplished without relying on the use of the eval() function

I am faced with a situation where I have multiple batches of code structured like this: 1 <div id="backgrounds" class="centery">Backgrounds 2 <div id="bk1" class="attr">Background 1 3 <div class="container"> 4 ...

The function d3.json() does not support googleoverlay

As a newcomer to coding, I am currently working on incorporating the code found at https://bl.ocks.org/mbostock/899711. Instead of using a local .json file, I have opted to read JSON data from a URL. However, I encountered an issue where the LAT and LONG v ...

Tips for sequentially calling multiple await functions within a for loop in Node.js when one await is dependent on the data from another await

I am currently facing a challenge where I need to call multiple awaits within a for loop, which according to the documentation can be performance heavy. I was considering using promise.all() to optimize this process. However, the issue I'm encounterin ...

Controlling the Quantity of Selected Checkboxes with JavaScript

I am facing an issue with implementing multiple checkboxes with limits in JavaScript, as shown below. $(".checkbox-limit").on('change', function(evt) { var limit = parseInt($(this).parent().data("limit")); if($(this).siblings(':checked&ap ...

The attempt to compress the code from this particular file within the node_modules directory was unsuccessful

Hey there! I'm facing an issue while attempting to compile my React project using npm run build. Upon running this command in the console, I encountered the following error message: Failed to minify the code from this file: ./node_modules/react- ...