Comments (2)
To clarify, the reason why JWT is considered stateless is because we do not need to store the user's session in the server. Instead, the client is responsible for storing session details in the form of the jwt token.
The line SecurityContextHolder.getContext().setAuthentication(authentication);
does not store the session details in a session store, instead it is just simply used to tell Spring Security that the user is authenticated.
from spring-boot-spring-security-jwt-authentication.
SecurityContextHolder is the most fundamental object where we store details of the present security context of the application (includes details of the principal). Spring Security uses an Authentication object to represent this information and we can query this Authentication object from anywhere in our application:
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
// currently authenticated user
Object principal = authentication.getPrincipal();
Pasting it from author's another detailed blog post on the same- https://bezkoder.com/spring-boot-jwt-mysql-spring-security-architecture/
from spring-boot-spring-security-jwt-authentication.
Related Issues (19)
- Role is not found HOT 6
- Question. With this implementation, if you intentionally remove the token from the request header, won't the token filter stop working?
- This entire JWT implementation is bad practice HOT 9
- signup is not Working HOT 1
- Upgrade into Spring Boot 3.x.x version
- Signup posts generates 401 HOT 8
- The web application [ROOT] appears to have started a thread named [HikariPool-1 housekeeper] but has failed to stop it. This is very likely to create a memory leak.
- getting org.springframework.security.authentication.InsufficientAuthenticationException error If I pass unknown api url or method
- diagrama-secuencia-v2
- Missing License
- registro-nuevo-usuario-ok
- login-unauthorized
- acceso-exitoso
- db-h2-login
- db-h2-select-users
- db-h2-select-phones
- WebSecurityConfig.java AuthTokenFilter bug
- Constraint validtions upgrade HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot-spring-security-jwt-authentication.