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