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

#15,16 - Security 설정, 회원가입 개발 #34

Merged
merged 34 commits into from
Jul 17, 2024

Conversation

sectionr0
Copy link
Contributor

@sectionr0 sectionr0 commented Jul 16, 2024

1. 🔗 관련 이슈

2. 📄 구현한 내용 또는 수정한 내용

  • Spring Security 설정
  • JWT 개발
  • 회원가입 개발
  • Redis 모듈 추가

3. 🙌 추가적으로 알리고 싶은 내용

  • jwt yml 값 추가되었습니다

  • 지금 수정 후 VoteServiceTest 에서 에러가 나고 있더라고요.. 아마 User 쪽이 변경되어서 그런것같기도 한데 제가 수정하기에는 양이 많아서, 재연님이 나중에 한번 봐주면 좋을 것 같아요!
    (테스트 실패가 나고 있음)

4. 🙄 TODO / 고민하고 있는 것들

아직 AuthService 테스트 코드를 작성하지 않았는데, 추후 작성 후 PR 새로 올릴게요!ㅜㅜ
(재연님 테스트 코드 잘 보고 배우고 있습니다 ㅎㅎ)

5. ✅ 배포 Checklist

  • SecretKey 를 업데이트 해주세요
  • 본인을 Assign 해주세요.
  • 본인을 제외한 백엔드 개발자를 리뷰어로 지정해주세요.

@sectionr0 sectionr0 self-assigned this Jul 16, 2024
@sectionr0 sectionr0 requested review from kpeel5839 July 16, 2024 16:22
@sectionr0 sectionr0 added the 🌱기능🌱 새로운 기능을 추가해요 ! label Jul 16, 2024
@sectionr0 sectionr0 added 🔥리뷰 기다리는 중🔥 PR을 올리고 코드리뷰를 기다리고 있는 상태입니다. 🥭망고🥭 24기 조기천 labels Jul 16, 2024
Copy link
Contributor

@kpeel5839 kpeel5839 left a 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")
Copy link
Contributor

Choose a reason for hiding this comment

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

자기야 이거 api 그냥 넣을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아 ㅋㅋ 저거 안뺐네요,, 편한대로?!

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

이거는 아직 사용자가 소셜로그인만 하고 회원가입을 안한 상태인가요?

Copy link
Contributor Author

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 {

Copy link
Contributor

Choose a reason for hiding this comment

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

자기야 Function 내부에는 위, 아래 공백 안두어도 괜찮을 것 같아요!

Copy link
Contributor

Choose a reason for hiding this comment

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

위 아래 공백은, 지금 작업하시기에는 시간이 걸리니, 차차 제거해나가도록 하시죠!

Comment on lines +23 to +30
private val validUrlPatterns = listOf(
"/health",
"/",
"/api/v1/auth/reissue",
"/api/v1/auth/login",
"/api/v1/auth/signup",
"/api/v1/auth/revoke",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

앞으로 여기다가 url 추가하면 되겠네요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 맞아요 근데 이것도 조금 불편할 것 같기도 해서 개선해보는거 나중에 시도해볼게요!

Copy link
Contributor

Choose a reason for hiding this comment

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

네네!

Copy link
Contributor

Choose a reason for hiding this comment

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

뭔가 메타데이터 가져와서 하는 방법이 있을 것 같은데

Copy link
Contributor

Choose a reason for hiding this comment

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

아니면 리플렉션으로도 가능할 것 같기도 하고오옹

Comment on lines +54 to +76
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)

}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

키야 좋네요 👍

Comment on lines +25 to +49
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(),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

기가 막히는군요

Comment on lines +20 to +23
override fun findByUserId(userId: Long): RefreshToken? {
return refreshTokenJpaRepository.findByUserId(userId)
?.let { RefreshTokenMapper.mapToDomainEntity(it) }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

조회만 있는 부분은 Transactional 야무지게 빼주셨네요 👍

Comment on lines +37 to +39
override fun deleteByUserId(userId: Long) {
refreshTokenJpaRepository.deleteByUserId(userId)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

요거는 Transactional 붙여줘야 하지 않을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

빼먹었네요..!! 추가하겠습니다!

Copy link
Contributor

Choose a reason for hiding this comment

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

알러뷰

Copy link
Contributor

Choose a reason for hiding this comment

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

Transactional 추가해주시면 감사할 것 같아요!

Comment on lines +43 to +45
if (findByRefreshToken != null) {
return RefreshTokenMapper.mapToDomainEntity(findByRefreshToken)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

얼리 리턴 좋습니다.

Comment on lines +34 to +40
@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,
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 안지웠네요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rebase하다가 안지웠나봐요 ㅋㅋ.. 그래서 지웠습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋ 알러뷰

Copy link
Contributor

Choose a reason for hiding this comment

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

아직 안지워진 것 같은데!! 내가 잘못보고 있는건가요?!

Copy link
Contributor

@kpeel5839 kpeel5839 left a comment

Choose a reason for hiding this comment

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

기천 자기야 고생했어요. 너무 많네 우리 작업

@github-actions github-actions bot added the 🌟머지 해주세요🌟 머지해주셔! label Jul 17, 2024
@sectionr0 sectionr0 merged commit b0983e5 into develop Jul 17, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌟머지 해주세요🌟 머지해주셔! 🌱기능🌱 새로운 기능을 추가해요 ! 🔥리뷰 기다리는 중🔥 PR을 올리고 코드리뷰를 기다리고 있는 상태입니다. 🥭망고🥭 24기 조기천
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants