Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Domain-Module/src/main/kotlin/com/pawith/domain/auth/OAuth.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.pawith.domain.auth

import com.pawith.commonmodule.enums.Provider

class OAuth(
private val id: Long?,
private val provider: Provider,
private val sub: String,
private val userId: Long
) {
}
11 changes: 11 additions & 0 deletions Domain-Module/src/main/kotlin/com/pawith/domain/auth/Token.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.pawith.domain.auth

import com.pawith.domain.auth.jwt.TokenType

class Token(
private val id: Long?,
private val value: String,
private val tokenType: TokenType,
private val userId: Long
) {
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
package com.pawith.domain.auth.exception;
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.Error;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;

@Getter
@RequiredArgsConstructor
public enum AuthError implements Error {
import com.pawith.commonmodule.exception.Error
import org.springframework.http.HttpStatus
import org.springframework.http.HttpStatusCode

enum class AuthError(
override val message: String,
override val errorCode: Int,
override val httpStatusCode: HttpStatusCode,
) : Error {
INVALID_TOKEN("유효하지 않은 토큰입니다.", 1000, HttpStatus.BAD_REQUEST),
EXPIRED_TOKEN("만료된 토큰입니다.", 1001, HttpStatus.BAD_REQUEST),
NOT_EXIST_TOKEN("토큰이 존재하지 않습니다.", 1002, HttpStatus.BAD_REQUEST),
INVALID_AUTHORIZATION_TYPE("유효하지 않은 Authorization Type 입니다.", 1003, HttpStatus.BAD_REQUEST),
EMPTY_AUTHORIZATION_HEADER("Authorization Header가 비어있습니다.", 1004, HttpStatus.BAD_REQUEST),
OAUTH_FAIL("OAuth 인증에 실패하였습니다.", 1005, HttpStatus.BAD_REQUEST),
OAUTH_NOT_FOUND("OAuth 정보를 찾을 수 없습니다.", 1006, HttpStatus.NOT_FOUND),
INVALID_OAUTH_REQUEST("다른 소셜로그인으로 가입된 계정이 존재합니다.", 2002, HttpStatus.BAD_REQUEST), // 오류 코드 변경 요청하기
;

private final String message;
private final int errorCode;
private final HttpStatusCode httpStatusCode;
INVALID_OAUTH_REQUEST("다른 소셜로그인으로 가입된 계정이 존재합니다.", 2002, HttpStatus.BAD_REQUEST),
; // 오류 코드 변경 요청하기
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.Error

class ExpiredTokenException(error: Error) : TokenException(error)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.Error

class InvalidTokenException(error: Error) : TokenException(error)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.Error

class NotExistTokenException(error: Error) : TokenException(error)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.BusinessException
import com.pawith.commonmodule.exception.Error

open class OAuthException(error: Error) : BusinessException(error)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.Error

class OAuthNotFoundException(error: Error) : OAuthException(error)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.pawith.domain.auth.exception

import com.pawith.commonmodule.exception.BusinessException
import com.pawith.commonmodule.exception.Error

open class TokenException(error: Error) : BusinessException(error)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.pawith.domain.auth.jwt

import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.annotation.Configuration

@Configuration
@EnableConfigurationProperties(JwtProperties::class)
class ConfigurationPropertiesConfig

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.pawith.domain.auth.jwt

object JwtConsts {
const val TOKEN_ISSUER: String = "pawith"
const val USER_CLAIMS: String = "user_claims"
const val TOKEN_TYPE: String = "token_type"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.pawith.domain.auth.jwt

import io.jsonwebtoken.io.Decoders
import io.jsonwebtoken.security.Keys
import org.springframework.stereotype.Component
import javax.crypto.SecretKey

@Component
class JwtKeyFactory(
private val jwtProperties: JwtProperties
) {

fun generateKey(): SecretKey = Keys.hmacShaKeyFor(Decoders.BASE64.decode(jwtProperties.secret))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.pawith.domain.auth.jwt

import org.springframework.boot.context.properties.ConfigurationProperties

@ConfigurationProperties(prefix="jwt")
class JwtProperties(
val secret: String,
val accessTokenExpirationTime: Long,
val refreshTokenExpirationTime: Long,
) {
}
Loading