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

Refactor: Authentication 인증 유지 값 변경 #86

Merged
merged 1 commit into from
Aug 6, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class JwtAuthorizationFilter extends OncePerRequestFilter {
private static final String SESSION_PATH = "/v1/api/session";

private final JwtTokenProvider jwtTokenProvider;
private final MemberRepository memberRepository;

@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
Expand All @@ -49,14 +48,13 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse

private void setAuthentication(String accessToken) {
Long memberId = jwtTokenProvider.getMemberId(accessToken);
Member findMember = memberRepository.findById(memberId)
.orElseThrow(() -> new FilterAuthenticationException("해당 회원이 존재하지 않습니다."));
String role = jwtTokenProvider.getRole(accessToken);
log.info("[인증 필터 인증 진행, {}]", memberId);
log.info("Member Role: {}", role);

jwtTokenProvider.checkMemberExist(memberId);

Authentication authenticationToken = new UsernamePasswordAuthenticationToken(findMember.getEmail(), "",
Authentication authenticationToken = new UsernamePasswordAuthenticationToken(memberId, "",
List.of(new SimpleGrantedAuthority(role)));
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
}
Expand Down
Loading