diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..a92d929e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = false +tab_width = 4 + +[*.kt] +ij_kotlin_packages_to_use_import_on_demand = unset +ij_kotlin_allow_trailing_comma = false +ij_kotlin_allow_trailing_comma_on_call_site = false \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index abe3f0c7..72a102a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,12 +4,14 @@ plugins { id("org.springframework.boot") version PluginVersion.SPRING_BOOT_VERSION id("io.spring.dependency-management") version PluginVersion.DEPENDENCY_MANAGER_VERSION id("com.ewerk.gradle.plugins.querydsl") version PluginVersion.QUERY_DSL_PLUGIN_VERSION + id("org.jlleitschuh.gradle.ktlint") version "10.2.0" kotlin("jvm") version PluginVersion.JVM_VERSION kotlin("plugin.spring") version PluginVersion.SPRING_PLUGIN_VERSION kotlin("plugin.jpa") version PluginVersion.JPA_PLUGIN_VERSION kotlin("kapt") version PluginVersion.KAPT_VERSION idea + application } group = "com.msg" @@ -78,7 +80,6 @@ dependencies { implementation(Dependencies.PROMETHEUS_MICROMETER) } - tasks.withType { kotlinOptions { freeCompilerArgs = listOf("-Xjsr305=strict") @@ -97,3 +98,18 @@ idea { tasks.withType { useJUnitPlatform() } + +application { + mainClass.set("com.msg.gauth.GauthBackendApplicationKt") +} + +ktlint { + verbose.set(true) + android.set(false) + outputToConsole.set(true) + coloredOutput.set(false) + ignoreFailures.set(false) + enableExperimentalRules.set(false) + + disabledRules.set(setOf("no-wildcard-imports", "import-ordering")) +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index fc10a5d8..f9c4f232 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "gauth" +rootProject.name = "gauth" \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/GauthBackendApplication.kt b/src/main/kotlin/com/msg/gauth/GauthBackendApplication.kt index 6c5d65ea..d41a7aa1 100644 --- a/src/main/kotlin/com/msg/gauth/GauthBackendApplication.kt +++ b/src/main/kotlin/com/msg/gauth/GauthBackendApplication.kt @@ -12,4 +12,4 @@ class GauthBackendApplication fun main(args: Array) { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul")) runApplication(*args) -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/admin/service/ExcelParsingService.kt b/src/main/kotlin/com/msg/gauth/domain/admin/service/ExcelParsingService.kt index 49644b79..f680c033 100644 --- a/src/main/kotlin/com/msg/gauth/domain/admin/service/ExcelParsingService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/admin/service/ExcelParsingService.kt @@ -20,12 +20,12 @@ class ExcelParsingService( private val userRepository: UserRepository, ) { - fun execute(file: MultipartFile){ + fun execute(file: MultipartFile) { val tika = Tika() val detect = tika.detect(file.bytes) val extension = FileNameUtils.getExtension(file.originalFilename) - if(!ExcelUtil.isExcel(detect, extension)) + if (!ExcelUtil.isExcel(detect, extension)) throw FileExtensionInvalidException() val workBook: Workbook = @@ -34,10 +34,10 @@ class ExcelParsingService( else HSSFWorkbook(file.inputStream) - val workSheet:Sheet = workBook.getSheetAt(0) + val workSheet: Sheet = workBook.getSheetAt(0) val map = hashMapOf() - for(i in 1 until workSheet.physicalNumberOfRows){ + for (i in 1 until workSheet.physicalNumberOfRows) { val row = workSheet.getRow(i) val email = row.getCell(4).stringCellValue diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/handler/AuthEventHandler.kt b/src/main/kotlin/com/msg/gauth/domain/auth/handler/AuthEventHandler.kt index e751eaa4..ef12d34c 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/handler/AuthEventHandler.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/handler/AuthEventHandler.kt @@ -10,8 +10,6 @@ import org.springframework.http.HttpEntity import org.springframework.http.HttpHeaders import org.springframework.http.MediaType import org.springframework.stereotype.Component -import org.springframework.transaction.event.TransactionPhase -import org.springframework.transaction.event.TransactionalEventListener import org.springframework.web.client.RestTemplate @Component @@ -51,4 +49,4 @@ class AuthEventHandler( val entity = HttpEntity(jsonObject.toString(), headers) restTemplate.postForObject(discordProperties.url, entity, String::class.java) } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/presentation/AuthController.kt b/src/main/kotlin/com/msg/gauth/domain/auth/presentation/AuthController.kt index 56c033c9..b4a83bf5 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/presentation/AuthController.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/presentation/AuthController.kt @@ -66,7 +66,6 @@ class AuthController( return ResponseEntity.ok(result) } - @PatchMapping("/password/initialize") fun initPassword(@Valid @RequestBody initPasswordRequestDto: InitPasswordRequestDto): ResponseEntity { initPasswordService.execute(initPasswordRequestDto) @@ -84,5 +83,4 @@ class AuthController( signUpEmailVerificationService.execute(email) return ResponseEntity.ok().build() } - } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/presentation/dto/request/SignUpV2RequestDto.kt b/src/main/kotlin/com/msg/gauth/domain/auth/presentation/dto/request/SignUpV2RequestDto.kt index e41f7c8a..72c79c31 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/presentation/dto/request/SignUpV2RequestDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/presentation/dto/request/SignUpV2RequestDto.kt @@ -4,7 +4,7 @@ import javax.validation.constraints.NotBlank import javax.validation.constraints.NotNull import javax.validation.constraints.Pattern -data class SignUpV2RequestDto ( +data class SignUpV2RequestDto( @field:NotBlank @field:Pattern(regexp = "^[a-zA-Z0-9.]+@gsm.hs.kr$") val email: String, diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt b/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt index 488e267a..d185cc88 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/repository/RefreshTokenRepository.kt @@ -4,6 +4,6 @@ import com.msg.gauth.global.util.count.auth.RefreshToken import org.springframework.data.repository.CrudRepository interface RefreshTokenRepository : CrudRepository { - + fun findByToken(token: String): RefreshToken? } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/service/InitPasswordService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/service/InitPasswordService.kt index a6f11e54..ee944079 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/service/InitPasswordService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/service/InitPasswordService.kt @@ -20,7 +20,7 @@ class InitPasswordService( val emailAuth = emailAuthRepository.findByIdOrNull(initPasswordRequestDto.email) ?: throw EmailNotVerifiedException() - if(!emailAuth.authentication) + if (!emailAuth.authentication) throw EmailNotVerifiedException() val user = userRepository.findByEmail(initPasswordRequestDto.email) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/service/RefreshService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/service/RefreshService.kt index 781e4ee7..8e0f0e04 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/service/RefreshService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/service/RefreshService.kt @@ -28,7 +28,8 @@ class RefreshService( throw InvalidRefreshTokenException() val (access, refresh) = jwtTokenProvider.run { - generateAccessToken(email) to generateRefreshToken(email)} + generateAccessToken(email) to generateRefreshToken(email) + } val newRefreshToken = RefreshToken( userId = existingRefreshToken.userId, diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignInService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignInService.kt index c8a61e38..e34540b5 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignInService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignInService.kt @@ -38,7 +38,7 @@ class SignInService( throw PasswordMismatchException() } - if(user.state == UserState.PENDING) + if (user.state == UserState.PENDING) throw UserIsPendingException() tempUserUtil.resetWrongPasswordCount(user) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpImageUploadService.kt b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpImageUploadService.kt index a815da52..efa86960 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpImageUploadService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpImageUploadService.kt @@ -18,10 +18,10 @@ class SignUpImageUploadService( val emailAuth = emailAuthRepository.findByIdOrNull(email) ?: throw AuthCodeExpiredException() - if(!emailAuth.authentication) + if (!emailAuth.authentication) throw AuthCodeNotVerificationException() - if(previousUrl != null) + if (previousUrl != null) s3Util.deleteImage(previousUrl) return SignUpImageResDto(s3Util.imageUpload(image)) diff --git a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpMemberV2Service.kt b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpMemberV2Service.kt index e761faea..b11841cb 100644 --- a/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpMemberV2Service.kt +++ b/src/main/kotlin/com/msg/gauth/domain/auth/service/SignUpMemberV2Service.kt @@ -23,7 +23,7 @@ class SignUpMemberV2Service( ) { fun execute(signUpV2RequestDto: SignUpV2RequestDto) { - if(userRepository.existsByEmail(signUpV2RequestDto.email)) + if (userRepository.existsByEmail(signUpV2RequestDto.email)) throw DuplicateEmailException() if (userRepository.existsByGradeAndClassNumAndNum(signUpV2RequestDto.grade, signUpV2RequestDto.classNum, signUpV2RequestDto.num)) diff --git a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/request/ClientUpdateReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/request/ClientUpdateReqDto.kt index 8c3bb4dd..c303218b 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/request/ClientUpdateReqDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/request/ClientUpdateReqDto.kt @@ -18,7 +18,7 @@ data class ClientUpdateReqDto( @Enumerated(EnumType.STRING) val serviceScope: ServiceScope = ServiceScope.PUBLIC, - + val serviceImgUrl: String = "" ) { diff --git a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientDetailResDto.kt b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientDetailResDto.kt index 52a440cc..759022fd 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientDetailResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientDetailResDto.kt @@ -14,7 +14,7 @@ data class ClientDetailResDto( val serviceImgUrl: String ) { - constructor(client: Client): this( + constructor(client: Client) : this( id = client.id, clientId = client.clientId, clientSecret = client.clientSecret, diff --git a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientRegisterResDto.kt b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientRegisterResDto.kt index 9df48573..5d022447 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientRegisterResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientRegisterResDto.kt @@ -14,7 +14,7 @@ data class ClientRegisterResDto( val serviceImgUrl: String ) { - constructor(client: Client): this( + constructor(client: Client) : this( id = client.id, clientId = client.clientId, clientSecret = client.clientSecret, diff --git a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientResDto.kt b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientResDto.kt index 663c91b4..0db87d84 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/ClientResDto.kt @@ -12,7 +12,7 @@ data class ClientResDto( val serviceImgUrl: String ) { - constructor(client: Client): this( + constructor(client: Client) : this( clientId = client.id, serviceName = client.serviceName, serviceUri = client.serviceUri, diff --git a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/SingleClientResDto.kt b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/SingleClientResDto.kt index bb01962b..ec999642 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/SingleClientResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/presentation/dto/response/SingleClientResDto.kt @@ -12,7 +12,7 @@ data class SingleClientResDto( val serviceImgUrl: String ) { - constructor(client: Client): this( + constructor(client: Client) : this( id = client.id, clientId = client.clientId, serviceName = client.serviceName, diff --git a/src/main/kotlin/com/msg/gauth/domain/client/repository/ClientRepository.kt b/src/main/kotlin/com/msg/gauth/domain/client/repository/ClientRepository.kt index 1c3bdeba..32ab2774 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/repository/ClientRepository.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/repository/ClientRepository.kt @@ -6,7 +6,6 @@ import com.msg.gauth.domain.user.User import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.data.jpa.repository.Query import java.util.* interface ClientRepository : JpaRepository, CustomClientRepository { diff --git a/src/main/kotlin/com/msg/gauth/domain/client/repository/CustomClientRepositoryImpl.kt b/src/main/kotlin/com/msg/gauth/domain/client/repository/CustomClientRepositoryImpl.kt index c818d067..401bcfbd 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/repository/CustomClientRepositoryImpl.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/repository/CustomClientRepositoryImpl.kt @@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository @Repository class CustomClientRepositoryImpl( private val jpaQueryFactory: JPAQueryFactory -): CustomClientRepository { +) : CustomClientRepository { override fun deleteAllByIdsAndCreatedBy(ids: List, createdBy: User) { jpaQueryFactory.delete(client) diff --git a/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt b/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt index dd31e1e1..3e66c3a4 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/service/DelegateOwnerService.kt @@ -24,7 +24,7 @@ class DelegateOwnerService( val user = userUtil.fetchCurrentUser() if (delegateUserId == user.id) - throw BadDelegateUserIdRequestException() + throw BadDelegateUserIdRequestException() val client = clientRepository.findByIdOrNull(clientId) ?: throw ClientNotFindException() diff --git a/src/main/kotlin/com/msg/gauth/domain/client/service/DeleteClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/service/DeleteClientService.kt index 5d562991..d3f402f1 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/service/DeleteClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/service/DeleteClientService.kt @@ -13,11 +13,11 @@ class DeleteClientService( private val userUtil: UserUtil, ) { - fun execute(id: Long){ + fun execute(id: Long) { val client = clientRepository.findByIdOrNull(id) ?: throw ClientNotFindException() - if(client.createdBy != userUtil.fetchCurrentUser()) + if (client.createdBy != userUtil.fetchCurrentUser()) throw UserNotMatchException() clientRepository.delete(client) diff --git a/src/main/kotlin/com/msg/gauth/domain/client/service/UpdateClientService.kt b/src/main/kotlin/com/msg/gauth/domain/client/service/UpdateClientService.kt index 35451058..4046eac1 100644 --- a/src/main/kotlin/com/msg/gauth/domain/client/service/UpdateClientService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/client/service/UpdateClientService.kt @@ -12,7 +12,7 @@ class UpdateClientService( private val userUtil: UserUtil ) { - fun updateClient(id: Long, clientUpdateReqDto: ClientUpdateReqDto){ + fun updateClient(id: Long, clientUpdateReqDto: ClientUpdateReqDto) { val client = clientRepository.findByIdAndCreatedBy(id, userUtil.fetchCurrentUser()) ?: throw ClientNotFindException() diff --git a/src/main/kotlin/com/msg/gauth/domain/email/EmailAuthEntity.kt b/src/main/kotlin/com/msg/gauth/domain/email/EmailAuthEntity.kt index 1a50bca3..50345edf 100644 --- a/src/main/kotlin/com/msg/gauth/domain/email/EmailAuthEntity.kt +++ b/src/main/kotlin/com/msg/gauth/domain/email/EmailAuthEntity.kt @@ -1,6 +1,5 @@ package com.msg.gauth.domain.email -import org.hibernate.annotations.ColumnDefault import org.hibernate.validator.constraints.Length import org.springframework.data.annotation.Id import org.springframework.data.redis.core.RedisHash @@ -30,7 +29,7 @@ class EmailAuthEntity( return EmailAuthEntity( email = this.email, authentication = this.authentication, - attemptCount = this.attemptCount+1, + attemptCount = this.attemptCount + 1, randomValue = uuid, ) } diff --git a/src/main/kotlin/com/msg/gauth/domain/email/presentation/EmailController.kt b/src/main/kotlin/com/msg/gauth/domain/email/presentation/EmailController.kt index db3dabdd..407e71cf 100644 --- a/src/main/kotlin/com/msg/gauth/domain/email/presentation/EmailController.kt +++ b/src/main/kotlin/com/msg/gauth/domain/email/presentation/EmailController.kt @@ -33,5 +33,4 @@ class EmailController( checkMailVerificationService.execute(email) return ResponseEntity.ok().build() } - } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/email/service/CheckMailVerificationService.kt b/src/main/kotlin/com/msg/gauth/domain/email/service/CheckMailVerificationService.kt index 2ac75487..8370bb83 100644 --- a/src/main/kotlin/com/msg/gauth/domain/email/service/CheckMailVerificationService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/email/service/CheckMailVerificationService.kt @@ -14,7 +14,7 @@ class CheckMailVerificationService( val authEntity = emailAuthRepository.findByIdOrNull(email) ?: throw AuthCodeNotVerificationException() - if(!authEntity.authentication) + if (!authEntity.authentication) throw AuthCodeNotVerificationException() } } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/email/service/SendMailService.kt b/src/main/kotlin/com/msg/gauth/domain/email/service/SendMailService.kt index edbe4cb0..6c535438 100644 --- a/src/main/kotlin/com/msg/gauth/domain/email/service/SendMailService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/email/service/SendMailService.kt @@ -35,7 +35,7 @@ class SendMailService( attemptCount = 0 ) - if(authEntity.authentication) + if (authEntity.authentication) throw AlreadyAuthenticatedEmailException() if (authEntity.attemptCount >= 5) @@ -65,7 +65,7 @@ class SendMailService( private fun createMailTemplate(email: String, code: String): String { val context = Context() - val url = "https://port-0-gauth-backend-85phb42bluutn9a7.sel5.cloudtype.app/email/authentication?email=${email}&uuid=${code}" + val url = "https://port-0-gauth-backend-85phb42bluutn9a7.sel5.cloudtype.app/email/authentication?email=$email&uuid=$code" context.setVariables( mapOf( diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/exception/UserStatePendingException.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/exception/UserStatePendingException.kt index 4f11ec65..79ad93e2 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/exception/UserStatePendingException.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/exception/UserStatePendingException.kt @@ -3,6 +3,6 @@ package com.msg.gauth.domain.oauth.exception import com.msg.gauth.global.exception.ErrorCode import com.msg.gauth.global.exception.exceptions.BasicException -class UserStatePendingException: BasicException( +class UserStatePendingException : BasicException( ErrorCode.USER_STATE_PENDING ) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/OauthController.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/OauthController.kt index 25ca6478..c204fc30 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/OauthController.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/OauthController.kt @@ -23,7 +23,7 @@ class OauthController( ) { @PostMapping("/code") - fun generateOauthCode(@Valid @RequestBody oauthCodeRequestDto : OauthCodeRequestDto): ResponseEntity { + fun generateOauthCode(@Valid @RequestBody oauthCodeRequestDto: OauthCodeRequestDto): ResponseEntity { val result = generateOauthCodeService.execute(oauthCodeRequestDto) return ResponseEntity.ok(result) } diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/dto/request/OauthLoginReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/dto/request/OauthLoginReqDto.kt index cff2274f..862af9a0 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/dto/request/OauthLoginReqDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/presentation/dto/request/OauthLoginReqDto.kt @@ -13,4 +13,4 @@ data class OauthLoginReqDto( @field:NotBlank val password: String -) +) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthCodeService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthCodeService.kt index 67365ceb..a6004093 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthCodeService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthCodeService.kt @@ -39,7 +39,7 @@ class GenerateOauthCodeService( throw PasswordMismatchException() } - if(user.state == UserState.PENDING) + if (user.state == UserState.PENDING) throw UserStatePendingException() tempUserUtil.resetOAuthWrongPasswordCount(user) @@ -58,7 +58,7 @@ class GenerateOauthCodeService( tempUserUtil.isUserBan(user) tooManyOAuthRequestValidUtil.validRequest(user.email) - if(user.state == UserState.PENDING) + if (user.state == UserState.PENDING) throw UserStatePendingException() val code = UUID.randomUUID().toString().split(".")[0] diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthTokenService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthTokenService.kt index a09e40a5..bed38993 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthTokenService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GenerateOauthTokenService.kt @@ -26,11 +26,13 @@ class GenerateOauthTokenService( private val oauthCodeRepository: OauthCodeRepository ) { - fun execute(oauthTokenRequestDto: OauthTokenRequestDto): OauthTokenResponseDto{ - val client = (clientRepository.findByClientIdAndRedirectUri(oauthTokenRequestDto.clientId, oauthTokenRequestDto.redirectUri) - ?: throw ClientNotFindException()) + fun execute(oauthTokenRequestDto: OauthTokenRequestDto): OauthTokenResponseDto { + val client = ( + clientRepository.findByClientIdAndRedirectUri(oauthTokenRequestDto.clientId, oauthTokenRequestDto.redirectUri) + ?: throw ClientNotFindException() + ) - if(client.clientSecret != oauthTokenRequestDto.clientSecret) + if (client.clientSecret != oauthTokenRequestDto.clientSecret) throw ClientSecretMismatchException() val oauthCode = oauthCodeRepository.findByIdOrNull(oauthTokenRequestDto.code) @@ -40,8 +42,10 @@ class GenerateOauthTokenService( oauthCodeRepository.delete(oauthCode) - val user = (userRepository.findByEmail(email) - ?: throw UserNotFoundException()) + val user = ( + userRepository.findByEmail(email) + ?: throw UserNotFoundException() + ) return tokenResponseDto(email, client, user) } diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GetServiceNameService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GetServiceNameService.kt index 1797d003..80e2a2b0 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/service/GetServiceNameService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/service/GetServiceNameService.kt @@ -11,8 +11,10 @@ class GetServiceNameService( ) { fun execute(clientId: String): ServiceNameResponseDto { - val client = (clientRepository.findByClientId(clientId) - ?: throw ClientNotFindException()) + val client = ( + clientRepository.findByClientId(clientId) + ?: throw ClientNotFindException() + ) return ServiceNameResponseDto( client.serviceName diff --git a/src/main/kotlin/com/msg/gauth/domain/oauth/service/RefreshOauthTokenService.kt b/src/main/kotlin/com/msg/gauth/domain/oauth/service/RefreshOauthTokenService.kt index f4d58d3a..aad8b694 100644 --- a/src/main/kotlin/com/msg/gauth/domain/oauth/service/RefreshOauthTokenService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/oauth/service/RefreshOauthTokenService.kt @@ -19,7 +19,7 @@ class RefreshOauthTokenService( private val tokenParser: TokenParser ) { - fun execute(requestToken: String): OauthTokenResponseDto{ + fun execute(requestToken: String): OauthTokenResponseDto { val refreshToken = tokenParser.parseToken(requestToken) ?: throw InvalidRefreshTokenException() diff --git a/src/main/kotlin/com/msg/gauth/domain/user/User.kt b/src/main/kotlin/com/msg/gauth/domain/user/User.kt index b51a35ae..f1f2b24d 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/User.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/User.kt @@ -45,4 +45,4 @@ class User( val oauthWrongPasswordCount: Int = 0 -) : BaseIdEntity(id) +) : BaseIdEntity(id) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/enums/UserRoleType.kt b/src/main/kotlin/com/msg/gauth/domain/user/enums/UserRoleType.kt index c5f9c29f..89d2bf3f 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/enums/UserRoleType.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/enums/UserRoleType.kt @@ -7,4 +7,4 @@ enum class UserRoleType : GrantedAuthority { override fun getAuthority(): String = name -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt index cbd1526f..c9b6f683 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/UserController.kt @@ -8,7 +8,6 @@ import com.msg.gauth.domain.user.presentation.dto.response.SinglePendingListResD import com.msg.gauth.domain.user.service.* import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.* -import org.springframework.web.multipart.MultipartFile import javax.validation.Valid @RestController diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptUserReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptUserReqDto.kt index f7d8bd0b..bdccc167 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptUserReqDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/AcceptUserReqDto.kt @@ -35,4 +35,4 @@ data class AcceptUserReqDto( oauthWrongPasswordCount = user.oauthWrongPasswordCount ) } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/PasswordChangeReqDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/PasswordChangeReqDto.kt index 6d8a9a35..0025c072 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/PasswordChangeReqDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/request/PasswordChangeReqDto.kt @@ -8,9 +8,9 @@ data class PasswordChangeReqDto( @field:NotBlank @field:Pattern(regexp = "^(?=.*[a-zA-Z])(?=.*[!@#\$%^*+=-?<>])(?=.*[0-9]).{8,20}\$") val password: String, -){ +) { - fun toEntity(user: User, newPassword: String): User{ + fun toEntity(user: User, newPassword: String): User { return User( id = user.id, email = user.email, diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/GetMyRolesResDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/GetMyRolesResDto.kt index 08660800..92b28f97 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/GetMyRolesResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/GetMyRolesResDto.kt @@ -4,4 +4,4 @@ import com.msg.gauth.domain.user.enums.UserRoleType data class GetMyRolesResDto( val roles: List -) +) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/MyProfileResDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/MyProfileResDto.kt index 16e6c94e..81554194 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/MyProfileResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/MyProfileResDto.kt @@ -15,10 +15,10 @@ data class MyProfileResDto( val clientList: List ) { - constructor(user: User, clientList: List): this( + constructor(user: User, clientList: List) : this( userId = user.id, email = user.email, - name =user.name, + name = user.name, grade = user.grade, classNum = user.classNum, number = user.num, @@ -35,7 +35,7 @@ data class MyProfileResDto( val serviceImgUrl: String ) { - constructor(client: Client): this( + constructor(client: Client) : this( id = client.id, clientId = client.clientId, serviceName = client.serviceName, diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SingleAcceptedUserResDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SingleAcceptedUserResDto.kt index 078e2041..9e15fac3 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SingleAcceptedUserResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SingleAcceptedUserResDto.kt @@ -12,7 +12,7 @@ data class SingleAcceptedUserResDto( val profileUrl: String? ) { - constructor(user: User): this( + constructor(user: User) : this( user.id, user.name!!, user.email, diff --git a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SinglePendingListResDto.kt b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SinglePendingListResDto.kt index 73508eea..f728fa8a 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SinglePendingListResDto.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/presentation/dto/response/SinglePendingListResDto.kt @@ -8,7 +8,7 @@ data class SinglePendingListResDto( val profileUrl: String? ) { - constructor(user: User): this( + constructor(user: User) : this( id = user.id, email = user.email, profileUrl = user.profileUrl diff --git a/src/main/kotlin/com/msg/gauth/domain/user/repository/CustomUserRepositoryImpl.kt b/src/main/kotlin/com/msg/gauth/domain/user/repository/CustomUserRepositoryImpl.kt index 2d8d8691..fc3d2b76 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/repository/CustomUserRepositoryImpl.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/repository/CustomUserRepositoryImpl.kt @@ -1,7 +1,6 @@ package com.msg.gauth.domain.user.repository import com.msg.gauth.domain.user.QUser.user -import com.msg.gauth.domain.user.QUserRole import com.msg.gauth.domain.user.QUserRole.userRole import com.msg.gauth.domain.user.User import com.msg.gauth.domain.user.enums.UserRoleType @@ -37,12 +36,11 @@ class CustomUserRepositoryImpl( keywordLike(keyword) ) - - if(gradeEq == null) { - orderSpecifiers.add(OrderSpecifier(Order.ASC, pathBuilder.get(user.grade))) + if (gradeEq == null) { + orderSpecifiers.add(OrderSpecifier(Order.ASC, pathBuilder.get(user.grade))) } - if(classNumEq == null) { + if (classNumEq == null) { orderSpecifiers.add(OrderSpecifier(Order.ASC, pathBuilder.get(user.classNum))) } @@ -63,13 +61,13 @@ class CustomUserRepositoryImpl( } private fun gradeEq(grade: Int): BooleanExpression? = - if(grade != 0) user.grade.eq(grade) else null + if (grade != 0) user.grade.eq(grade) else null private fun classNumEq(classNum: Int): BooleanExpression? = - if(classNum != 0) user.classNum.eq(classNum) else null + if (classNum != 0) user.classNum.eq(classNum) else null private fun keywordLike(keyword: String): BooleanExpression? = - if(keyword.isNotEmpty()) user.name.like("%${keyword}%") else null + if (keyword.isNotEmpty()) user.name.like("%$keyword%") else null private fun roleEq(userRoleType: UserRoleType): BooleanExpression = userRole.userRoleType.eq(userRoleType) diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptUserSignUpService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptUserSignUpService.kt index b8b0ded7..70396255 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptUserSignUpService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/service/AcceptUserSignUpService.kt @@ -1,8 +1,6 @@ package com.msg.gauth.domain.user.service -import com.msg.gauth.domain.user.User import com.msg.gauth.domain.user.UserRole -import com.msg.gauth.domain.user.enums.UserRoleType import com.msg.gauth.domain.user.enums.UserState import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.presentation.dto.request.AcceptUserReqDto @@ -30,5 +28,4 @@ class AcceptUserSignUpService( userRoleRepository.save(userRole) userRepository.save(signedUpUser) } -} - +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/ChangePasswordService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/ChangePasswordService.kt index 04d4e857..5bd9aae7 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/ChangePasswordService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/service/ChangePasswordService.kt @@ -17,13 +17,13 @@ class ChangePasswordService( private val passwordEncoder: PasswordEncoder ) { - fun execute(passwordChangeReqDto: PasswordChangeReqDto){ + fun execute(passwordChangeReqDto: PasswordChangeReqDto) { val currentUser = userUtil.fetchCurrentUser() val emailAuth = emailAuthRepository.findByIdOrNull(currentUser.email) ?: throw EmailNotVerifiedException() - if(!emailAuth.authentication) + if (!emailAuth.authentication) throw EmailNotVerifiedException() val user = passwordChangeReqDto.toEntity( diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt index ea1642de..8e5aaa69 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/service/GetAcceptedUsersService.kt @@ -11,7 +11,7 @@ class GetAcceptedUsersService( private val userRepository: UserRepository, ) { fun execute(request: AcceptedUserRequest): List = - when(request.role) { + when (request.role) { UserRoleType.ROLE_STUDENT -> userRepository.search(request.grade, request.classNum, request.keyword) else -> userRepository.findAllByUserRoleType(request.role) }.map { SingleAcceptedUserResDto(it) } diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/GetMyRolesService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/GetMyRolesService.kt index ad82e941..56922bb1 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/GetMyRolesService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/service/GetMyRolesService.kt @@ -1,7 +1,6 @@ package com.msg.gauth.domain.user.service import com.msg.gauth.domain.user.presentation.dto.response.GetMyRolesResDto -import com.msg.gauth.domain.user.repository.UserRoleRepository import com.msg.gauth.domain.user.util.UserUtil import com.msg.gauth.global.annotation.service.ReadOnlyService diff --git a/src/main/kotlin/com/msg/gauth/domain/user/service/GetPendingUsersService.kt b/src/main/kotlin/com/msg/gauth/domain/user/service/GetPendingUsersService.kt index 920e28c7..73a2c969 100644 --- a/src/main/kotlin/com/msg/gauth/domain/user/service/GetPendingUsersService.kt +++ b/src/main/kotlin/com/msg/gauth/domain/user/service/GetPendingUsersService.kt @@ -13,4 +13,4 @@ class GetPendingUsersService( fun execute(): List = userRepository.findAllByState(UserState.PENDING) .map { SinglePendingListResDto(it) } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/annotation/logger/log4k.kt b/src/main/kotlin/com/msg/gauth/global/annotation/logger/log4k.kt index 327786e7..5e6c8203 100644 --- a/src/main/kotlin/com/msg/gauth/global/annotation/logger/log4k.kt +++ b/src/main/kotlin/com/msg/gauth/global/annotation/logger/log4k.kt @@ -1,6 +1,5 @@ package com.msg.gauth.global.annotation.logger - @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FUNCTION) annotation class log4k \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt b/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt index ee5b7ab6..7b76fbcb 100644 --- a/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt +++ b/src/main/kotlin/com/msg/gauth/global/annotation/service/ReadOnlyService.kt @@ -10,4 +10,4 @@ import kotlin.reflect.KClass annotation class ReadOnlyService( @get: AliasFor(annotation = Transactional::class) val noRollbackFor: Array> = [] -) +) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt b/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt index 1e593799..5b55629b 100644 --- a/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt +++ b/src/main/kotlin/com/msg/gauth/global/annotation/service/TransactionalService.kt @@ -10,4 +10,4 @@ import kotlin.reflect.KClass annotation class TransactionalService( @get: AliasFor(annotation = Transactional::class) val noRollbackFor: Array> = [] -) +) \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/config/jackson/JacksonConfig.kt b/src/main/kotlin/com/msg/gauth/global/config/jackson/JacksonConfig.kt index f2993daa..bb0ac809 100644 --- a/src/main/kotlin/com/msg/gauth/global/config/jackson/JacksonConfig.kt +++ b/src/main/kotlin/com/msg/gauth/global/config/jackson/JacksonConfig.kt @@ -14,5 +14,4 @@ class JacksonConfig { jacksonObjectMapper().apply { this.registerModule(JavaTimeModule()) } -} - +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/config/thymeleaf/ThymeleafConfig.kt b/src/main/kotlin/com/msg/gauth/global/config/thymeleaf/ThymeleafTemplateConfig.kt similarity index 100% rename from src/main/kotlin/com/msg/gauth/global/config/thymeleaf/ThymeleafConfig.kt rename to src/main/kotlin/com/msg/gauth/global/config/thymeleaf/ThymeleafTemplateConfig.kt diff --git a/src/main/kotlin/com/msg/gauth/global/config/web/WebMvcConfig.kt b/src/main/kotlin/com/msg/gauth/global/config/web/WebMvcConfig.kt index 3ced45d3..e370218d 100644 --- a/src/main/kotlin/com/msg/gauth/global/config/web/WebMvcConfig.kt +++ b/src/main/kotlin/com/msg/gauth/global/config/web/WebMvcConfig.kt @@ -5,7 +5,7 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration -class WebMvcConfig: WebMvcConfigurer { +class WebMvcConfig : WebMvcConfigurer { override fun addCorsMappings(registry: CorsRegistry) { registry @@ -16,4 +16,4 @@ class WebMvcConfig: WebMvcConfigurer { .exposedHeaders("Authorization") .allowCredentials(true) } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/filter/ExceptionFilter.kt b/src/main/kotlin/com/msg/gauth/global/filter/ExceptionFilter.kt index fcb268aa..58d4f8bc 100644 --- a/src/main/kotlin/com/msg/gauth/global/filter/ExceptionFilter.kt +++ b/src/main/kotlin/com/msg/gauth/global/filter/ExceptionFilter.kt @@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.msg.gauth.global.exception.ErrorCode import com.msg.gauth.global.exception.ErrorResponse import com.msg.gauth.global.exception.exceptions.BasicException -import org.slf4j.LoggerFactory import org.springframework.http.MediaType import org.springframework.web.filter.OncePerRequestFilter import javax.servlet.FilterChain @@ -13,7 +12,7 @@ import javax.servlet.http.HttpServletResponse class ExceptionFilter( private val objectMapper: ObjectMapper -): OncePerRequestFilter() { +) : OncePerRequestFilter() { override fun doFilterInternal( request: HttpServletRequest, @@ -28,7 +27,6 @@ class ExceptionFilter( sendError(response, ErrorCode.INTERNAL_SERVER_ERROR) throw e } - } private fun sendError(res: HttpServletResponse, errorCode: ErrorCode) { diff --git a/src/main/kotlin/com/msg/gauth/global/filter/JwtTokenFilter.kt b/src/main/kotlin/com/msg/gauth/global/filter/JwtTokenFilter.kt index c632a15b..2f1603a3 100644 --- a/src/main/kotlin/com/msg/gauth/global/filter/JwtTokenFilter.kt +++ b/src/main/kotlin/com/msg/gauth/global/filter/JwtTokenFilter.kt @@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletResponse class JwtTokenFilter( private val tokenParser: TokenParser, private val jwtTokenProvider: JwtTokenProvider -): OncePerRequestFilter() { +) : OncePerRequestFilter() { override fun doFilterInternal( request: HttpServletRequest, diff --git a/src/main/kotlin/com/msg/gauth/global/filter/RequestLogFilter.kt b/src/main/kotlin/com/msg/gauth/global/filter/RequestLogFilter.kt index de6ab74c..9ec82033 100644 --- a/src/main/kotlin/com/msg/gauth/global/filter/RequestLogFilter.kt +++ b/src/main/kotlin/com/msg/gauth/global/filter/RequestLogFilter.kt @@ -33,7 +33,7 @@ class RequestLogFilter : OncePerRequestFilter() { log.error("=========================") log.error(e.cause.toString()) } - + log.info("=========================") log.info("response status = ${response.status}") log.info("=========================") diff --git a/src/main/kotlin/com/msg/gauth/global/redis/RedisConfig.kt b/src/main/kotlin/com/msg/gauth/global/redis/RedisConfig.kt index 0330628d..19454783 100644 --- a/src/main/kotlin/com/msg/gauth/global/redis/RedisConfig.kt +++ b/src/main/kotlin/com/msg/gauth/global/redis/RedisConfig.kt @@ -32,4 +32,4 @@ class RedisConfig( @Bean fun zSetOperation(): ZSetOperations = redisTemplate().opsForZSet() -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/security/CustomAccessDeniedHandler.kt b/src/main/kotlin/com/msg/gauth/global/security/CustomAccessDeniedHandler.kt index 457f1393..fdafefe3 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/CustomAccessDeniedHandler.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/CustomAccessDeniedHandler.kt @@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletResponse @Component class CustomAccessDeniedHandler( private val objectMapper: ObjectMapper -): AccessDeniedHandler { +) : AccessDeniedHandler { private val log = LoggerFactory.getLogger(this::class.simpleName) override fun handle( diff --git a/src/main/kotlin/com/msg/gauth/global/security/CustomAuthenticationEntryPoint.kt b/src/main/kotlin/com/msg/gauth/global/security/CustomAuthenticationEntryPoint.kt index 5828ac23..2fe22f4a 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/CustomAuthenticationEntryPoint.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/CustomAuthenticationEntryPoint.kt @@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletResponse @Component class CustomAuthenticationEntryPoint( private val objectMapper: ObjectMapper -): AuthenticationEntryPoint { +) : AuthenticationEntryPoint { private val log = LoggerFactory.getLogger(this::class.simpleName) override fun commence( diff --git a/src/main/kotlin/com/msg/gauth/global/security/SecurityConfig.kt b/src/main/kotlin/com/msg/gauth/global/security/SecurityConfig.kt index 01b1b5c7..93f09e8f 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/SecurityConfig.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/SecurityConfig.kt @@ -4,12 +4,9 @@ import com.fasterxml.jackson.databind.ObjectMapper import com.msg.gauth.global.security.config.FilterConfig import com.msg.gauth.global.security.jwt.JwtTokenProvider import com.msg.gauth.global.security.jwt.TokenParser -import org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest -import org.springframework.boot.actuate.autoconfigure.security.servlet.SecurityRequestMatchersManagementContextConfiguration import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.http.HttpMethod -import org.springframework.security.config.Customizer.withDefaults import org.springframework.security.config.annotation.web.builders.HttpSecurity import org.springframework.security.config.http.SessionCreationPolicy import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder @@ -18,7 +15,6 @@ import org.springframework.security.web.SecurityFilterChain import org.springframework.security.web.util.matcher.RequestMatcher import org.springframework.web.cors.CorsUtils - @Configuration class SecurityConfig( private val jwtTokenProvider: JwtTokenProvider, @@ -35,13 +31,13 @@ class SecurityConfig( .httpBasic().disable() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS) - .and() .authorizeRequests() - .requestMatchers(RequestMatcher { request -> - CorsUtils.isPreFlightRequest(request) - }).permitAll() - + .requestMatchers( + RequestMatcher { request -> + CorsUtils.isPreFlightRequest(request) + } + ).permitAll() // Auth .antMatchers(HttpMethod.POST, "/auth").permitAll() .antMatchers(HttpMethod.PATCH, "/auth").permitAll() @@ -53,12 +49,10 @@ class SecurityConfig( .antMatchers(HttpMethod.PATCH, "/auth/password").authenticated() .antMatchers(HttpMethod.GET, "/auth").permitAll() .antMatchers(HttpMethod.POST, "/auth/v2/signup").permitAll() - // Email .antMatchers(HttpMethod.POST, "/email").permitAll() .antMatchers(HttpMethod.GET, "/email/authentication").permitAll() .antMatchers(HttpMethod.GET, "/email").permitAll() - // Client .antMatchers(HttpMethod.GET, "/client").authenticated() .antMatchers(HttpMethod.POST, "/client").authenticated() @@ -72,20 +66,16 @@ class SecurityConfig( .antMatchers(HttpMethod.PATCH, "/client/{id}/co-worker").authenticated() .antMatchers(HttpMethod.DELETE, "/client/{id}/co-worker").authenticated() .antMatchers(HttpMethod.GET, "/client/{id}/co-worker").authenticated() - // Admin .antMatchers(HttpMethod.POST, "/admin/parsing-member").hasRole("ADMIN") - // OAuth .antMatchers(HttpMethod.POST, "/oauth/code").permitAll() .antMatchers(HttpMethod.POST, "/oauth/token").permitAll() .antMatchers(HttpMethod.PATCH, "/oauth/token").permitAll() .antMatchers(HttpMethod.GET, "/oauth/{clientId}").permitAll() .antMatchers(HttpMethod.POST, "/oauth/code/access").authenticated() - // Health .antMatchers(HttpMethod.GET, "/health").permitAll() - // User .antMatchers(HttpMethod.GET, "/user").authenticated() .antMatchers(HttpMethod.GET, "/user/role").authenticated() @@ -97,25 +87,20 @@ class SecurityConfig( .antMatchers(HttpMethod.PATCH, "/user/accept-student").hasRole("ADMIN") .antMatchers(HttpMethod.PATCH, "/user/accept-user/{id}").hasRole("ADMIN") .antMatchers(HttpMethod.DELETE, "/user/reject/{id}").hasRole("ADMIN") - - //image + // image .antMatchers(HttpMethod.POST, "/image").authenticated() .antMatchers(HttpMethod.DELETE, "/image").authenticated() - // Actuator .antMatchers(HttpMethod.GET, "/actuator/health").hasRole("ADMIN") .antMatchers(HttpMethod.GET, "/actuator/info").hasRole("ADMIN") .antMatchers(HttpMethod.GET, "/actuator/prometheus").hasRole("ADMIN") - .anyRequest().denyAll() .and() .exceptionHandling() .authenticationEntryPoint(CustomAuthenticationEntryPoint(objectMapper)) .accessDeniedHandler(CustomAccessDeniedHandler(objectMapper)) - .and() - .apply(FilterConfig(tokenParser, jwtTokenProvider, objectMapper)) - + .apply(FilterConfig(tokenParser, jwtTokenProvider, objectMapper)) .and() .build() } @@ -123,4 +108,4 @@ class SecurityConfig( @Bean fun passwordEncoder(): PasswordEncoder = BCryptPasswordEncoder() -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetails.kt b/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetails.kt index 2c683e4e..b120e09e 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetails.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetails.kt @@ -1,14 +1,13 @@ package com.msg.gauth.global.security.auth import com.msg.gauth.domain.user.User -import com.msg.gauth.domain.user.UserRole import com.msg.gauth.domain.user.enums.UserState import org.springframework.security.core.GrantedAuthority import org.springframework.security.core.userdetails.UserDetails class AuthDetails( private val user: User, -): UserDetails { +) : UserDetails { override fun getAuthorities(): Collection = user.userRole.map { it.userRoleType } @@ -25,7 +24,6 @@ class AuthDetails( override fun isAccountNonLocked(): Boolean = user.state.equals(UserState.CREATED) - override fun isCredentialsNonExpired(): Boolean = true diff --git a/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetailsService.kt b/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetailsService.kt index 397fbe35..c958fc58 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetailsService.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/auth/AuthDetailsService.kt @@ -2,7 +2,6 @@ package com.msg.gauth.global.security.auth import com.msg.gauth.domain.user.exception.UserNotFoundException import com.msg.gauth.domain.user.repository.UserRepository -import com.msg.gauth.domain.user.repository.UserRoleRepository import org.springframework.security.core.userdetails.UserDetails import org.springframework.security.core.userdetails.UserDetailsService import org.springframework.stereotype.Service @@ -12,12 +11,11 @@ import org.springframework.transaction.annotation.Transactional @Transactional(readOnly = true) class AuthDetailsService( private val userRepository: UserRepository -): UserDetailsService { +) : UserDetailsService { override fun loadUserByUsername(username: String): UserDetails { val user = userRepository.findByEmail(username) ?: throw UserNotFoundException() return AuthDetails(user) } - -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/security/config/FilterConfig.kt b/src/main/kotlin/com/msg/gauth/global/security/config/FilterConfig.kt index b46a6aa4..592dfee8 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/config/FilterConfig.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/config/FilterConfig.kt @@ -15,7 +15,7 @@ class FilterConfig( private val tokenParser: TokenParser, private val jwtTokenProvider: JwtTokenProvider, private val objectMapper: ObjectMapper -): SecurityConfigurerAdapter() { +) : SecurityConfigurerAdapter() { override fun configure(builder: HttpSecurity) { val jwtTokenFilter = JwtTokenFilter(tokenParser, jwtTokenProvider) diff --git a/src/main/kotlin/com/msg/gauth/global/security/jwt/JwtTokenProvider.kt b/src/main/kotlin/com/msg/gauth/global/security/jwt/JwtTokenProvider.kt index 56dfcd72..7fe1f684 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/jwt/JwtTokenProvider.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/jwt/JwtTokenProvider.kt @@ -1,16 +1,7 @@ package com.msg.gauth.global.security.jwt -import com.msg.gauth.domain.auth.repository.RefreshTokenRepository -import com.msg.gauth.domain.oauth.repository.OauthRefreshTokenRepository -import com.msg.gauth.global.security.auth.AuthDetailsService -import com.msg.gauth.global.security.exception.ExpiredTokenException -import com.msg.gauth.global.security.exception.InvalidTokenException -import io.jsonwebtoken.Claims -import io.jsonwebtoken.ExpiredJwtException import io.jsonwebtoken.Jwts import io.jsonwebtoken.SignatureAlgorithm -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken -import org.springframework.security.core.Authentication import org.springframework.stereotype.Component import java.security.Key import java.time.ZonedDateTime @@ -54,5 +45,4 @@ class JwtTokenProvider( val token = req.getHeader("Authorization") ?: return null return tokenParser.parseToken(token) } - } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/security/jwt/OauthTokenProvider.kt b/src/main/kotlin/com/msg/gauth/global/security/jwt/OauthTokenProvider.kt index 8ef6ef96..e8822d96 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/jwt/OauthTokenProvider.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/jwt/OauthTokenProvider.kt @@ -1,10 +1,5 @@ package com.msg.gauth.global.security.jwt -import com.msg.gauth.global.security.auth.AuthDetailsService -import com.msg.gauth.global.security.exception.ExpiredTokenException -import com.msg.gauth.global.security.exception.InvalidTokenException -import io.jsonwebtoken.Claims -import io.jsonwebtoken.ExpiredJwtException import io.jsonwebtoken.Jwts import io.jsonwebtoken.SignatureAlgorithm import org.springframework.stereotype.Component @@ -24,13 +19,15 @@ class OauthTokenProvider( } fun generateOauthAccessToken(email: String, clientId: String): String = - generateOauthToken(email, + generateOauthToken( + email, OAUTH_ACCESS_TYPE, clientId, jwtProperties.oauthSecret, OAUTH_ACCESS_EXP ) fun generateOauthRefreshToken(email: String, clientId: String): String = - generateOauthToken(email, + generateOauthToken( + email, OAUTH_REFRESH_TYPE, clientId, jwtProperties.oauthSecret, OAUTH_REFRESH_EXP ) @@ -44,6 +41,4 @@ class OauthTokenProvider( .setIssuedAt(Date()) .setExpiration(Date(System.currentTimeMillis() + exp * 1000)) .compact() - -} - +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/security/jwt/TokenParser.kt b/src/main/kotlin/com/msg/gauth/global/security/jwt/TokenParser.kt index 5478e1f5..f529e6bb 100644 --- a/src/main/kotlin/com/msg/gauth/global/security/jwt/TokenParser.kt +++ b/src/main/kotlin/com/msg/gauth/global/security/jwt/TokenParser.kt @@ -51,6 +51,4 @@ class TokenParser( private fun getTokenSubject(token: String, secret: Key): String = getTokenBody(token, secret).subject - - } \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/AwsS3Config.kt b/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/AwsS3Config.kt index f0144aa4..240d7bf3 100644 --- a/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/AwsS3Config.kt +++ b/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/AwsS3Config.kt @@ -9,7 +9,6 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration - @Configuration class AwsS3Config { @Value("\${cloud.aws.credentials.access-key}") diff --git a/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/S3Util.kt b/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/S3Util.kt index f1a6d3c4..c72a15ee 100644 --- a/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/S3Util.kt +++ b/src/main/kotlin/com/msg/gauth/global/thirdparty/aws/s3/S3Util.kt @@ -21,19 +21,19 @@ class S3Util( val splitFile = image.originalFilename.toString().split(".") - if(splitFile.size != 2) + if (splitFile.size != 2) throw FileExtensionInvalidException() - + val extension = splitFile.last().lowercase() - - if(list.none { it == extension }) + + if (list.none { it == extension }) throw FileExtensionInvalidException() return upload(image) } private fun upload(file: MultipartFile): String { - val profileName = "${bucket}/${UUID.randomUUID()}${file.originalFilename}" + val profileName = "$bucket/${UUID.randomUUID()}${file.originalFilename}" val metadata = ObjectMetadata() @@ -44,9 +44,9 @@ class S3Util( return amazonS3.getUrl(bucket, profileName).toString() } - fun deleteImage(url: String){ + fun deleteImage(url: String) { val key = url.split("/")[3] amazonS3.deleteObject(bucket, key) } -} +} \ No newline at end of file diff --git a/src/main/kotlin/com/msg/gauth/global/util/count/auth/TempSignInBan.kt b/src/main/kotlin/com/msg/gauth/global/util/count/auth/TempSignInBan.kt index 0ab856bd..e26e6add 100644 --- a/src/main/kotlin/com/msg/gauth/global/util/count/auth/TempSignInBan.kt +++ b/src/main/kotlin/com/msg/gauth/global/util/count/auth/TempSignInBan.kt @@ -5,7 +5,7 @@ import org.springframework.data.redis.core.RedisHash import org.springframework.data.redis.core.index.Indexed @RedisHash(value = "tempSignInBan", timeToLive = 60) -class TempSignInBan ( +class TempSignInBan( @Id @Indexed val email: String diff --git a/src/main/kotlin/com/msg/gauth/global/util/count/auth/util/TooManyRequestValidUtil.kt b/src/main/kotlin/com/msg/gauth/global/util/count/auth/util/TooManyRequestValidUtil.kt index 2616c18c..e3511614 100644 --- a/src/main/kotlin/com/msg/gauth/global/util/count/auth/util/TooManyRequestValidUtil.kt +++ b/src/main/kotlin/com/msg/gauth/global/util/count/auth/util/TooManyRequestValidUtil.kt @@ -21,8 +21,10 @@ class TooManyRequestValidUtil( ) { fun validRequest(email: String) { - val secondSignInCount = (secondSignInCountRepository.findByIdOrNull(email) - ?: secondSignInCountRepository.save(SecondSignInCount(email))) + val secondSignInCount = ( + secondSignInCountRepository.findByIdOrNull(email) + ?: secondSignInCountRepository.save(SecondSignInCount(email)) + ) if (secondSignInCount.count >= 20) { val user = userRepository.findByEmail(email) @@ -37,8 +39,10 @@ class TooManyRequestValidUtil( secondSignInCountRepository.save(secondSignInCount) - val minuteSignInCount = (minuteSignInCountRepository.findByIdOrNull(email) - ?: minuteSignInCountRepository.save(MinuteSignInCount(email))) + val minuteSignInCount = ( + minuteSignInCountRepository.findByIdOrNull(email) + ?: minuteSignInCountRepository.save(MinuteSignInCount(email)) + ) if (minuteSignInCount.count >= 10) { val user = userRepository.findByEmail(email) diff --git a/src/main/kotlin/com/msg/gauth/global/util/count/oauth/TempOAuthSignInBan.kt b/src/main/kotlin/com/msg/gauth/global/util/count/oauth/TempOAuthSignInBan.kt index 11c4f4be..e0981967 100644 --- a/src/main/kotlin/com/msg/gauth/global/util/count/oauth/TempOAuthSignInBan.kt +++ b/src/main/kotlin/com/msg/gauth/global/util/count/oauth/TempOAuthSignInBan.kt @@ -5,7 +5,7 @@ import org.springframework.data.redis.core.RedisHash import org.springframework.data.redis.core.index.Indexed @RedisHash(value = "tempOAuthSignInBan", timeToLive = 60) -class TempOAuthSignInBan ( +class TempOAuthSignInBan( @Id @Indexed val email: String diff --git a/src/main/kotlin/com/msg/gauth/global/util/count/oauth/util/TooManyOAuthRequestValidUtil.kt b/src/main/kotlin/com/msg/gauth/global/util/count/oauth/util/TooManyOAuthRequestValidUtil.kt index 6a7f7f08..7d99d3f1 100644 --- a/src/main/kotlin/com/msg/gauth/global/util/count/oauth/util/TooManyOAuthRequestValidUtil.kt +++ b/src/main/kotlin/com/msg/gauth/global/util/count/oauth/util/TooManyOAuthRequestValidUtil.kt @@ -21,8 +21,10 @@ class TooManyOAuthRequestValidUtil( ) { fun validRequest(email: String) { - val secondSignInCount = (secondSignInCountRepository.findByIdOrNull(email) - ?: secondSignInCountRepository.save(SecondOAuthSignInCount(email))) + val secondSignInCount = ( + secondSignInCountRepository.findByIdOrNull(email) + ?: secondSignInCountRepository.save(SecondOAuthSignInCount(email)) + ) if (secondSignInCount.count >= 20) { val user = userRepository.findByEmail(email) @@ -36,8 +38,10 @@ class TooManyOAuthRequestValidUtil( secondSignInCount.addCount() secondSignInCountRepository.save(secondSignInCount) - val minuteSignInCount = (minuteSignInCountRepository.findByIdOrNull(email) - ?: minuteSignInCountRepository.save(MinuteOAuthSignInCount(email))) + val minuteSignInCount = ( + minuteSignInCountRepository.findByIdOrNull(email) + ?: minuteSignInCountRepository.save(MinuteOAuthSignInCount(email)) + ) if (minuteSignInCount.count >= 10) { val user = userRepository.findByEmail(email) diff --git a/src/test/kotlin/com/msg/gauth/GauthBackendApplicationTests.kt b/src/test/kotlin/com/msg/gauth/GauthBackendApplicationTests.kt index 7561735e..2bdb90c4 100644 --- a/src/test/kotlin/com/msg/gauth/GauthBackendApplicationTests.kt +++ b/src/test/kotlin/com/msg/gauth/GauthBackendApplicationTests.kt @@ -1,12 +1,9 @@ package com.msg.gauth import org.junit.jupiter.api.Test -import org.springframework.boot.test.context.SpringBootTest -@SpringBootTest class GauthBackendApplicationTests { @Test fun contextLoads() { } - -} +} \ No newline at end of file