-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#11] JWT 설정 #13
Conversation
// URL별 권한 설정 | ||
.authorizeHttpRequests(auth -> auth | ||
.requestMatchers("/h2-console/**").permitAll() | ||
.requestMatchers("/api/users/**").permitAll() |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
하나의 서비스가 서로 다른 서비스의 repository를 가지는 것에 대해서 멘토링 시간에 얘기해보죠. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코드는 깔끔할 것 같아요. 아이디어에 대해서 멘토링 시간에 얘기해보죠. :-)
JWT 설정