Node TS: JWT token sign to verify authentication between client and backend question

Is it safe to generate a JWT token on server-side and to pass it in a sign-up request within the response JSON back to the client? Currently I’m generating a JWT in the following way: import express from "express"; import jwt from "jsonwebtoken"; const generateToken = (id: any, res: express.Response) => { const token =… Read More Node TS: JWT token sign to verify authentication between client and backend question

Spring boot Unique index or primary key violation when using jwt to authenticate, when multiple authentication requests in a short time

I am using jwt to authenticate in my spring boot app. These are methods in AuthenticationService: public AuthenticationResponse authenticate(AuthenticationRequest request) { authenticationManager.authenticate( new UsernamePasswordAuthenticationToken( request.getEmail(), request.getPassword() ) ); User user = userRepository.findByEmail(request.getEmail()).orElseThrow(UserNotFoundException::new); String jwtToken = jwtService.generateToken(user); String refreshToken = jwtService.generateRefreshToken(user); revokeAllUserTokens(user); saveUserToken(user, jwtToken); return AuthenticationResponse.builder() .accessToken(jwtToken) .refreshToken(refreshToken) .build(); } private void revokeAllUserTokens(User user) { List<Token>… Read More Spring boot Unique index or primary key violation when using jwt to authenticate, when multiple authentication requests in a short time

how can i get the user_id from jwt in the localstorage and use it in react?

I am writing a logic to create a post and i want to add the logged in user as the user making the post, i have saved the refresh token in my browser localstorage, when i copy the refresh token and paste in jwt.io, i get this response { "token_type": "refresh", "exp": 1679234275085, "iat": 1674953425085,… Read More how can i get the user_id from jwt in the localstorage and use it in react?

Best practice to get user's idToken from Firebase – using getIdToken(/* forceRefresh */ true) leads to Firebase: Error (auth/quota-exceeded)

I’m working on a dashboard website in react.js where the users can analyze multiple different charts. To get the data for the charts from my node.js server I need to get the user’s ID token to be able to verify it on the server side (return data only if user is authorized). In the firebase… Read More Best practice to get user's idToken from Firebase – using getIdToken(/* forceRefresh */ true) leads to Firebase: Error (auth/quota-exceeded)

Angular does not display JWT protected pictures but it loads them properly?

I’m writing an Angular application (version 14.1) where I fetch images from my backend which are protected by a JSON web token. Meaning, each time the user wants to fetch an image from the backend, a valid JWT needs to be attached onto the request, otherwise you get back a http403 forbidden. From a browser… Read More Angular does not display JWT protected pictures but it loads them properly?