-
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.
refactor: @AuthAdmin, @AuthMember 어노테이션 값 설정하는 로직 변경 (#72)
- Loading branch information
1 parent
be0f871
commit 47bfd1d
Showing
12 changed files
with
99 additions
and
27 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
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/atwoz/admin/ui/auth/interceptor/ParseAdminIdFromTokenInterceptor.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,29 @@ | ||
package com.atwoz.admin.ui.auth.interceptor; | ||
|
||
import com.atwoz.admin.ui.auth.support.AdminAuthenticationContext; | ||
import com.atwoz.admin.ui.auth.support.AdminAuthenticationExtractor; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class ParseAdminIdFromTokenInterceptor implements HandlerInterceptor { | ||
|
||
private final AdminLoginValidCheckerInterceptor loginValidCheckerInterceptor; | ||
private final AdminAuthenticationContext adminAuthenticationContext; | ||
|
||
@Override | ||
public boolean preHandle(final HttpServletRequest request, | ||
final HttpServletResponse response, | ||
final Object handler) throws Exception { | ||
if (AdminAuthenticationExtractor.extractFromRequest(request).isEmpty()) { | ||
adminAuthenticationContext.setAnonymous(); | ||
return true; | ||
} | ||
|
||
return loginValidCheckerInterceptor.preHandle(request, response, handler); | ||
} | ||
} |
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
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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/atwoz/member/ui/auth/interceptor/ParseMemberIdFromTokenInterceptor.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,29 @@ | ||
package com.atwoz.member.ui.auth.interceptor; | ||
|
||
import com.atwoz.member.ui.auth.support.MemberAuthenticationContext; | ||
import com.atwoz.member.ui.auth.support.MemberAuthenticationExtractor; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.HandlerInterceptor; | ||
|
||
@RequiredArgsConstructor | ||
@Component | ||
public class ParseMemberIdFromTokenInterceptor implements HandlerInterceptor { | ||
|
||
private final MemberLoginValidCheckerInterceptor memberLoginValidCheckerInterceptor; | ||
private final MemberAuthenticationContext memberAuthenticationContext; | ||
|
||
@Override | ||
public boolean preHandle(final HttpServletRequest request, | ||
final HttpServletResponse response, | ||
final Object handler) throws Exception { | ||
if (MemberAuthenticationExtractor.extractFromRequest(request).isEmpty()) { | ||
memberAuthenticationContext.setAnonymous(); | ||
return true; | ||
} | ||
|
||
return memberLoginValidCheckerInterceptor.preHandle(request, response, handler); | ||
} | ||
} |
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
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