Refers to the state of the application, that is, the condition or quality of it at a given time. In stateless authentication, there is no session or user stored, containing only static contents. This differs from stateful, which is dynamic content.
A stateless process is an isolated resource, which does not reference any other service or interaction with another system. It operates only in that part of the code, without bringing information from old transactions, as stateless authentication does not store this type of data; each operation is done from scratch.
Stateful authentication allows information to be used more than once and is executed based on the context of previous transactions. Therefore, in applications where it is necessary to wait for a response or preexisting data, whether present in another system or database, stateful is used.
Stateless authentication consists of a strategy in which, after providing credentials, the user receives an access token in response. This token already contains all the information necessary to identify the user who generated it, without the need to continually consult the service that issued the token or a database.
This token is stored client-side (browser), so the server only has the ability to check the validity of the token by confirming that the payload and signature match.
JSON Web Token (JWT) are keys with standards established in RFC-7519, containing an entity in the form of declarations, which are independent, without the need to call the server to revalidate the token.
Are strings encoded in the base64 standard using a secret key, as in the example:
Advantages:
Disadvantages:
Commonly used in various applications, especially those that do not require as much scalability, the stateful session is created in the back-end of the application, and the session reference is sent back to the corresponding user. Each time the user makes a request, part of the application generates the token. From that moment on, with each new request, this token will be sent again to the application to revalidate access. In this model, if there is any change in user data, the token can be easily revoked.
These are opaque access tokens, that is, a simple string in a proprietary format that does not contain any identifier or user data relating to that token. The recipient needs to call the server that created the token to validate it.
Example token: 8c90e55a-e867-45d5-9e42-8fcbd9c30a74
This ID must be stored in a database with the user who owns the token.
Advantages:
Disadvantages:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3