Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.DecodEat.domain.RefreshToken.service;
package com.DecodEat.domain.refreshToken.service;


import static com.DecodEat.global.apiPayload.code.status.ErrorStatus.*;
Expand All @@ -10,14 +10,15 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;


import java.time.Duration;

@RequiredArgsConstructor
@Service
public class TokenService {

private final JwtTokenProvider jwtTokenProvider;
private final RefreshTokenService refreshTokenService;
private final com.DecodEat.domain.RefreshToken.service.RefreshTokenService refreshTokenService;
private final UserService userService;

public String createNewAccessToken(String refreshToken){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
import com.DecodEat.global.config.oauth.OAuth2SuccessHandler;
import com.DecodEat.global.config.oauth.OAuth2UserCustomService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.client.TokenExchangeOAuth2AuthorizedClientProvider;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.HttpStatusEntryPoint;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.beans.factory.annotation.Value;

@RequiredArgsConstructor
@Configuration
Expand All @@ -31,6 +29,8 @@ public class WebOAuthSecurityConfig {
private final RefreshTokenRepository refreshTokenRepository;
private final UserService userService;
private final CorsConfigurationSource corsConfigurationSource; // CorsCongifuragtinoSource Bean 주입 위함
@Value("${spring.security.oauth2.client.registration.kakao.client-id}")
private String kakaoClientId;

// @Bean
// public WebSecurityCustomizer configure() {
Expand Down Expand Up @@ -77,6 +77,15 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
.defaultAuthenticationEntryPointFor(
new HttpStatusEntryPoint(HttpStatus.UNAUTHORIZED),
new AntPathRequestMatcher("/api/**")));
// 7. 로그아웃
http.logout(logout -> logout
.logoutUrl("/api/logout")
// 👇 카카오 로그아웃 URL로 리다이렉트
.logoutSuccessUrl("https://kauth.kakao.com/oauth/logout?client_id=" + kakaoClientId + "&logout_redirect_uri=https://decodeat.store.app/")
.invalidateHttpSession(true)
.deleteCookies("JSESSIONID")
.clearAuthentication(true)
);

return http.build();
}
Expand Down
Loading