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

[#11] JWT 설정 #13

Merged
merged 7 commits into from
Jan 9, 2025
Merged

[#11] JWT 설정 #13

merged 7 commits into from
Jan 9, 2025

Conversation

austinhong22
Copy link
Collaborator

JWT 설정

  • JWT 인증 구현
  • 회원가입 로직 구현
  • 로그인, 유저 조회 로직 구현
  • 테스트코드 작성

@austinhong22 austinhong22 self-assigned this Jan 7, 2025
// URL별 권한 설정
.authorizeHttpRequests(auth -> auth
.requestMatchers("/h2-console/**").permitAll()
.requestMatchers("/api/users/**").permitAll()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이렇게 하면, get users할때도 토큰이 필요없는거 아닐까요?


@Component
public class JwtTokenProvider {
@Value("${jwt.secret-key}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Refresh Token 생성
public String generateRefreshToken(String email) {
Date now = new Date();
Date expiry = new Date(now.getTime() + refreshTokenValidity * 1000);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refresh token의 만료시간이랑 access token의 만료시간이 같으면, refresh를 못하지 않을까요? access token으로 통신하다가 access token이 만료되면, refresh token을 써서 갱신하는 방식일 것 같은데요 ...


public TokenResponseDto() {}

public TokenResponseDto(String accessToken, String refreshToken) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

생성자가 두 개 다 필요한 이유는 무엇일까요?

}

public TokenResponseDto refreshAccessToken(String refreshToken) {
JwtToken stored = jwtTokenRepository.findByToken(refreshToken)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 .... refreshtoken을 저장해야하는 이유는 무엇인가요?


@Service
public class JwtService {
private final UserRepository userRepository;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

하나의 서비스가 서로 다른 서비스의 repository를 가지는 것에 대해서 멘토링 시간에 얘기해보죠. :-)

Copy link

@f-lab-lyan f-lab-lyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코드는 깔끔할 것 같아요. 아이디어에 대해서 멘토링 시간에 얘기해보죠. :-)

@austinhong22 austinhong22 merged commit be315c2 into develop Jan 9, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants