Skip to content

Commit

Permalink
fix: Auth관련 코드 정리 (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
ah9mon authored Aug 3, 2023
1 parent e335211 commit c8a659e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public JwtAuthorizationFilter(AuthenticationManager authenticationManager, Membe
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
System.out.println("JwtAuthorizationFilter : 인증이나 권한이 필요한 주소 요청이 됨");

String jwtHeader = request.getHeader("Authorization");
String jwtHeader = request.getHeader(jwtConfig.getHeader());

// JWT 토큰을 검증을 해서 정상적인 사용자인지 확인
if (jwtHeader == null || !jwtHeader.startsWith("Bearer")) {
if (jwtHeader == null || !jwtHeader.startsWith(jwtConfig.getPrefix())) {
chain.doFilter(request, response); // 다시 필터 타게 넘김
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
System.out.println("OAuth2AuthenticationSuccessHandler : 로그인 성공");
OAuth2User oAuth2User = (OAuth2User) authentication.getPrincipal();

// RSA방식은 아니고 Hash 암호 방식
String jwtToken = JWT.create()
.withSubject("mokumoku")
.withExpiresAt(new Date(System.currentTimeMillis() + (1000 * 60 * 60 * 24)))
Expand All @@ -34,6 +33,5 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
.sign(Algorithm.HMAC512(jwtConfig.getKey()));
System.out.println("jwtToken = " + jwtToken);
response.addHeader(jwtConfig.getHeader(), jwtConfig.getPrefix() + " " + jwtToken);
// this.getSuccessHandler().onAuthenticationSuccess(request, response, authentication);
}
}

0 comments on commit c8a659e

Please sign in to comment.