Some questions about using token for login authentication

recently, I have been learning about the backend. In the process of learning SSM, because I want to give the client a login authentication function, I thought of using token for authentication and using auth0, to generate token through user id encryption. The question arises: in addition to being returned to the client, does the generated token need to be stored in a database or redis? Or is it OK to decrypt and verify the received token directly?

Nov.23,2021

just decrypt it when you want to use it directly.
storing the database doesn't seem to make any sense. Do you have to retrieve the database once, which is a waste of io


token to decrypt it? Not afraid of being cracked?


the token generated by encrypting ID is fixed, there is no need to store the database, but the problem is that it is not timely.
you can try to increase the timeliness based on random strings as Token,


if it is a login authentication token, you can consider using jwt to do it, so that after the login is completed, the subsequent request can parse the user name information with this token, in the header.
if you need to add token, to a general request to prevent the interface from being brushed or to prevent the interface parameters from being changed in series, the front and back end can use a set of encryption rules to encrypt the parameters and the expiration time of the request to generate a token and pass it to the backend, and the backend uses the same rules to generate a token for comparison. If the parameters are changed in series, or if the request time has been exceeded, a signature error is reported, which can prevent the interface from being brushed and the interface parameters from being changed in series.

Menu