Skip to content

Commit

Permalink
style: auth javaDocs 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
masiljangajji committed Mar 26, 2024
1 parent b27606b commit 8fb6ce1
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
23 changes: 23 additions & 0 deletions src/main/java/store/mybooks/front/auth/adaptor/TokenAdaptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public class TokenAdaptor {

private final GatewayAdaptorProperties gatewayAdaptorProperties;

/**
* methodName : createToken
* author : masiljangajji
* description : jwt 생성요청을 보냄
*
* @param tokenCreateRequest 유저의 정보를 담은 dto , 이것을 기반으로 JWT 생성
* @return token create response
*/
public TokenCreateResponse createToken(TokenCreateRequest tokenCreateRequest) {

ResponseEntity<TokenCreateResponse> responseEntity =
Expand All @@ -50,6 +58,14 @@ public TokenCreateResponse createToken(TokenCreateRequest tokenCreateRequest) {
return responseEntity.getBody();
}

/**
* methodName : refreshAccessToken
* author : masiljangajji
* description : 엑세스토큰 재발급 요청을 보냄
*
* @param refreshTokenRequest accessToken , ip , X-User-Agent 정보
* @return refresh token response
*/
public RefreshTokenResponse refreshAccessToken(RefreshTokenRequest refreshTokenRequest) {

ResponseEntity<RefreshTokenResponse> responseEntity =
Expand All @@ -65,6 +81,13 @@ public RefreshTokenResponse refreshAccessToken(RefreshTokenRequest refreshTokenR
return responseEntity.getBody();
}

/**
* methodName : deleteRefreshToken
* author : masiljangajji
* description : 로그아웃시 리프래시토큰 삭제 요청을 보냄
*
* @param logoutRequest 엑세스토큰 , ip , X-User-Agent
*/
public void deleteRefreshToken(LogoutRequest logoutRequest){

ResponseEntity<Void> responseEntity =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class AdminCookieAspect {

private final RedisAuthService redisAuthService;

/**
* methodName : beforeMethod
* author : masiljangajji
* description : 어드민 페이지에 접근시 RequiredAdminCookie 어노테이션이 있는 경우 , adminCookie 를 확인 및 검증하는 인가처리
*/
@Before("@annotation(store.mybooks.front.auth.Annotation.RequiredAdminCookie)")
public void beforeMethod() {
HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ public class AuthorizationAspect {

private final RedisProperties redisProperties;

/**
* methodName : aroundMethod
* author : masiljangajji
* description : RequiredAuthorization 어노테이션이 걸려있는 경우 , 회원의 인가처리가 필요하다는 것을 의미
* identity-cookie 라는 이름의 쿠키에 JWT 를 담고 있기 떄문에 Header 에 토큰으 담아서 gateway 로 보냄
* gateway 에서 토큰 검증 및 유저 검증 인가처리에 문제가 없을 시 그대로 return
* Exception 이 발생한다면 (토큰 검증 실패 , 토큰만료 , 일반 유저가 어드민이 사용하는 기능접근 ,유저 휴면상태 , 유저 잠금상태) ErrorMessage 를 이용해
* 각각의 상황에 맞는 처리를 함
*
* @param joinPoint point
* @return object
* @throws Throwable the throwable
*/
@Around(value = "@annotation(store.mybooks.front.auth.Annotation.RequiredAuthorization)")
public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,

// UUID - UserId 담은 redis 삭제 및 admin 쿠키 삭제
if (Objects.nonNull(request.getAttribute("admin_cookie_value"))) {
log.warn("어드민쿠키 삭제 시작 ");
log.debug("어드민쿠키 삭제 시작 ");
RedisAuthService redisAuthService = context.getBean(RedisAuthService.class);
redisAuthService.deleteValues((String) request.getAttribute("admin_cookie_value"));
log.warn("레디스 삭제");
log.debug("레디스 삭제");
CookieUtils.deleteAdminCookie(response);
log.warn("어드민쿠키 삭제 완료");
log.debug("어드민쿠키 삭제 완료");
}


Expand Down

0 comments on commit 8fb6ce1

Please sign in to comment.