Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] #672 auth module 분리 #675

Merged
merged 6 commits into from
Mar 4, 2024
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
gg-pingpong-api/src/main/resources/application.yml
**/application.yml
.DS_Store
python
/logs
Expand Down
11 changes: 11 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,17 @@ project(':gg-pingpong-api') {
implementation project(':gg-repo')
implementation project(':gg-admin-repo')
implementation project(':gg-utils')
implementation project(':gg-auth')
}
}

project(':gg-auth') {
bootJar { enabled = false }
jar { enabled = true }
dependencies {
implementation project(':gg-data')
implementation project(':gg-repo')
implementation project(':gg-utils')
}
}

Expand Down
22 changes: 22 additions & 0 deletions gg-auth/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id 'java'
}

group 'gg.auth'
version '42gg'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'

implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.2'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.2'

annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"

testImplementation testFixtures(project(':gg-utils'))
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.user.user.dto;
package gg.auth;

import gg.data.user.User;
import gg.data.user.type.RacketType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils.argumentresolver;
package gg.auth.argumentresolver;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils.argumentresolver;
package gg.auth.argumentresolver;

import javax.servlet.http.HttpServletRequest;

Expand All @@ -8,10 +8,10 @@
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;

import gg.auth.UserDto;
import gg.auth.utils.AuthTokenProvider;
import gg.auth.utils.HeaderUtil;
import gg.data.user.User;
import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider;
import gg.pingpong.api.global.utils.HeaderUtil;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.repo.user.UserRepository;
import lombok.RequiredArgsConstructor;

Expand Down
24 changes: 24 additions & 0 deletions gg-auth/src/main/java/gg/auth/config/AuthWebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gg.auth.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import gg.auth.argumentresolver.LoginMemberArgumentResolver;
import gg.auth.utils.AuthTokenProvider;
import gg.repo.user.UserRepository;
import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
public class AuthWebConfig implements WebMvcConfigurer {
private final UserRepository userRepository;
private final AuthTokenProvider tokenProvider;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new LoginMemberArgumentResolver(userRepository, tokenProvider));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.security.config.properties;
package gg.auth.properties;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package gg.pingpong.api.global.security.jwt.utils;
package gg.auth.utils;

import java.security.Key;
import java.util.Date;

import org.springframework.stereotype.Component;

import gg.pingpong.api.global.security.config.properties.AppProperties;
import gg.auth.properties.AppProperties;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gg.pingpong.api.global.utils;
package gg.auth.utils;

import javax.servlet.http.HttpServletRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = {"gg.admin.repo", "gg.data", "gg.repo",
"gg.pingpong.api", "gg.utils", "gg.party.api"})
"gg.pingpong.api", "gg.utils", "gg.party.api", "gg.auth"})
public class PingpongApiApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.party.api.user.comment.controller.request.CommentCreateReqDto;
import gg.party.api.user.comment.service.CommentService;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import lombok.RequiredArgsConstructor;

@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.party.api.user.room.controller.request.RoomCreateReqDto;
import gg.party.api.user.room.controller.response.RoomDetailResDto;
import gg.party.api.user.room.controller.response.RoomListResDto;
import gg.party.api.user.room.service.RoomService;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import gg.auth.UserDto;
import gg.data.party.Category;
import gg.data.party.Room;
import gg.data.party.UserRoom;
Expand All @@ -24,7 +25,6 @@
import gg.party.api.user.room.controller.response.RoomListResDto;
import gg.party.api.user.room.controller.response.RoomResDto;
import gg.party.api.user.room.controller.response.UserRoomResDto;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.repo.party.CategoryRepository;
import gg.repo.party.CommentRepository;
import gg.repo.party.RoomRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import gg.admin.repo.noti.NotiAdminRepository;
import gg.admin.repo.user.UserAdminRepository;
import gg.auth.UserDto;
import gg.data.noti.Noti;
import gg.data.noti.type.NotiType;
import gg.data.user.User;
import gg.pingpong.api.admin.noti.controller.request.SendNotiAdminRequestDto;
import gg.pingpong.api.admin.noti.controller.response.NotiListAdminResponseDto;
import gg.pingpong.api.admin.noti.dto.NotiAdminDto;
import gg.pingpong.api.user.noti.service.SnsNotiService;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.utils.exception.user.UserNotFoundException;
import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto;
import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto;
import gg.pingpong.api.admin.store.service.CoinPolicyAdminService;
import gg.pingpong.api.global.dto.PageRequestDto;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto;
import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto;
import gg.pingpong.api.admin.store.service.ItemAdminService;
import gg.pingpong.api.global.dto.PageRequestDto;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.utils.exception.item.ItemImageLargeException;
import gg.utils.exception.item.ItemImageTypeException;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import gg.admin.repo.store.CoinPolicyAdminRepository;
import gg.admin.repo.user.UserAdminRepository;
import gg.auth.UserDto;
import gg.data.store.CoinPolicy;
import gg.data.user.User;
import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminListResponseDto;
import gg.pingpong.api.admin.store.controller.response.CoinPolicyAdminResponseDto;
import gg.pingpong.api.admin.store.dto.CoinPolicyAdminAddDto;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.utils.exception.user.UserNotFoundException;
import lombok.AllArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.springframework.web.multipart.MultipartFile;

