Comments (6)
Makes sense!
Thank you
from spring-security-samples.
Hi @simasch,
CSRF protection is unnecessary in this scenario because we are using stateless authentication. In other words, we are not dealing with Session Cookies, which are added to the request automatically by the browser, this way avoiding the majority of CSRF exploits. When using an Authorization
header, we have to add the header manually using JavaScript.
The HTTP Basic authentication mechanism is also stateless, so no need for CSRF protection either.
from spring-security-samples.
Hi @marcusdacoregio
That's what I thought :-)
Will https://github.com/spring-projects/spring-security-samples/blob/main/servlet/spring-boot/java/jwt/login/src/main/java/example/RestConfig.java be change accordingly?
from spring-security-samples.
Hi @simasch,
What changes specifically do you expect to see in the configuration?
from spring-security-samples.
csrf(AbstractHttpConfigurer::disable)
instead of
csrf((csrf) -> csrf.ignoringRequestMatchers("/token"))
Because it was very confusing that CSRF is configured but not used and now token was generated.
from spring-security-samples.
It is a little tricky for sure, but I think keeping .csrf((csrf) -> csrf.ignoringAntMatchers("/token"))
makes sense. If the user happens to add some authentication mechanism that relies on a session cookie they do not have to remember to change the CSRF configuration to now include those endpoints.
It is a recommended secure posture to "deny" everything unless they are authorized, it's the same train of thought as spring-projects/spring-security#11958
from spring-security-samples.
Related Issues (20)
- How to build with gradle HOT 1
- In the case of microservices, jwt HOT 1
- Update Saml2 Federation Sample
- Fix sync scripts
- Sync dependency versions
- DaoAuthenticationProvider HOT 5
- Can you provide a simple example of ajax login HOT 1
- Keep samples updated with latest patch versions HOT 2
- Add -parameters to compiler args
- More complete examples for webflux request
- Multi-factor authentication: The second factor can be skipped
- Migrating from Spring Security SAML extension project to SAML2 authentication using Spring Boot 3.X version and Java 17 HOT 2
- AspectJInterceptorTests fails with Spring Framework 6.1.0 SNAPSHOTs
- Upgrade to Gradle 8.3
- Multi factor authentication always redirect to /login even when using correct code for /second-factor HOT 10
- `HiddenHttpMethodFilter` configuration in the `hello-mvc-security` example project? HOT 1
- Add CAS Gateway sample
- Unable to Retrieve Refresh Token HOT 4
- The branch is 6.2.x, but the dependency is 6.1.1 HOT 3
- spring-security-samples/servlet/spring-boot/java/oauth2/login doesn't run HOT 2
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-security-samples.