Ask Sawal

Discussion Forum
Notification Icon1
Write Answer Icon
Add Question Icon

Banksy Koster




Posted Answers



Answer


Token-based authentication (most often JWT based) is referred to as stateless authentication — because the authentication server doesn’t need to maintain any state, the token itself contains all the necessary information to verify a token bearer’s authentication.

The server can seamlessly check whether the JWT contains the necessary information about the user’s identity and authorization to perform an action without querying the database. Now the question arises, if such is the scenario then do we need to save the JWT token in the database? If yes, then when and why?

I will try to cover three scenarios where the necessity to save the tokens in DB arises.

Before we dive deep into the topic let me give you a tiny introduction on access tokens and refresh tokens. When a user logs in, the authorization server issues an access token (generally JWT), then the client can use this token to make secure API calls.

When the client needs to access any protected resource from the server on behalf of a user, it attaches the token in the request header which helps the server to determine the authenticity of the client/user. Access tokens have a very short lifespan (generally not more than 30mins).

Once the access token expires the client application can prompt the user to re-login (which is certainly not a good user experience) or the client can use a refresh token which is issued by the authorization/authentication server to generate a new access token.

Refresh tokens generally have a much higher life span than the access tokens. They may or may not be JWT. Refresh tokens can be a simple encoded string or a UUID. Refresh tokens are also bearer tokens, hence ​malicious users can theoretically steal the refresh token and use it indefinitely to access protected resources from the server. Then how do we secure our application from malicious users accessing protected resources?

The most straightforward answer to this question would be saving refresh tokens in the database and revoking access of all users by deleting all the refresh tokens when any such malicious behavior is reported. But what if it’s not reported, do we let the malicious user access protected resources indefinitely? Do we keep on saving refresh tokens in our database?

The answer to this question is refresh token rotation, refresh token reuse detection and deleting all old refresh tokens when a new one is generated. Let me try to explain my answer — when a new access token is generated (at the time of sign in/signup or using a refresh token) — a new refresh token should also be generated (this is called refresh token rotation), and all the previous refresh tokens must be deleted.

In this way — even if a malicious user steals the refresh token, when the legitimate user tries to log in to the application, a new access token and a new refresh token will be generated, and all other refresh tokens will be deleted, if the malicious user tries to use the old refresh token the refresh token reuse detection would already detect the reuse or the refresh token wouldn’t exist in DB. This way we can prevent a malicious attack.

A verification email is sent out to a user email address (which he/she uses to register), after they register into an application. This email contains a link with a token generated by the server for that user ID, when the user clicks on the link an API request is made to the server with this token (email verification token). These tokens always have a short expiration time.

The server needs to verify this token for that user email. But what if the user clicks on the resend verification email again even before the current link/token’s expiration? To handle such scenarios tokens need to be saved in DB — either all the tokens or only the latest one (when a new token is generated old tokens are deleted).

Since all or more than one token is active at this moment, JWT verification would pass for any of the tokens, but we should compare only with the latest one. Once verification is done, all the email verification tokens for that user must be deleted.

When a user clicks on forgot-password and enters his/her email address, an email is sent out to the user containing a link (which contains a reset password token). These reset password tokens also generally have a short lifespan.

Once a user clicks on the link, he/she needs to enter the new password, and once clicked on reset password an API request is made to the server containing the new password and token sent in the email link. The reason to save/not save this token is pretty similar to email-verification-token. If the user clicks on the forget password more than once and receives multiple emails (all before the token’s expiry).

In this case, we need to store all the tokens in DB or the latest one (when a new token is generated the old tokens should be deleted). After a user clicks on the link, the token in the API request payload is matched with the latest token in DB for that user, and all the reset-password tokens for that user must be deleted.


Answer is posted for the following question.

Where jwt token is stored?

Answer


  1. Open the Server Manager (Start > Server Manager).
  2. In the Security Information section, click Configure IE ESC.
  3. In the Internet Explorer Enhanced Security Configuration window, disable the IE ESC for Administrators and Users, and click OK.

Answer is posted for the following question.

How to temporarily disable explorer?

Answer


That's inevitable, given the spectacular volatility the cryptos have seen in recent months, more than doubling in value and falling back down


Answer is posted for the following question.

Why are crypto mining stocks down today?

Answer


The Government Employees Insurance Company is a private American auto insurance company with headquarters in Chevy Chase, Maryland. It is the second largest auto insurer in the United States, after State Farm.


Answer is posted for the following question.

Who owns geico insurance?

Answer


What are the Rates? The rates are all based on an average scale but, typically, the lowest amount you can spend is anywhere from $300-$800 on a 'Junior poster', which is a small billboard that can be around 11' wide and 5' high Anything bigger could cost you anywhere from $900-$5,000


Answer is posted for the following question.

How much does billboard advertising cost in canada?

Answer


The second way to earn Dark Zone Credit is by killing other players . Generally, the most effective way to do this is by focusing on Rogues. They are always marked on your HUD and map, and killing a Rogue won't cause you to take on Rogue status yourself.


Answer is posted for the following question.

How to earn dz credits?

Answer


  1. Open the default browser of your iOS or Android mobile device.
  2. Download the BLPE Shader pack from below.
  3. When the file is downloaded, open your Minecraft Pocket Edition and head over to Settings> Global Resources> and Apply the recently downloaded pack.
  4. Restart the game and play.

Answer is posted for the following question.

How to download bsl shaders for minecraft pe?


Wait...