import gg.admin.repo.store.ItemAdminRepository;
import gg.auth.UserDto;
import gg.data.store.Item;
import gg.pingpong.api.admin.store.controller.request.ItemUpdateRequestDto;
import gg.pingpong.api.admin.store.controller.response.ItemHistoryResponseDto;
import gg.pingpong.api.admin.store.controller.response.ItemListResponseDto;
import gg.pingpong.api.global.utils.aws.AsyncNewItemImageUploader;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.utils.exception.item.ItemNotAvailableException;
import gg.utils.exception.item.ItemNotFoundException;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
package gg.pingpong.api.global.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider;
import gg.pingpong.api.global.utils.argumentresolver.LoginMemberArgumentResolver;
import gg.pingpong.api.global.utils.querytracker.LoggingInterceptor;
import gg.repo.user.UserRepository;
import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
private final UserRepository userRepository;
private final AuthTokenProvider tokenProvider;
private final LoggingInterceptor loggingInterceptor;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new LoginMemberArgumentResolver(userRepository, tokenProvider));
}

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loggingInterceptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.util.UriComponentsBuilder;

import gg.auth.properties.AppProperties;
import gg.auth.utils.AuthTokenProvider;
import gg.data.user.User;
import gg.data.user.type.RoleType;
import gg.pingpong.api.global.security.UserPrincipal;
import gg.pingpong.api.global.security.config.properties.AppProperties;
import gg.pingpong.api.global.security.cookie.CookieUtil;
import gg.pingpong.api.global.security.jwt.repository.JwtRedisRepository;
import gg.pingpong.api.global.security.jwt.utils.AuthTokenProvider;
import gg.pingpong.api.global.security.jwt.utils.TokenHeaders;
import gg.pingpong.api.global.utils.ApplicationYmlRead;
import gg.repo.user.UserRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import gg.auth.utils.AuthTokenProvider;
import gg.auth.utils.HeaderUtil;
import gg.pingpong.api.global.security.service.CustomUserDetailsService;
import gg.pingpong.api.global.utils.HeaderUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.data.game.type.Mode;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.game.controller.request.GameListReqDto;
import gg.pingpong.api.user.game.controller.request.NormalGameListReqDto;
import gg.pingpong.api.user.game.controller.request.NormalResultReqDto;
Expand All @@ -30,7 +31,6 @@
import gg.pingpong.api.user.game.service.GameFindService;
import gg.pingpong.api.user.game.service.GameService;
import gg.pingpong.api.user.rank.redis.RankRedisService;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.utils.exception.ErrorCode;
import gg.utils.exception.custom.BusinessException;
import gg.utils.exception.custom.InvalidParameterException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.pingpong.api.user.manage.controller.request.FeedbackRequestDto;
import gg.pingpong.api.user.manage.service.FeedbackService;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.repo.user.UserRepository;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

import org.springframework.stereotype.Service;

import gg.auth.UserDto;
import gg.data.manage.Penalty;
import gg.data.manage.redis.RedisPenaltyUser;
import gg.data.manage.type.PenaltyType;
import gg.data.user.User;
import gg.pingpong.api.user.manage.redis.PenaltyUserRedisRepository;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.pingpong.api.user.user.service.UserFindService;
import gg.repo.manage.PenaltyRepository;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gg.auth.UserDto;
import gg.auth.argumentresolver.Login;
import gg.data.match.type.Option;
import gg.pingpong.api.global.utils.argumentresolver.Login;
import gg.pingpong.api.user.match.controller.request.MatchRequestDto;
import gg.pingpong.api.user.match.controller.response.MatchStatusResponseListDto;
import gg.pingpong.api.user.match.controller.response.SlotStatusResponseListDto;
import gg.pingpong.api.user.match.service.MatchFindService;
import gg.pingpong.api.user.match.service.MatchService;
import gg.pingpong.api.user.user.dto.UserDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.springframework.stereotype.Service;

import gg.auth.UserDto;
import gg.data.game.Game;
import gg.data.game.Team;
import gg.data.game.TeamUser;
Expand All @@ -14,7 +15,6 @@
import gg.pingpong.api.user.match.dto.GameAddDto;
import gg.pingpong.api.user.noti.service.NotiService;
import gg.pingpong.api.user.noti.service.SnsNotiService;
import gg.pingpong.api.user.user.dto.UserDto;
import gg.repo.game.GameRepository;
import gg.repo.game.TeamRepository;
import gg.repo.game.TeamUserRepository;
Expand Down
Loading
Loading