diff --git a/src/main/java/com/mpnp/baechelin/BaechelinApplication.java b/src/main/java/com/mpnp/baechelin/BaechelinApplication.java index c4bf1fb..febcd57 100644 --- a/src/main/java/com/mpnp/baechelin/BaechelinApplication.java +++ b/src/main/java/com/mpnp/baechelin/BaechelinApplication.java @@ -2,19 +2,12 @@ import com.mpnp.baechelin.config.properties.AppProperties; import com.mpnp.baechelin.config.properties.CorsProperties; -import io.netty.channel.ChannelOption; -import io.netty.handler.timeout.ReadTimeoutHandler; -import io.netty.handler.timeout.WriteTimeoutHandler; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.*; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import reactor.netty.http.client.HttpClient; - -import java.time.Duration; -import java.util.concurrent.TimeUnit; @EnableJpaAuditing diff --git a/src/main/java/com/mpnp/baechelin/config/security/SecurityConfig.java b/src/main/java/com/mpnp/baechelin/config/security/SecurityConfig.java index 2d590a2..4081b84 100644 --- a/src/main/java/com/mpnp/baechelin/config/security/SecurityConfig.java +++ b/src/main/java/com/mpnp/baechelin/config/security/SecurityConfig.java @@ -2,16 +2,16 @@ import com.mpnp.baechelin.config.properties.AppProperties; import com.mpnp.baechelin.config.properties.CorsProperties; -import com.mpnp.baechelin.oauth.entity.RoleType; -import com.mpnp.baechelin.oauth.exception.RestAuthenticationEntryPoint; -import com.mpnp.baechelin.oauth.filter.TokenAuthenticationFilter; -import com.mpnp.baechelin.oauth.handler.OAuth2AuthenticationFailureHandler; -import com.mpnp.baechelin.oauth.handler.OAuth2AuthenticationSuccessHandler; -import com.mpnp.baechelin.oauth.handler.TokenAccessDeniedHandler; -import com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; -import com.mpnp.baechelin.oauth.service.CustomOAuth2UserService; -import com.mpnp.baechelin.oauth.token.AuthTokenProvider; -import com.mpnp.baechelin.user.repository.UserRefreshTokenRepository; +import com.mpnp.baechelin.login.oauth.entity.RoleType; +import com.mpnp.baechelin.login.jwt.exception.RestAuthenticationEntryPoint; +import com.mpnp.baechelin.login.jwt.filter.TokenAuthenticationFilter; +import com.mpnp.baechelin.login.oauth.handler.OAuth2AuthenticationFailureHandler; +import com.mpnp.baechelin.login.oauth.handler.OAuth2AuthenticationSuccessHandler; +import com.mpnp.baechelin.login.jwt.handler.TokenAccessDeniedHandler; +import com.mpnp.baechelin.login.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; +import com.mpnp.baechelin.login.oauth.service.CustomOAuth2UserService; +import com.mpnp.baechelin.login.jwt.AuthTokenProvider; +import com.mpnp.baechelin.login.jwt.repository.UserRefreshTokenRepository; import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/com/mpnp/baechelin/oauth/exception/ErrorCode.java b/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java similarity index 96% rename from src/main/java/com/mpnp/baechelin/oauth/exception/ErrorCode.java rename to src/main/java/com/mpnp/baechelin/exception/ErrorCode.java index 1978e3b..b655a97 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/exception/ErrorCode.java +++ b/src/main/java/com/mpnp/baechelin/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.exception; +package com.mpnp.baechelin.exception; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/mpnp/baechelin/oauth/token/AuthToken.java b/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java similarity index 96% rename from src/main/java/com/mpnp/baechelin/oauth/token/AuthToken.java rename to src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java index 8cdbc7e..79cb7ab 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/token/AuthToken.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/AuthToken.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.token; +package com.mpnp.baechelin.login.jwt; import io.jsonwebtoken.*; import io.jsonwebtoken.security.SignatureException; @@ -48,10 +48,7 @@ private String createAuthToken(String id, String role, Date expiry) { .compact(); } - public boolean validate() { - return this.getTokenClaims() != null; - } - + // 토큰 유효성 검사 public boolean tokenValidate() { Jws claimsJws = Jwts.parserBuilder() .setSigningKey(key) diff --git a/src/main/java/com/mpnp/baechelin/oauth/token/AuthTokenProvider.java b/src/main/java/com/mpnp/baechelin/login/jwt/AuthTokenProvider.java similarity index 94% rename from src/main/java/com/mpnp/baechelin/oauth/token/AuthTokenProvider.java rename to src/main/java/com/mpnp/baechelin/login/jwt/AuthTokenProvider.java index fcd4fca..68e31f4 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/token/AuthTokenProvider.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/AuthTokenProvider.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.token; +package com.mpnp.baechelin.login.jwt; -import com.mpnp.baechelin.oauth.exception.TokenValidFailedException; +import com.mpnp.baechelin.login.jwt.exception.TokenValidFailedException; import io.jsonwebtoken.Claims; import io.jsonwebtoken.security.Keys; import lombok.extern.slf4j.Slf4j; @@ -46,7 +46,7 @@ public AuthToken convertAuthToken(String token) { // 인증 객체 생성 public Authentication getAuthentication(AuthToken authToken) { // 유효한 토큰일 때 - if (authToken.validate()) { + if (authToken.tokenValidate()) { Claims claims = authToken.getTokenClaims(); Collection authorities = Arrays.stream(new String[] {claims.get(AUTHORITIES_KEY).toString()}) diff --git a/src/main/java/com/mpnp/baechelin/config/security/JwtConfig.java b/src/main/java/com/mpnp/baechelin/login/jwt/config/JwtConfig.java similarity index 82% rename from src/main/java/com/mpnp/baechelin/config/security/JwtConfig.java rename to src/main/java/com/mpnp/baechelin/login/jwt/config/JwtConfig.java index aa94eeb..696fc79 100644 --- a/src/main/java/com/mpnp/baechelin/config/security/JwtConfig.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/config/JwtConfig.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.config.security; +package com.mpnp.baechelin.login.jwt.config; -import com.mpnp.baechelin.oauth.token.AuthTokenProvider; +import com.mpnp.baechelin.login.jwt.AuthTokenProvider; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/src/main/java/com/mpnp/baechelin/oauth/controller/AuthController.java b/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java similarity index 69% rename from src/main/java/com/mpnp/baechelin/oauth/controller/AuthController.java rename to src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java index 70dc524..9dbe4ae 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/controller/AuthController.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/controller/TokenController.java @@ -1,7 +1,7 @@ -package com.mpnp.baechelin.oauth.controller; +package com.mpnp.baechelin.login.jwt.controller; -import com.mpnp.baechelin.oauth.common.AuthResponse; -import com.mpnp.baechelin.oauth.service.AuthService; +import com.mpnp.baechelin.login.oauth.common.AuthResponse; +import com.mpnp.baechelin.login.jwt.service.TokenService; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.GetMapping; @@ -14,13 +14,13 @@ @RestController @RequestMapping("/auth") @RequiredArgsConstructor -public class AuthController { +public class TokenController { - private final AuthService authService; + private final TokenService tokenService; @ApiOperation(value = "Access Token 만료 시 Refresh Token을 이용하여 재발급 받는 메소드") @GetMapping("/refresh") public AuthResponse refreshToken (HttpServletRequest request, HttpServletResponse response) { - return authService.refreshToken(request, response); + return tokenService.refreshToken(request, response); } } diff --git a/src/main/java/com/mpnp/baechelin/user/domain/UserRefreshToken.java b/src/main/java/com/mpnp/baechelin/login/jwt/entity/UserRefreshToken.java similarity index 93% rename from src/main/java/com/mpnp/baechelin/user/domain/UserRefreshToken.java rename to src/main/java/com/mpnp/baechelin/login/jwt/entity/UserRefreshToken.java index 59e5033..31871a8 100644 --- a/src/main/java/com/mpnp/baechelin/user/domain/UserRefreshToken.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/entity/UserRefreshToken.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.user.domain; +package com.mpnp.baechelin.login.jwt.entity; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Builder; diff --git a/src/main/java/com/mpnp/baechelin/oauth/exception/RestAuthenticationEntryPoint.java b/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java similarity index 95% rename from src/main/java/com/mpnp/baechelin/oauth/exception/RestAuthenticationEntryPoint.java rename to src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java index 8280b83..d96364c 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/exception/RestAuthenticationEntryPoint.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/exception/RestAuthenticationEntryPoint.java @@ -1,11 +1,11 @@ -package com.mpnp.baechelin.oauth.exception; +package com.mpnp.baechelin.login.jwt.exception; import com.google.gson.JsonObject; +import com.mpnp.baechelin.exception.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; -import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; diff --git a/src/main/java/com/mpnp/baechelin/oauth/exception/TokenValidFailedException.java b/src/main/java/com/mpnp/baechelin/login/jwt/exception/TokenValidFailedException.java similarity index 84% rename from src/main/java/com/mpnp/baechelin/oauth/exception/TokenValidFailedException.java rename to src/main/java/com/mpnp/baechelin/login/jwt/exception/TokenValidFailedException.java index b89aced..81a8798 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/exception/TokenValidFailedException.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/exception/TokenValidFailedException.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.exception; +package com.mpnp.baechelin.login.jwt.exception; public class TokenValidFailedException extends RuntimeException { diff --git a/src/main/java/com/mpnp/baechelin/oauth/filter/TokenAuthenticationFilter.java b/src/main/java/com/mpnp/baechelin/login/jwt/filter/TokenAuthenticationFilter.java similarity index 90% rename from src/main/java/com/mpnp/baechelin/oauth/filter/TokenAuthenticationFilter.java rename to src/main/java/com/mpnp/baechelin/login/jwt/filter/TokenAuthenticationFilter.java index 3b5100f..577dc79 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/filter/TokenAuthenticationFilter.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/filter/TokenAuthenticationFilter.java @@ -1,8 +1,8 @@ -package com.mpnp.baechelin.oauth.filter; +package com.mpnp.baechelin.login.jwt.filter; -import com.mpnp.baechelin.oauth.exception.ErrorCode; -import com.mpnp.baechelin.oauth.token.AuthToken; -import com.mpnp.baechelin.oauth.token.AuthTokenProvider; +import com.mpnp.baechelin.exception.ErrorCode; +import com.mpnp.baechelin.login.jwt.AuthToken; +import com.mpnp.baechelin.login.jwt.AuthTokenProvider; import com.mpnp.baechelin.util.HeaderUtil; import io.jsonwebtoken.ExpiredJwtException; import io.jsonwebtoken.MalformedJwtException; @@ -47,6 +47,7 @@ protected void doFilterInternal( // SecurityContextHolder 에 인증 객체를 넣는다. SecurityContextHolder.getContext().setAuthentication(authentication); } + // 에러가 발생했을 때, request에 attribute를 세팅하고 RestAuthenticationEntryPoint로 request를 넘겨준다. } catch (SignatureException e) { log.info("잘못된 JWT 서명입니다."); request.setAttribute("exception", ErrorCode.WRONG_TYPE_SIGNATURE.getCode()); diff --git a/src/main/java/com/mpnp/baechelin/oauth/handler/TokenAccessDeniedHandler.java b/src/main/java/com/mpnp/baechelin/login/jwt/handler/TokenAccessDeniedHandler.java similarity index 95% rename from src/main/java/com/mpnp/baechelin/oauth/handler/TokenAccessDeniedHandler.java rename to src/main/java/com/mpnp/baechelin/login/jwt/handler/TokenAccessDeniedHandler.java index 85f53f3..fa6e506 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/handler/TokenAccessDeniedHandler.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/handler/TokenAccessDeniedHandler.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.handler; +package com.mpnp.baechelin.login.jwt.handler; import lombok.RequiredArgsConstructor; import org.springframework.security.access.AccessDeniedException; diff --git a/src/main/java/com/mpnp/baechelin/user/repository/UserRefreshTokenRepository.java b/src/main/java/com/mpnp/baechelin/login/jwt/repository/UserRefreshTokenRepository.java similarity index 76% rename from src/main/java/com/mpnp/baechelin/user/repository/UserRefreshTokenRepository.java rename to src/main/java/com/mpnp/baechelin/login/jwt/repository/UserRefreshTokenRepository.java index 3ddf8d7..b2e67e0 100644 --- a/src/main/java/com/mpnp/baechelin/user/repository/UserRefreshTokenRepository.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/repository/UserRefreshTokenRepository.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.user.repository; +package com.mpnp.baechelin.login.jwt.repository; -import com.mpnp.baechelin.user.domain.UserRefreshToken; +import com.mpnp.baechelin.login.jwt.entity.UserRefreshToken; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/mpnp/baechelin/oauth/service/AuthService.java b/src/main/java/com/mpnp/baechelin/login/jwt/service/TokenService.java similarity index 87% rename from src/main/java/com/mpnp/baechelin/oauth/service/AuthService.java rename to src/main/java/com/mpnp/baechelin/login/jwt/service/TokenService.java index eff42ba..6590a89 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/service/AuthService.java +++ b/src/main/java/com/mpnp/baechelin/login/jwt/service/TokenService.java @@ -1,12 +1,12 @@ -package com.mpnp.baechelin.oauth.service; +package com.mpnp.baechelin.login.jwt.service; import com.mpnp.baechelin.config.properties.AppProperties; -import com.mpnp.baechelin.oauth.common.AuthResponse; -import com.mpnp.baechelin.oauth.entity.RoleType; -import com.mpnp.baechelin.oauth.token.AuthToken; -import com.mpnp.baechelin.oauth.token.AuthTokenProvider; -import com.mpnp.baechelin.user.domain.UserRefreshToken; -import com.mpnp.baechelin.user.repository.UserRefreshTokenRepository; +import com.mpnp.baechelin.login.oauth.common.AuthResponse; +import com.mpnp.baechelin.login.oauth.entity.RoleType; +import com.mpnp.baechelin.login.jwt.AuthToken; +import com.mpnp.baechelin.login.jwt.AuthTokenProvider; +import com.mpnp.baechelin.login.jwt.entity.UserRefreshToken; +import com.mpnp.baechelin.login.jwt.repository.UserRefreshTokenRepository; import com.mpnp.baechelin.util.CookieUtil; import com.mpnp.baechelin.util.HeaderUtil; import io.jsonwebtoken.Claims; @@ -24,7 +24,7 @@ @Service @RequiredArgsConstructor @Transactional -public class AuthService { +public class TokenService { private final AppProperties appProperties; private final AuthTokenProvider tokenProvider; @@ -55,7 +55,7 @@ public AuthResponse refreshToken(HttpServletRequest request, HttpServletResponse .orElse((null)); AuthToken authRefreshToken = tokenProvider.convertAuthToken(refreshToken); - if (!authRefreshToken.validate()) { + if (!authRefreshToken.tokenValidate()) { return AuthResponse.invalidRefreshToken(); } diff --git a/src/main/java/com/mpnp/baechelin/oauth/common/AuthResponse.java b/src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponse.java similarity index 94% rename from src/main/java/com/mpnp/baechelin/oauth/common/AuthResponse.java rename to src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponse.java index f8d6a7f..24b6324 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/common/AuthResponse.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponse.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.common; +package com.mpnp.baechelin.login.oauth.common; -import com.mpnp.baechelin.oauth.exception.ErrorCode; +import com.mpnp.baechelin.exception.ErrorCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/mpnp/baechelin/oauth/common/AuthResponseHeader.java b/src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponseHeader.java similarity index 68% rename from src/main/java/com/mpnp/baechelin/oauth/common/AuthResponseHeader.java rename to src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponseHeader.java index f5f775c..68612d8 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/common/AuthResponseHeader.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/common/AuthResponseHeader.java @@ -1,6 +1,5 @@ -package com.mpnp.baechelin.oauth.common; +package com.mpnp.baechelin.login.oauth.common; -import com.mpnp.baechelin.oauth.exception.ErrorCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/mpnp/baechelin/oauth/entity/ProviderType.java b/src/main/java/com/mpnp/baechelin/login/oauth/entity/ProviderType.java similarity index 69% rename from src/main/java/com/mpnp/baechelin/oauth/entity/ProviderType.java rename to src/main/java/com/mpnp/baechelin/login/oauth/entity/ProviderType.java index 9ba2724..675f2c8 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/entity/ProviderType.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/entity/ProviderType.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.entity; +package com.mpnp.baechelin.login.oauth.entity; import lombok.Getter; diff --git a/src/main/java/com/mpnp/baechelin/oauth/entity/RoleType.java b/src/main/java/com/mpnp/baechelin/login/oauth/entity/RoleType.java similarity index 93% rename from src/main/java/com/mpnp/baechelin/oauth/entity/RoleType.java rename to src/main/java/com/mpnp/baechelin/login/oauth/entity/RoleType.java index d5dccb0..ff4156c 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/entity/RoleType.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/entity/RoleType.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.entity; +package com.mpnp.baechelin.login.oauth.entity; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/mpnp/baechelin/oauth/entity/UserPrincipal.java b/src/main/java/com/mpnp/baechelin/login/oauth/entity/UserPrincipal.java similarity index 98% rename from src/main/java/com/mpnp/baechelin/oauth/entity/UserPrincipal.java rename to src/main/java/com/mpnp/baechelin/login/oauth/entity/UserPrincipal.java index 9a1deef..6ee2e0a 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/entity/UserPrincipal.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/entity/UserPrincipal.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.entity; +package com.mpnp.baechelin.login.oauth.entity; import com.mpnp.baechelin.user.domain.User; import lombok.*; diff --git a/src/main/java/com/mpnp/baechelin/oauth/exception/OAuthProviderMissMatchException.java b/src/main/java/com/mpnp/baechelin/login/oauth/exception/OAuthProviderMissMatchException.java similarity index 76% rename from src/main/java/com/mpnp/baechelin/oauth/exception/OAuthProviderMissMatchException.java rename to src/main/java/com/mpnp/baechelin/login/oauth/exception/OAuthProviderMissMatchException.java index cd6f880..74d29f5 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/exception/OAuthProviderMissMatchException.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/exception/OAuthProviderMissMatchException.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.exception; +package com.mpnp.baechelin.login.oauth.exception; public class OAuthProviderMissMatchException extends RuntimeException { diff --git a/src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationFailureHandler.java b/src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationFailureHandler.java similarity index 84% rename from src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationFailureHandler.java rename to src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationFailureHandler.java index 7864a07..57911f1 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationFailureHandler.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationFailureHandler.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.handler; +package com.mpnp.baechelin.login.oauth.handler; -import com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; +import com.mpnp.baechelin.login.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; import com.mpnp.baechelin.util.CookieUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.core.AuthenticationException; @@ -14,8 +14,6 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import static com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository.REDIRECT_URI_PARAM_COOKIE_NAME; - @Component @RequiredArgsConstructor public class OAuth2AuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler { @@ -32,7 +30,7 @@ public void onAuthenticationFailure( AuthenticationException exception) throws IOException, ServletException { // 리프레시 토큰을 저장한 쿠키에 들어있는 redirect uri를 가져온다. - String targetUrl = CookieUtil.getCookie(request, REDIRECT_URI_PARAM_COOKIE_NAME) + String targetUrl = CookieUtil.getCookie(request, OAuth2AuthorizationRequestBasedOnCookieRepository.REDIRECT_URI_PARAM_COOKIE_NAME) .map(Cookie::getValue) .orElse("/"); diff --git a/src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationSuccessHandler.java b/src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationSuccessHandler.java similarity index 88% rename from src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationSuccessHandler.java rename to src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationSuccessHandler.java index 84d8c6a..d521da7 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/handler/OAuth2AuthenticationSuccessHandler.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/handler/OAuth2AuthenticationSuccessHandler.java @@ -1,15 +1,15 @@ -package com.mpnp.baechelin.oauth.handler; +package com.mpnp.baechelin.login.oauth.handler; import com.mpnp.baechelin.config.properties.AppProperties; -import com.mpnp.baechelin.oauth.entity.ProviderType; -import com.mpnp.baechelin.oauth.entity.RoleType; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfo; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfoFactory; -import com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; -import com.mpnp.baechelin.oauth.token.AuthToken; -import com.mpnp.baechelin.oauth.token.AuthTokenProvider; -import com.mpnp.baechelin.user.domain.UserRefreshToken; -import com.mpnp.baechelin.user.repository.UserRefreshTokenRepository; +import com.mpnp.baechelin.login.oauth.entity.ProviderType; +import com.mpnp.baechelin.login.oauth.entity.RoleType; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfoFactory; +import com.mpnp.baechelin.login.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository; +import com.mpnp.baechelin.login.jwt.AuthToken; +import com.mpnp.baechelin.login.jwt.AuthTokenProvider; +import com.mpnp.baechelin.login.jwt.entity.UserRefreshToken; +import com.mpnp.baechelin.login.jwt.repository.UserRefreshTokenRepository; import com.mpnp.baechelin.util.CookieUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; @@ -29,8 +29,8 @@ import java.util.Date; import java.util.Optional; -import static com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository.REDIRECT_URI_PARAM_COOKIE_NAME; -import static com.mpnp.baechelin.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository.REFRESH_TOKEN; +import static com.mpnp.baechelin.login.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository.REDIRECT_URI_PARAM_COOKIE_NAME; +import static com.mpnp.baechelin.login.oauth.repository.OAuth2AuthorizationRequestBasedOnCookieRepository.REFRESH_TOKEN; // 로그인 성공 시 처리해주는 클래스 @Component diff --git a/src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfo.java b/src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfo.java similarity index 91% rename from src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfo.java rename to src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfo.java index 450d93c..bd32acc 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfo.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfo.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.info; +package com.mpnp.baechelin.login.oauth.info; import java.util.Map; diff --git a/src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfoFactory.java b/src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfoFactory.java similarity index 62% rename from src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfoFactory.java rename to src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfoFactory.java index ab01d64..8f30d52 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/info/OAuth2UserInfoFactory.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/info/OAuth2UserInfoFactory.java @@ -1,9 +1,9 @@ -package com.mpnp.baechelin.oauth.info; +package com.mpnp.baechelin.login.oauth.info; -import com.mpnp.baechelin.oauth.entity.ProviderType; -import com.mpnp.baechelin.oauth.info.impl.GoogleOAuth2UserInfo; -import com.mpnp.baechelin.oauth.info.impl.KakaoOAuth2UserInfo; -import com.mpnp.baechelin.oauth.info.impl.NaverOAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.entity.ProviderType; +import com.mpnp.baechelin.login.oauth.info.impl.GoogleOAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.impl.KakaoOAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.impl.NaverOAuth2UserInfo; import java.util.Map; diff --git a/src/main/java/com/mpnp/baechelin/oauth/info/impl/GoogleOAuth2UserInfo.java b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/GoogleOAuth2UserInfo.java similarity index 86% rename from src/main/java/com/mpnp/baechelin/oauth/info/impl/GoogleOAuth2UserInfo.java rename to src/main/java/com/mpnp/baechelin/login/oauth/info/impl/GoogleOAuth2UserInfo.java index b840bce..933293f 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/info/impl/GoogleOAuth2UserInfo.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/GoogleOAuth2UserInfo.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.info.impl; +package com.mpnp.baechelin.login.oauth.info.impl; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfo; import java.util.Map; diff --git a/src/main/java/com/mpnp/baechelin/oauth/info/impl/KakaoOAuth2UserInfo.java b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/KakaoOAuth2UserInfo.java similarity index 88% rename from src/main/java/com/mpnp/baechelin/oauth/info/impl/KakaoOAuth2UserInfo.java rename to src/main/java/com/mpnp/baechelin/login/oauth/info/impl/KakaoOAuth2UserInfo.java index 24149b7..fade7f2 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/info/impl/KakaoOAuth2UserInfo.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/KakaoOAuth2UserInfo.java @@ -1,7 +1,6 @@ -package com.mpnp.baechelin.oauth.info.impl; +package com.mpnp.baechelin.login.oauth.info.impl; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfo; import java.util.Map; diff --git a/src/main/java/com/mpnp/baechelin/oauth/info/impl/NaverOAuth2UserInfo.java b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/NaverOAuth2UserInfo.java similarity index 92% rename from src/main/java/com/mpnp/baechelin/oauth/info/impl/NaverOAuth2UserInfo.java rename to src/main/java/com/mpnp/baechelin/login/oauth/info/impl/NaverOAuth2UserInfo.java index 5529761..93254ca 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/info/impl/NaverOAuth2UserInfo.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/info/impl/NaverOAuth2UserInfo.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.info.impl; +package com.mpnp.baechelin.login.oauth.info.impl; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfo; import java.util.Map; diff --git a/src/main/java/com/mpnp/baechelin/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java b/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java similarity index 98% rename from src/main/java/com/mpnp/baechelin/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java rename to src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java index 22c1e2b..56034bf 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/repository/OAuth2AuthorizationRequestBasedOnCookieRepository.java @@ -1,4 +1,4 @@ -package com.mpnp.baechelin.oauth.repository; +package com.mpnp.baechelin.login.oauth.repository; import com.mpnp.baechelin.util.CookieUtil; diff --git a/src/main/java/com/mpnp/baechelin/oauth/service/CustomOAuth2UserService.java b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java similarity index 89% rename from src/main/java/com/mpnp/baechelin/oauth/service/CustomOAuth2UserService.java rename to src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java index bd45331..311affa 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/service/CustomOAuth2UserService.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomOAuth2UserService.java @@ -1,12 +1,12 @@ -package com.mpnp.baechelin.oauth.service; - -import com.mpnp.baechelin.oauth.entity.ProviderType; -import com.mpnp.baechelin.oauth.entity.RoleType; -import com.mpnp.baechelin.oauth.entity.UserPrincipal; -import com.mpnp.baechelin.oauth.exception.ErrorCode; -import com.mpnp.baechelin.oauth.exception.OAuthProviderMissMatchException; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfo; -import com.mpnp.baechelin.oauth.info.OAuth2UserInfoFactory; +package com.mpnp.baechelin.login.oauth.service; + +import com.mpnp.baechelin.login.oauth.entity.ProviderType; +import com.mpnp.baechelin.login.oauth.entity.RoleType; +import com.mpnp.baechelin.login.oauth.entity.UserPrincipal; +import com.mpnp.baechelin.login.oauth.exception.OAuthProviderMissMatchException; +import com.mpnp.baechelin.exception.ErrorCode; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfo; +import com.mpnp.baechelin.login.oauth.info.OAuth2UserInfoFactory; import com.mpnp.baechelin.user.domain.User; import com.mpnp.baechelin.user.repository.UserRepository; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/mpnp/baechelin/oauth/service/CustomUserDetailsService.java b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomUserDetailsService.java similarity index 89% rename from src/main/java/com/mpnp/baechelin/oauth/service/CustomUserDetailsService.java rename to src/main/java/com/mpnp/baechelin/login/oauth/service/CustomUserDetailsService.java index 39b27a4..d78b39e 100644 --- a/src/main/java/com/mpnp/baechelin/oauth/service/CustomUserDetailsService.java +++ b/src/main/java/com/mpnp/baechelin/login/oauth/service/CustomUserDetailsService.java @@ -1,6 +1,6 @@ -package com.mpnp.baechelin.oauth.service; +package com.mpnp.baechelin.login.oauth.service; -import com.mpnp.baechelin.oauth.entity.UserPrincipal; +import com.mpnp.baechelin.login.oauth.entity.UserPrincipal; import com.mpnp.baechelin.user.domain.User; import com.mpnp.baechelin.user.repository.UserRepository; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/mpnp/baechelin/user/controller/UserRestController.java b/src/main/java/com/mpnp/baechelin/user/controller/UserRestController.java index 6f08716..7e80be5 100644 --- a/src/main/java/com/mpnp/baechelin/user/controller/UserRestController.java +++ b/src/main/java/com/mpnp/baechelin/user/controller/UserRestController.java @@ -1,6 +1,6 @@ package com.mpnp.baechelin.user.controller; -import com.mpnp.baechelin.oauth.common.AuthResponse; +import com.mpnp.baechelin.login.oauth.common.AuthResponse; import com.mpnp.baechelin.user.domain.User; import com.mpnp.baechelin.user.service.UserService; import io.swagger.annotations.ApiOperation; diff --git a/src/main/java/com/mpnp/baechelin/user/domain/User.java b/src/main/java/com/mpnp/baechelin/user/domain/User.java index 9a64e71..b4a297e 100644 --- a/src/main/java/com/mpnp/baechelin/user/domain/User.java +++ b/src/main/java/com/mpnp/baechelin/user/domain/User.java @@ -3,8 +3,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.mpnp.baechelin.bookmark.domain.Bookmark; import com.mpnp.baechelin.bookmark.domain.Folder; -import com.mpnp.baechelin.oauth.entity.ProviderType; -import com.mpnp.baechelin.oauth.entity.RoleType; +import com.mpnp.baechelin.login.oauth.entity.ProviderType; +import com.mpnp.baechelin.login.oauth.entity.RoleType; import com.mpnp.baechelin.review.domain.Review; import com.mpnp.baechelin.util.TimeStamped; import lombok.Builder;