Questions tagged [jwt]

A JSON Web Token (JWT, pronounced "jot") serves as a form of token-based authentication specifically designed for use in limited-space environments like HTTP Authorization headers. Feel free to employ this tag for any inquiries regarding the setup, creation, and application of JWTs within your codebase.

I seem to be failing at properly executing Promises... What crucial element am I overlooking in this process?

Within my project, there exists a file named token.ts which contains a function that exports functionality: import * as jwt from 'jsonwebtoken'; import { db, dbUserLevel } from '../util/db'; export function genToken(username, password): Object { le ...

Troubleshooting error message: 'crypto' module not found while validating JWT token in Next.js middleware

While attempting to implement JWT verification for authentication with middleware, I encountered some errors that have proven difficult to resolve. ./node_modules/jwa/index.js:3:0 Module not found: Can't resolve 'crypto' Import trace for re ...

Tips for setting a unique JWT secret in next-auth for production to prevent potential issues

Is there a way to properly set a JWT secret in NextAuth.js v4 to prevent errors in production? I have followed the guidelines outlined in the documentation, but I am still encountering this warning message without any further explanation: [next-auth][warn] ...

What steps should I take to ensure that a cookie has been properly set before utilizing it?

I'm in the process of developing a JWT authorization code flow using Next.js and NestJS. Below is the POST request being sent from the frontend to the backend server: const response = await fetch( 'http://localhost:4000/auth/42/callback?code=& ...

Check access tokens from various front-end applications (Client ID) with the help of okta-jwt-verifier

Is there a way to verify access tokens generated from multiple front end Angular apps using the same backend API by sending in an array of clientIds? const OktaJwtVerifier = require("@okta/jwt-verifier"); const oktaJwtVerifier = new OktaJwtVerifi ...

What is the best way to incorporate auto refresh in a client-side application using vue.js?

Disclaimer: I have separated my client application (Vue.js) from the server side (DjangoRest). I am utilizing JWT for validating each request sent from the client to the server. Here is how it works - The client forwards user credentials to the server, an ...

Exploring ways to bypass authentication using react development tools

Currently, I am delving into the realm of token-based authentication in SPA and a question has been nagging at me. Picture this: in my app, the authentication process works like this - when a user enters correct credentials, they receive a token and the "a ...

Managing the storage of refresh and authorization tokens on the client side: where should they be kept?

My backend is powered by Laravel and the frontend uses Vue. Users authenticate by calling my Laravel API to get an Auth token and a refresh token. The Auth token expires after 2 minutes, while the refresh token lasts longer. Storing the refresh token in l ...

Retrieve JSON web token from HTTP header following backend SAML2 authentication

I am facing a challenge in my Angular application where I need to read the JWT from the HTTP header after being redirected from the backend. Here is an overview of my authentication process: Once the user logs in successfully on the web browser, a POST r ...

Storing JWT securely in cookie or local storage for a Node.js/Angular 2 web application

I've been researching how to save jwt tokens in either local storage or cookies but I'm having trouble finding clear instructions online. Can someone provide guidance on how to instruct the server to recognize a user for future sessions? //authentic ...

Angular 10 experiences issues with JWT Helper service causing errors

Currently, I'm facing an issue with my Angular 10 project and the latest JWT Helper service. Unfortunately, the app is failing to compile. The error message that pops up reads as follows: ERROR in node_modules/@auth0/angular-jwt/lib/jwthelper.service.d.t ...

Verifying paths using Jwt Token authentication

const userModel = require('../models/UsersModel') const express = require('express') const routes = express.Router() const bcrypt = require('bcrypt') const jwt = require('jsonwebtoken') require('dotenv').config() routes.post('/signup', async(req, res) =&g ...

Guide to implementing hapi-auth-jwt2 authorization on a specific route within hapi.js?

I am facing an issue with using an access token in hapi.js. I am struggling to comprehend how to utilize this token for authentication purposes. Currently, I am referring to the article on dwyl/hapi-auth-jwt2. My database setup involves mongodb. However, I ...

Tips for integrating jwt token into axios request

I am facing an issue with my backend endpoint. I can successfully retrieve a list of customers using jwt token on Postman, but when I try to fetch the list from a React app using axios get request, it fails. After reading through this question, I implemen ...

The useState function in React does not update the state

I have a frontend code snippet that deals with authentication: AuthContext.js: const { createContext, useState, useContext } = require("react"); const AuthContext = createContext(); export function useAuth() { return useContext(AuthContext); } export ...

Every time I attempt to utilize tokens, I consistently encounter the error message "Login sessions require session support"

Currently, I am learning about JSON tokens through a tutorial and encountering an error. Previously, everything was functioning correctly with sessions, but now I can't seem to pinpoint the problem even though I'm using identical code. This snip ...

Which method is better for accessing a user's data - using a sent token or the user_id?

When a user has multiple offers, should the fetching be done using the sent Authorization token or by sending the user_id separately in a body request? I am focusing on Node.js and MongoDB for this question, considering that best practices may vary with d ...

Controlling the access to simpleJWT tokens in Django-React authentication to restrict user permissions

My backend has two React frontends: one for general users and the other specifically for admin users with the is_staff attribute. I have customized TokenObtainPairSerializer to add extra fields like 'is_staff'. Now, I'm considering how to r ...

NextAuth encountered a CLIENT_FETCH_ERROR error while processing the session callback

Encountering issues while trying to set up nextauth v4. Keep getting this error: Client fetch error, Unexpected end of JSON input {error: {…}, path: 'session', message: 'JSON.parse: unexpected end of data at line 1 column 1 of the JSON d ...

Angular fails to retrieve the data from an Object

I have both backend and frontend applications. When I attempt to retrieve information about the 'Probe' object, I can see its fields: https://i.stack.imgur.com/TJQqI.png However, when I try to access this information in Angular, I receive an undefined val ...

Issue with Flask-Cors in Nuxt with Flask and JWT authentication implementation

I have exhausted all the available solutions to my issue, but I still can't seem to pinpoint the problem. Despite trying every solution out there, nothing seems to be of any help. Every time I make a request, the browser blocks it due to CORS Policy. My ...

I'm having trouble adding headers to my axios post request. The post route functions correctly in Postman but does not work when using axios. Can anyone

Implementing JWT for protecting a post route in my nodejs, express, react application has been quite a challenge. While testing with postman and adding the JWT token to the headers works flawlessly to add users to the database, I encounter a 401 response ( ...

Is it secure to utilize useCnntext and useReducer for storing JWT tokens?

Would it be secure to utilize useCnntext+useReducer for storing JWT tokens? Additionally, how does this differ from using Redux? ...

User experiencing data loss following JWT refresh

Before diving into the issue, let me share the pertinent code snippets. This is my middleware for authenticating JWT: module.exports.authenticateToken = (req, res, next) => { const authHeader = req.headers["authorization"]; const token = authHeader ...

Encountering a mysterious token error in the backend system

Hello, I am facing an issue with using my token in the application after the user logs in as I am receiving an undefined response in the console. Below are the snippets of code I have been working with. How can I modify my code to successfully access the t ...

What is the process for a server to transmit a JWT token to the browser?

Here is an example response sent to the browser: HTTP / 1.1 200 OK Content - Type: application / json Cache - Control : no - store Pragma : no - cache { "access_token":"MTQ0NjJkZmQ5OTM2NDE1Z ...

What is the proper method for transmitting a token as Bearer authentication in the header to the browser

Here is a snippet of code from my helper signin router where I am attempting to set a cookie in the browser after confirming sign in. exports.signin = (req,res) => { db.User.findOne({email:req.body.email}).then(user => { user.c ...

The Passport JWT strategy has encountered a malfunction

I can't figure out why my Passport Jwt Auth suddenly stopped working. Code snippet from app.js app.use(passport.initialize()); passport.serializeUser(function (user, done) { done(null, user); }); passport.deserializeUser(function (user, done) { ...

Storing Json Web Tokens in a mongodb database with node express

Recently, I integrated jwt (JsonWebToken) into my Node.js Express application with MongoDB. When generating the token, I saved the value in a database collection and retrieved it from MongoDB to pass on to subsequent pages. Additionally, I implemented a ...

Exploring Angular: How to Access HTTP Headers and Form Data from POST Request

I am currently working with an authentication system that operates as follows: Users are directed to a third-party login page Users input their credentials The website then redirects the user back to my site, including an auth token in a POST request. Is ...

Can Socket.io be connected only when a user logs in?

Exploring the fundamentals of Socket.io and aiming to establish a connection ONLY when a user logs in. The official documentation doesn't provide clear guidance on this specific implementation. Utilizing JWT for authentication and Node.js for server-side p ...

Error: Unable to access attributes of null object (specifically 'accessToken')

After following a YouTube tutorial by Lama for creating an E-commerce application, I attempted to add a logout feature on the admin page that was not covered in the tutorial. To implement this, I used Redux to grab the currentUser and set it to null to suc ...

In a React app, there are instances where `localstorage.getitem('key')` may result in returning null

I've encountered a strange issue while building a login form that sets a JWT token in localstorage. The problem arises when, despite being able to see the token in my console.log, setting localstorage.getitem('idToken') sometimes returns nul ...

The JWT token contains a HasGroup parameter set to true, however, the roles values are missing from the claims

I recently made some changes to the group claims in my Azure AD app's token configuration. While I can see a value of hasGroup: true in my token, I am not able to view the actual list of groups. Can someone please assist me with this? "claims" ...

13 upcoming issues with server components related to cookies

My code involves retrieving cookies from the user on the front end, verifying it against a backend token stored in a database, and controlling access to certain pages based on this validation. If the "token" cookie is present, the user is allowed access, o ...

Endless loop occurs with post and put requests while attempting to refresh authentication token

Every time the token expires in my application with NEXTjs and I attempt to make a post request, it gets stuck in a loop. The POST request returns 401, then the refresh-token returns 200 after attempting the post again, it returns 401, and the cycle repeat ...

Unable to verify token within JWT Express middleware

I am encountering an issue with the validation of JWT tokens. When sending a GET request using Postman, the validation process fails to work as expected. Surprisingly, the request can go through even without a token. My concern is regarding utilizing this ...

Integrate AngularJS with Laravel using API keys

I am currently developing an application that utilizes Laravel for the backend and AngularJS for the front-end. The user authentication process between the front-end and the API is quite simple, as JSON web-tokens (JWT) are used. This particular tutorial ...

Is there a way for me to access the user's gender and birthday following their login using their Google account details?

I have successfully implemented a Google sign-in button in my Angular application following the example provided in Display the Sign In With Google button: <div id="g_id_onload" class="mt-3" data-client_id="XXXXXXXXXXXX-XX ...

Updating the Navigation Bar after User Logs in

In the process of working on my assignment, I am in the midst of developing a web application. As someone who is new to using React, I'm currently trying to figure out how to modify my navbar once a user has logged in. For instance: Prior to logging ...

The bearer token was not found or is currently undefined

I’ve recently encountered an issue while trying to incorporate a Bearer token into my POST route. Upon submitting a POST request using Postman, the resulting output displayed: { "success": true, "token": "Bearer undefined" } Shown below is a sn ...

What are some potential problems that could arise when making a POST request for signing authentication in a MERN stack using JWT?

I'm currently in the process of developing a social media application using the MERN stack. To ensure the functionality of the backend API, I am utilizing POSTMAN. Here is an overview of the dependencies outlined in the package.json file: { "name": ...

Confusion surrounding JWT authorization middleware

After reviewing the authentication middleware code in a course I am currently taking, I have some concerns about its security. I decided to test a protected route using Postman and discovered that I was able to retrieve an order for one user with a token ...

Is it secure to store the access token within the NextAuth session?

Utilizing a custom API built with Node.js and Express.js, I have implemented nextAuth to authenticate users in my Next.js application. Upon a successful login, the date is stored in the nextAuth session and can be accessed using the useSession hook. To acc ...

Incorporating JWT Token into Apollo Context in NextJs

I am facing an issue with integrating my jwt token into the context of my Apollo server using NextJs. In my previous experience with React and Express, I was able to pass the token in the headers as shown below: const client = new ApolloClient({ reque ...

Obtain information from a PHP file using AngularJS 2

Can you guide me on how to post data and receive a response from a PHP page in AngularJS 2? I want to send data from auth.js file to session.php for storing the session value. Please show me how to do this using HTTP POST method. retu ...

What is the best way to securely store a JWT Token received from Cognito after logging in through the Cognito Hosted UI?

Our current architecture involves front end Angular and backend nodejs/express. This setup functions in the following order: User logs in to the site via Cognito Hosted UI Upon successful login, the user is redirected to our home page with a code sent in ...

Getting a JWT token from Express to Angular using ngResource: A step-by-step guide

Currently, I am utilizing a jwt token for user registration validation. A unique URL is generated and sent to the user via email, which leads them to the authentication page. On the server side, the token is decoded and I need to transmit this JSON data to ...

I am looking for a solution on how to validate a token issued by Auth0 in a nodejs backend using jwt, but I keep

My React frontend uses Auth0 for user authentication. Once a user is logged in, I retrieve the token using getAccessTokenSilently() and send it to the backend like this: const { user, isAuthenticated, getAccessTokenSilently } = useAuth0() useEffect(() =&g ...

Can a JWT token be verified without access to the secret key?

Recently, my focus has been on understanding JWT and its potential application. I have been exploring the idea of incorporating JWT into a Next.js server alongside an external authentication server that issues JWT access tokens. Initially, I considered th ...

Updating access tokens within a Google login component in React by utilizing django-allauth

I recently integrated Google Login into my web app which has a React front-end and Django backend. In the front end, I utilized the react-google-login package to manage all authentication processes, while on the backend, I implemented django-allauth with s ...

Retrieve request header in Nest.js Passport local strategy

Is there a way to retrieve the request headers in passport local strategy? My objective is to establish a separate database for each entity using mongodb, and I need to determine the subdomain before authentication in order to connect to the correct data ...

unable to retrieve an object's property

Currently, I am implementing a JWT token compare function to authenticate user login by comparing the user password. However, I am facing an issue where I cannot access the user password after executing the mongoose query. exports.login = async(req, res, n ...

Secure your routes by verifying status on a separate server using JSON Web Token authentication service in NodeJS

Currently, I am working on a project where I am developing an API using Node/Express/Mongo and also building a website with the same tools. I would like to host these on separate servers for scalability purposes. For authentication, I have implemented jso ...

Angular 2+: Harnessing the Power of Web Tokens

After sending a POST request to the backend REST API through a login component, I receive an x-auth token in the response headers. What is the best way to retrieve and save this token for using it in all subsequent API requests throughout the user's logg ...

Oversee various interactions for the user

I am currently utilizing NodeJs, ExpressJs, and Angular 6 for my application, but I have encountered an issue. Within my system, there is a user with the attributes: User U: { name; email; password; } Let's assume this user, named U, is logg ...

Verify the authenticity of the Jwt Token in Angular

For the purpose of creating a JWT token, I possess both a public key and a private key. To generate the JWT token, the private key is used, while for verifying its validity, the public key comes into play. The following code snippet is employed on the ser ...

Best Practices for Safely Storing the JWT Client Credentials Grant

Currently, I am working on a NodeJS Express Application that connects to an Auth Server using client credentials grant. After receiving the token from the Auth Server, I use it to access data from an API. I am seeking advice on the most effective way to s ...

Is it possible for Angular 2 JWT to have an unauthenticatedRedirector feature?

Having transitioned from Angular 1 where JWT tokens were used for user authentication, I had the following code: .config(function Config($httpProvider, jwtOptionsProvider) { // Interceptor to add token to every $http request jwtOptionsProv ...

What could be causing the malfunction of my token rotation feature in nextAuth?

I am developing a web application that involves working with an external API alongside my team member. We are making API requests using Next.js. I have implemented nextAuth for authentication, but I am facing issues with token rotation. After successful lo ...

Encountered a SyntaxError on JSON Web Tokens Node JS Server: Unexpected token } found in JSON at position 24

Me, along with others, have encountered this issue: SyntaxError: Unexpected token } in JSON at position 24 at JSON.parse (<anonymous>) while following a tutorial on JSON Web Tokens (TUTORIAL LINK: https://www.youtube.com/watch?v=mbsmsi7l3r4&t=34s ...

Is it possible for anyone to access a website's source code using a web browser?

As I navigate the complex world of storing authentication tokens securely using Angular, with the added layer of encryption in the front end before placing it in browser local storage to prevent unauthorized decoding, I have encountered various conflicting ...

Protecting my HTTP connections

Currently, I am working on my Home Automation project and here is how the setup looks like: An ESP8266 WiFi module will be connected to a variety of sensors. The module will run a light web server while a Linode Cloud will host specific NodeJS scripts a ...

"Implement next-auth alongside a credentials provider and utilize a JWT token as a bearer in order to authenticate access to the API

Currently in the process of developing an application using Next.js and Next-auth with credentials provider. I'm trying to figure out how to secure my APIs within the pages folder by utilizing the JWT token generated by next-auth as a bearer token in the a ...

We encountered an issue: `TypeError: expressJwt function is undefined`

As I work on developing middleware for user authorization within my application, I encounter an issue while attempting to determine if a route necessitates signing in. The relevant snippet of code is presented below: const { expressJwt } = require ...

Procedure for validating a JWT token in order to retrieve the user profile

Within the context of my current test project using Node.js and Express, I am utilizing JWT for authentication. When handling a POST request, I ensure that the user sending the request is identified by including the JWT with it. Once this request reaches t ...

Server sending JSON Web Token to the client along with a page redirect

I am currently developing my backend server using Node Express. To handle authentication in my application, I have implemented Passport-SAML and JWT for user session management. The overall flow is as follows: Users access the login endpoint. They are th ...

Secure user authentication is essential for the proxy application built on Express using NodeJS

I currently manage two servers: Server A - Utilizes Express/FeathersJS and is accessible to the public. It is secured with JWT for authentication. Server X - A Django application that is not available publicly and does not require any type of authenticati ...

Error Encountered: RSA Key Pairs Invalid Signature for JSON Web Token (JWT)

I am facing an issue with my Node.js application (version 20.5.1) regarding the verification of JSON Web Tokens (JWT) using RSA key pairs. The specific error message I am encountering is: [16:39:56.959] FATAL (26460): invalid signature err: { "type& ...

Using PHP to generate JWT signatures for web push notifications

I am currently working on setting up web push notifications using PHP. While I have researched the implementation of the web push protocol, such as reading about it here, I am struggling with understanding how to create the Authorization header as explaine ...

The Angular compiler encounters an error when working with jsonwebtoken

Having some trouble with adding jsonwebtoken to my code. VS Code seems to think the code is fine, but the compiler keeps failing Any ideas on why this might be happening? Thanks for any help! Here's a snippet of my code: this.http .po ...

Tips for resolving the "Unauthorized 401 error" when accessing JSON data from the back end on a React profile page

My current setup involves utilizing React and Express for this application. React is running on PORT 3000, while Express is running on PORT 3001. Authentication on the Express side is implemented using JWT. Here is an overview of my auth.js service file: ...

What is the advantage of transmitting JWT tokens through the Authorization header instead of within the payload?

One common practice is to include JWTs in the Authorization header, prefaced by the "Bearer" string. What is the reason for this approach, and why not just send the token in the body of a post request? Is there an easy way to authenticate the token in nod ...

Best practices for effectively managing errors within JSON web tokens

I am a novice attempting to manage JWT verification. Within the function below, my goal is for the system to generate a new access token based on the refresh token if the user's access token has expired. import { asyncHandler } from "../utils/asy ...

Authenticating users through Express with Auth0's backend

Exploring the Auth0 documentation reveals guidance on implementing express-jwt middleware to secure endpoints. However, a gap seems to exist in how to actually acquire a valid JWT initially. Regarding Angular development, there are resources available for ...