File tree Expand file tree Collapse file tree
src/main/java/com/creepereye/ecommerce Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,18 +66,28 @@ public ResponseEntity<?> logout(@RequestHeader("Authorization") String accessTok
6666 @ PostMapping ("/refresh" )
6767 public ResponseEntity <TokenResponse > refresh (@ CookieValue ("refreshToken" ) String refreshToken ) {
6868
69+
6970 TokenResponse tokenResponse = authService .refresh (refreshToken );
7071
7172
72- ResponseCookie refreshCookie = ResponseCookie .from ("refreshToken" , tokenResponse .getRefreshToken ())
73+ ResponseCookie deleteCookie = ResponseCookie .from ("refreshToken" , "" )
74+ .httpOnly (true )
75+ .secure (true )
76+ .sameSite ("Lax" )
77+ .maxAge (0 )
78+ .build ();
79+
80+
81+ ResponseCookie newRefreshCookie = ResponseCookie .from ("refreshToken" , tokenResponse .getRefreshToken ())
7382 .httpOnly (true )
7483 .secure (true )
7584 .sameSite ("Lax" )
7685 .maxAge (refreshTokenValidityInSeconds )
7786 .build ();
7887
7988 return ResponseEntity .ok ()
80- .header (HttpHeaders .SET_COOKIE , refreshCookie .toString ())
89+ .header (HttpHeaders .SET_COOKIE , deleteCookie .toString ())
90+ .header (HttpHeaders .SET_COOKIE , newRefreshCookie .toString ())
8191 .body (tokenResponse );
8292 }
8393
Original file line number Diff line number Diff line change @@ -49,15 +49,32 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
4949 http
5050 .cors (cors -> cors .configurationSource (corsConfigurationSource ()))
5151 .authorizeHttpRequests (authorize -> authorize
52- .requestMatchers ("/h2-console/**" ).permitAll ()
52+
53+
5354 .requestMatchers ("/actuator/prometheus/**" ).permitAll ()
55+
56+
5457 .requestMatchers ("/api/v1/auth/login" , "/api/v2/auth/login" ).permitAll ()
5558 .requestMatchers ("/api/v1/auth/signup" , "/api/v2/auth/signup" ).permitAll ()
56- . requestMatchers ( "/api/v1/auth/signup-admin" , "/api/v2/auth/signup-admin" ). permitAll ()
59+
5760 .requestMatchers ("/api/v1/auth/logout" , "/api/v2/auth/logout" ).authenticated ()
58- .requestMatchers ("/api/v1/orders/**" ).authenticated ()
5961 .requestMatchers ("/api/v1/auth/refresh" , "/api/v2/auth/refresh" ).permitAll ()
62+
63+
64+ .requestMatchers ("/api/v1/orders/**" ).authenticated ()
65+
6066 .requestMatchers ("/api/v1/products/**" ,"/api/v2/products/**" ).permitAll ()
67+
68+ .requestMatchers ("/api/v2/co-purchase/**" ,"/api/v1/co-purchase/**" ).permitAll ()
69+
70+ .requestMatchers (
71+ "/swagger-ui/**" ,
72+ "/v3/api-docs/**" ,
73+ "/swagger-resources/**" ,
74+ "/webjars/**"
75+ ).permitAll ()
76+
77+
6178 .anyRequest ().authenticated ()
6279 )
6380 .csrf (AbstractHttpConfigurer ::disable )
You can’t perform that action at this time.
0 commit comments