generated from pricelees/issue-pr-template
[#20] 도메인별 예외 분리 #21
@ -13,15 +13,15 @@ class JwtHandler(
|
||||
@Value("\${security.jwt.token.secret-key}")
|
||||
private val secretKey: String,
|
||||
|
||||
@Value("\${security.jwt.token.access.expire-length}")
|
||||
private val accessTokenExpireTime: Long
|
||||
@Value("\${security.jwt.token.ttl-seconds}")
|
||||
private val tokenTtlSeconds: Long
|
||||
) {
|
||||
fun createToken(memberId: Long): String {
|
||||
val date = Date()
|
||||
val accessTokenExpiredAt = Date(date.time + accessTokenExpireTime)
|
||||
val accessTokenExpiredAt = Date(date.time + tokenTtlSeconds)
|
||||
|
||||
return Jwts.builder()
|
||||
.claim("memberId", memberId)
|
||||
.claim(MEMBER_ID_CLAIM_KEY, memberId)
|
||||
.setIssuedAt(date)
|
||||
.setExpiration(accessTokenExpiredAt)
|
||||
.signWith(SignatureAlgorithm.HS256, secretKey.toByteArray())
|
||||
@ -33,8 +33,8 @@ class JwtHandler(
|
||||
return Jwts.parser()
|
||||
.setSigningKey(secretKey.toByteArray())
|
||||
.parseClaimsJws(token)
|
||||
.getBody()
|
||||
.get("memberId", Number::class.java)
|
||||
.body
|
||||
.get(MEMBER_ID_CLAIM_KEY, Number::class.java)
|
||||
.toLong()
|
||||
} catch (e: Exception) {
|
||||
when (e) {
|
||||
@ -47,4 +47,8 @@ class JwtHandler(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val MEMBER_ID_CLAIM_KEY = "memberId"
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,8 +21,7 @@ security:
|
||||
jwt:
|
||||
token:
|
||||
secret-key: daijawligagaf@LIJ$@U)9nagnalkkgalijaddljfi
|
||||
access:
|
||||
expire-length: 1800000 # 30 분
|
||||
ttl-seconds: 1800000
|
||||
|
||||
payment:
|
||||
api-base-url: https://api.tosspayments.com
|
||||
|
||||
@ -14,8 +14,7 @@ security:
|
||||
jwt:
|
||||
token:
|
||||
secret-key: daijawligagaf@LIJ$@U)9nagnalkkgalijaddljfi
|
||||
access:
|
||||
expire-length: 1800000 # 30 분
|
||||
ttl-seconds: 1800000
|
||||
|
||||
payment:
|
||||
api-base-url: https://api.tosspayments.com
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user