Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stateless Authentication - what really does it mean?

I use Socialite library in Laravel. In documentation tells one paragraph:

The stateless method may be used to disable session state verification. This is useful when adding social authentication to an API:

what really does it mean? When I should use that?

like image 468
Dev Avatar asked Dec 28 '25 08:12

Dev


1 Answers

Actually, the basic authentication mechanism uses session to store the visitors identity so when you once get authenticated (providing credentials in a login form) the application doesn't ask for the password again when you visit another page after login. So, the session is used to keep the user's current state in the application. This is what happens in most of the cases.

On the other hand, the stateless authentication is used without using the session. In this case, the application doesn't keep any data into the session to identify the user on subsequent requests. Instead, it verifies every request independently.

When you gonna need this?

Basically, it's needed when you are going to build some kind of API which may serve resources as service to users where a user may send a request to your API to get data from anywhere, I mean the user may not be a registered user of your system but you may allow a user to consume data from your server depending on some sort of token based authentication.

This is not enough to describe the stateless auth but this may give you some idea. Further, you may check How to do stateless (session-less) & cookie-less authentication and this and also you'll find useful links if you search on Google using the term Stateless Authentication.

like image 57
The Alpha Avatar answered Dec 31 '25 00:12

The Alpha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!