File tree Expand file tree Collapse file tree 3 files changed +60
-0
lines changed
src/main/java/com/acme/csrf Expand file tree Collapse file tree 3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 4747 <groupId >jakarta.ws.rs</groupId >
4848 <artifactId >jakarta.ws.rs-api</artifactId >
4949 </dependency >
50+
51+ <dependency >
52+ <groupId >org.springframework</groupId >
53+ <artifactId >spring-webmvc</artifactId >
54+ <version >5.3.9</version >
55+ </dependency >
56+ <dependency >
57+ <groupId >org.springframework.security</groupId >
58+ <artifactId >spring-security-config</artifactId >
59+ <version >5.8.0</version > <!-- Use the latest stable version -->
60+ </dependency >
61+ <dependency >
62+ <groupId >org.springframework.security</groupId >
63+ <artifactId >spring-security-web</artifactId >
64+ <version >5.8.0</version >
65+ </dependency >
66+
5067 <dependency >
5168 <groupId >io.github.pixee</groupId >
5269 <artifactId >java-security-toolkit</artifactId >
Original file line number Diff line number Diff line change 1+ package com .acme .csrf ;
2+
3+ import org .springframework .web .bind .annotation .RequestMapping ;
4+ import org .springframework .web .bind .annotation .ResponseBody ;
5+
6+ import java .util .Optional ;
7+
8+ /** The contact controller. */
9+ public abstract class ContactController {
10+
11+ @ RequestMapping ("/search" )
12+ public @ ResponseBody
13+ void logout () {
14+ if (currentSession ().isPresent ()) {
15+ Session session = currentSession ().get ();
16+ session .logout ();
17+ }
18+ }
19+
20+ abstract Optional <Session > currentSession ();
21+
22+ /** The session interface. */
23+ interface Session {
24+ /** Logs out the session. */
25+ void logout ();
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ package com .acme .csrf ;
2+
3+ import org .springframework .context .annotation .Bean ;
4+ import org .springframework .context .annotation .Configuration ;
5+ import org .springframework .security .config .annotation .web .builders .HttpSecurity ;
6+ import org .springframework .security .web .SecurityFilterChain ;
7+
8+ @ Configuration
9+ public class SecurityConfiguration {
10+
11+ @ Bean
12+ public SecurityFilterChain filterChain (HttpSecurity http ) throws Exception {
13+ http .csrf ().disable ();
14+ return http .build ();
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments