Skip to content

Commit

Permalink
Merge pull request #22 from GSM-MSG/21-verify-button-to-a-tag
Browse files Browse the repository at this point in the history
🔀 :: 인증 버튼 태그 변경
  • Loading branch information
baekteun authored Sep 21, 2022
2 parents 8e3fb2d + 81856c6 commit 4ac4fa3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.ir.backend.js.compile

plugins {
id("org.springframework.boot") version "2.7.3"
Expand Down Expand Up @@ -31,11 +32,13 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("io.jsonwebtoken:jjwt-gson:0.11.5")
implementation("io.jsonwebtoken:jjwt-api:0.11.5")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
runtimeOnly("com.h2database:h2")
runtimeOnly("mysql:mysql-connector-java")
runtimeOnly("io.jsonwebtoken:jjwt-impl:0.11.5")
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import com.msg.gauth.domain.auth.services.LogoutService
import com.msg.gauth.domain.auth.services.RefreshService
import com.msg.gauth.domain.auth.services.SignUpService
import com.msg.gauth.domain.auth.services.SignInService
import com.msg.gauth.global.annotation.logger.log4k
import org.slf4j.Logger
import org.springframework.http.HttpStatus
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
Expand All @@ -21,7 +23,6 @@ class AuthController(
private val signInService: SignInService,
private val signUpService: SignUpService
) {

@PatchMapping
fun refresh(@RequestHeader("RefreshToken") refreshToken: String): ResponseEntity<RefreshResponseDto> =
ResponseEntity.ok(refreshService.execute(refreshToken))
Expand All @@ -36,6 +37,7 @@ class AuthController(
fun signin(@Valid @RequestBody signinRequestDto: SigninRequestDto): ResponseEntity<SigninResponseDto> =
ResponseEntity.ok(signInService.execute(signinRequestDto))


@PostMapping("/signup")
fun signUpMember(@Valid @RequestBody signUpDto: SignUpDto): ResponseEntity<Void> {
signUpService.execute(signUpDto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import com.msg.gauth.domain.auth.repository.RefreshTokenRepository
import com.msg.gauth.domain.user.User
import com.msg.gauth.domain.user.exception.UserNotFoundException
import com.msg.gauth.domain.user.repository.UserRepository
import com.msg.gauth.global.annotation.logger.log4k
import com.msg.gauth.global.security.jwt.JwtTokenProvider
import org.slf4j.Logger
import org.springframework.security.crypto.password.PasswordEncoder
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import kotlin.math.log

@Service
class SignInService(
Expand All @@ -20,6 +23,7 @@ class SignInService(
private val refreshTokenRepository: RefreshTokenRepository,
private val passwordEncoder: PasswordEncoder
) {

@Transactional
fun execute(dto: SigninRequestDto): SigninResponseDto {
val user: User = userRepository.findByEmail(dto.email) ?: throw UserNotFoundException()
Expand All @@ -30,7 +34,6 @@ class SignInService(
val refresh = jwtTokenProvider.generateRefreshToken(dto.email)
val expiresAt = jwtTokenProvider.accessExpiredTime
refreshTokenRepository.save(RefreshToken(user.id, refresh, JwtTokenProvider.REFRESH_EXP))

return SigninResponseDto(access, refresh, expiresAt)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MailSendService(
try {
val message = mailSender.createMimeMessage()
val msg =
"<form action=\"http://localhost:8080/email/authentication?email=$email&uuid=$value\"><input type=\"submit\" value=\"인증하기\" style=\"padding: 10px; border: none; color: white; background-color: skyblue; border-radius: 8px; align-self: center; text-align: center;\" /></form>"
"<a href=\"http://localhost:8080/email/authentication?email=$email&uuid=$value\" style=\"padding: 10px; border: none; color: white; background-color: skyblue; border-radius: 8px; align-self: center; text-align: center;\">인증하기</a>"
message.addRecipients(Message.RecipientType.TO, emailSendDto.email)
message.subject = "[Gauth] 이메일 인증"
message.setText(msg, "utf-8", "html")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package com.msg.gauth.global.security.filter
import com.msg.gauth.global.security.jwt.JwtTokenProvider
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.web.filter.OncePerRequestFilter
import java.io.IOException
import javax.servlet.FilterChain
import javax.servlet.ServletException
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.msg.gauth.global.security.jwt
import io.jsonwebtoken.security.Keys
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.ConstructorBinding
import java.nio.charset.StandardCharsets
import java.security.Key

@ConstructorBinding
Expand All @@ -15,7 +16,7 @@ class JwtProperties(
val refreshSecret: Key

init {
this.accessSecret = Keys.hmacShaKeyFor(accessSecret.toByteArray())
this.refreshSecret = Keys.hmacShaKeyFor(refreshSecret.toByteArray())
this.accessSecret = Keys.hmacShaKeyFor(accessSecret.toByteArray(StandardCharsets.UTF_8))
this.refreshSecret = Keys.hmacShaKeyFor(refreshSecret.toByteArray(StandardCharsets.UTF_8))
}
}

0 comments on commit 4ac4fa3

Please sign in to comment.