-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from f-lab-edu/feature/64-logincheck
[#64] 로그인 AOP/Argument Resolver 추가
- Loading branch information
Showing
37 changed files
with
489 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
## ModooSpace | ||
스터디룸, 회의실, 연습실, 파티룸, 스튜디오 등 모든 공간을 시간단위로 대여할 수 있는 공간 대여 플랫폼입니다. | ||
> ❗️ 단 호스트의 승인이 있어야 사용이 가능합니다. | ||
### 프로젝트 목표 | ||
- 국내 [SpaceCloud](https://www.spacecloud.kr/)를 모티브로 공간대여 플랫폼을 구현하였습니다. | ||
- 비즈니스 로직을 객체에게 최대한 위임하여 Service Layer에서 객체가 서로 협력하여 요청을 수행할 수 있도록 아키텍처를 구성하였습니다. | ||
- 해당 프로젝트에서는 Mock없는 테스트를 지향하며 Domain 단위테스트, Service 통합테스트를 수행하여 TestCoverage 80%를 달성하였습니다. | ||
- 단순 기능만 구현한 것이 아닌, 성능 테스트를 통해 높은 트래픽을 가정한 상황에서도 안정적인 서비스를 유지할 수 있도록 지속적으로 서버 구조를 개선 중입니다. | ||
|
||
### 사용 기술 | ||
<img width="637" alt="스크린샷 2024-03-27 오전 12 19 02" src="https://github.com/f-lab-edu/modoospace/assets/48192141/94b581e1-0863-49af-8ea8-bc3f80a29807"> | ||
|
||
### ERD 구조 | ||
<img width="1002" alt="스크린샷 2024-03-26 오후 11 10 16" src="https://github.com/f-lab-edu/modoospace/assets/48192141/8acd7fe9-b624-4081-8a2e-45a54f28831d"> | ||
|
||
### 1차 서버 아키텍처 | ||
![image](https://github.com/f-lab-edu/modoospace/assets/48192141/b8b63d8c-a09b-492f-a825-cd5b981d34e4) | ||
|
||
### 주요 기술 Issue | ||
- [CI/CD를 구축해보자1 - NCP서버 생성 및 Docker로 어플리케이션 배포하기](https://velog.io/@gjwjdghk123/CI-CD1) | ||
- [CI/CD를 구축해보자2 - JaCoCo와 GitHub Actions으로 CI/CD구축해보기](https://velog.io/@gjwjdghk123/CI-CD2) | ||
- [ObjectOptimisticLockingFailureException과 고아객체(Orphan) 그리고 한방 쿼리](https://velog.io/@gjwjdghk123/ObjectOptimisticLockingFailureException) | ||
- [nGrinder를 이용한 성능 테스트 및 성능 개선(ElasticSearch, Redis)](https://velog.io/@gjwjdghk123/nGrinder%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EC%84%B1%EB%8A%A5-%ED%85%8C%EC%8A%A4%ED%8A%B8-%EB%B0%8F-%EC%84%B1%EB%8A%A5-%EA%B0%9C%EC%84%A0ElasticSearch-Redis) | ||
- [ElasticSearch TimeOutException 해결과정](https://velog.io/@gjwjdghk123/ElasticSearch-TimeOutException-%ED%95%B4%EA%B2%B0%EA%B3%BC%EC%A0%95) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
package com.modoospace; | ||
|
||
import com.modoospace.config.auth.LoginEmail; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
import javax.servlet.http.HttpSession; | ||
|
||
@RequiredArgsConstructor | ||
@Controller | ||
public class MainController { | ||
|
||
@GetMapping({"", "/"}) | ||
public String index(Model model, @LoginEmail String loginEmail) { | ||
if (loginEmail != null) { | ||
model.addAttribute("userName", loginEmail); | ||
@GetMapping({"", "/"}) | ||
public String index(Model model, HttpSession session) { | ||
String email = (String) session.getAttribute("member"); | ||
if (email != null) { | ||
model.addAttribute("userName", email); | ||
} | ||
return "index"; | ||
} | ||
return "index"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/java/com/modoospace/common/exception/UnAuthenticatedException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.modoospace.common.exception; | ||
|
||
public class UnAuthenticatedException extends RuntimeException { | ||
|
||
private static final String MESSAGE = "로그인이 필요합니다."; | ||
|
||
public UnAuthenticatedException() { | ||
super(MESSAGE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
src/main/java/com/modoospace/config/auth/LoginEmailArgumentResolver.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/modoospace/config/auth/aop/CheckLogin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.modoospace.config.auth.aop; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ElementType.METHOD, ElementType.TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface CheckLogin { | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/com/modoospace/config/auth/aop/CheckLoginAspect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.modoospace.config.auth.aop; | ||
|
||
import com.modoospace.common.exception.UnAuthenticatedException; | ||
import lombok.RequiredArgsConstructor; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.aspectj.lang.annotation.Before; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.client.HttpClientErrorException; | ||
|
||
import javax.servlet.http.HttpSession; | ||
|
||
@Component | ||
@Aspect | ||
@RequiredArgsConstructor | ||
public class CheckLoginAspect { | ||
|
||
private final HttpSession httpSession; | ||
|
||
@Before("@annotation(com.modoospace.config.auth.aop.CheckLogin)") | ||
public void checkLogin() throws HttpClientErrorException { | ||
|
||
String email = (String) httpSession.getAttribute("member"); | ||
|
||
if (email == null) { | ||
throw new UnAuthenticatedException(); | ||
} | ||
} | ||
} |
19 changes: 0 additions & 19 deletions
19
src/main/java/com/modoospace/config/auth/dto/SessionMember.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/modoospace/config/auth/resolver/LoginMemberArgumentResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.modoospace.config.auth.resolver; | ||
|
||
import com.modoospace.common.exception.UnAuthenticatedException; | ||
import com.modoospace.member.domain.Member; | ||
import com.modoospace.member.service.MemberService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
import javax.servlet.http.HttpSession; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class LoginMemberArgumentResolver implements HandlerMethodArgumentResolver { | ||
|
||
private final HttpSession httpSession; | ||
private final MemberService memberService; | ||
|
||
/** | ||
* 컨트롤러 메서드의 특정 파라미터를 지원하는지 판단 | ||
*/ | ||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.hasParameterAnnotation(LoginMember.class) && parameter.getParameterType().equals(Member.class); | ||
} | ||
|
||
/** | ||
* 파라미터에 전달할 객체 생성 | ||
*/ | ||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
try { | ||
String email = (String) httpSession.getAttribute("member"); | ||
return memberService.findMemberByEmail(email); | ||
} catch (RuntimeException e) { | ||
throw new UnAuthenticatedException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.