-
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
#15,16 - Security 설정, 회원가입 개발 #34
Conversation
- email, password, role, socialEmail 추가
- 인증과 권한 부여를 위해 사용자 정보를 캡슐화
유저와 연결 끊도록 설정
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.
양이 진짜 많네요ㅋㅋㅋㅋ 고생했어요! 아무래도 기한이 기한인 만큼 코멘트 간단하게 남겼습니다. 한번 봐주시면 감사할 것 같아요
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/auth") |
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.
자기야 이거 api 그냥 넣을까요?
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.
아 ㅋㅋ 저거 안뺐네요,, 편한대로?!
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.
일단 빼시죵!
val response = authService.socialAccess(request) | ||
|
||
return if (response is SignUpResponse) { | ||
ResponseEntity.status(HttpStatus.ACCEPTED).body(response) |
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.
이거는 아직 사용자가 소셜로그인만 하고 회원가입을 안한 상태인가요?
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.
네 맞아요 이 이후에 회원가입 진행하게돼요!
fun signIn( | ||
@RequestBody request: AuthLoginRequest | ||
): Any { | ||
|
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.
자기야 Function 내부에는 위, 아래 공백 안두어도 괜찮을 것 같아요!
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.
위 아래 공백은, 지금 작업하시기에는 시간이 걸리니, 차차 제거해나가도록 하시죠!
private val validUrlPatterns = listOf( | ||
"/health", | ||
"/", | ||
"/api/v1/auth/reissue", | ||
"/api/v1/auth/login", | ||
"/api/v1/auth/signup", | ||
"/api/v1/auth/revoke", | ||
) |
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.
앞으로 여기다가 url 추가하면 되겠네요?
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.
네 맞아요 근데 이것도 조금 불편할 것 같기도 해서 개선해보는거 나중에 시도해볼게요!
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.
네네!
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.
뭔가 메타데이터 가져와서 하는 방법이 있을 것 같은데
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.
아니면 리플렉션으로도 가능할 것 같기도 하고오옹
private fun handleInvalidUrl( | ||
request: HttpServletRequest, | ||
response: HttpServletResponse | ||
) { | ||
|
||
response.contentType = MediaType.APPLICATION_JSON_VALUE | ||
response.characterEncoding = UTF_8.name() | ||
response.status = HttpStatus.NOT_FOUND.value() | ||
|
||
val body = objectMapper.writeValueAsString( | ||
ProblemDetail.forStatusAndDetail( | ||
HttpStatus.NOT_FOUND, | ||
NoSuchFieldException("잘못된 URL입니다.").message!!, | ||
).apply { | ||
type = URI.create("/errors/not-found") | ||
instance = URI.create(request.requestURI) | ||
} | ||
) | ||
|
||
response.writer.write(body) | ||
|
||
} | ||
} |
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.
키야 좋네요 👍
fun withdraw() = | ||
User( | ||
id = id, | ||
email = "", | ||
password = "", | ||
name = "", | ||
introduction = "", | ||
role = Role.GUEST, | ||
schoolId = schoolId, | ||
grade = grade, | ||
groupNumber = groupNumber, | ||
profile = profile, | ||
fcm = fcm, | ||
setting = setting, | ||
social = Social( | ||
socialEmail = "", | ||
socialId = "", | ||
socialType = social.socialType, | ||
socialRefreshToken = "" | ||
), | ||
userConsent = userConsent, | ||
createdAt = createdAt, | ||
updatedAt = LocalDateTime.now(), | ||
withdrawAt = LocalDateTime.now(), | ||
) |
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.
기가 막히는군요
override fun findByUserId(userId: Long): RefreshToken? { | ||
return refreshTokenJpaRepository.findByUserId(userId) | ||
?.let { RefreshTokenMapper.mapToDomainEntity(it) } | ||
} |
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.
조회만 있는 부분은 Transactional 야무지게 빼주셨네요 👍
override fun deleteByUserId(userId: Long) { | ||
refreshTokenJpaRepository.deleteByUserId(userId) | ||
} |
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.
요거는 Transactional 붙여줘야 하지 않을까요?
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.
빼먹었네요..!! 추가하겠습니다!
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.
알러뷰
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.
Transactional 추가해주시면 감사할 것 같아요!
if (findByRefreshToken != null) { | ||
return RefreshTokenMapper.mapToDomainEntity(findByRefreshToken) | ||
} |
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.
얼리 리턴 좋습니다.
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.PERSIST]) | ||
@JoinColumn(name = "profile_id", foreignKey = ForeignKey(name = "fk_users_profile_id")) | ||
val profile: ProfileJpaEntity, | ||
|
||
@field: NotNull | ||
val groupNumber: Int, | ||
@OneToOne(fetch = FetchType.LAZY, cascade = [CascadeType.PERSIST]) | ||
@JoinColumn(name = "fcm_id", foreignKey = ForeignKey(name = "fk_users_fcm_id")) | ||
val fcm: FCMJpaEntity, |
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.
이거 안지웠네요?!
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.
rebase하다가 안지웠나봐요 ㅋㅋ.. 그래서 지웠습니다.
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.
ㅋㅋㅋㅋ 알러뷰
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.
아직 안지워진 것 같은데!! 내가 잘못보고 있는건가요?!
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.
기천 자기야 고생했어요. 너무 많네 우리 작업
1. 🔗 관련 이슈
2. 📄 구현한 내용 또는 수정한 내용
3. 🙌 추가적으로 알리고 싶은 내용
jwt yml 값 추가되었습니다
지금 수정 후 VoteServiceTest 에서 에러가 나고 있더라고요.. 아마 User 쪽이 변경되어서 그런것같기도 한데 제가 수정하기에는 양이 많아서, 재연님이 나중에 한번 봐주면 좋을 것 같아요!
(테스트 실패가 나고 있음)
4. 🙄 TODO / 고민하고 있는 것들
아직 AuthService 테스트 코드를 작성하지 않았는데, 추후 작성 후 PR 새로 올릴게요!ㅜㅜ
(재연님 테스트 코드 잘 보고 배우고 있습니다 ㅎㅎ)
5. ✅ 배포 Checklist