Skip to content

Commit

Permalink
fix(JwtProvider) : 토큰 정보는 SecirutyContextHolder에서 가져온다
Browse files Browse the repository at this point in the history
  • Loading branch information
Due-IT committed Nov 30, 2024
1 parent c1d4144 commit 51d0430
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wabi/src/main/kotlin/com/wap/wabi/auth/jwt/JwtTokenProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package com.wap.wabi.auth.jwt
import io.jsonwebtoken.Jwts
import io.jsonwebtoken.SignatureAlgorithm
import org.springframework.beans.factory.annotation.Value
import org.springframework.context.annotation.PropertySource
import org.springframework.security.core.authority.SimpleGrantedAuthority
import org.springframework.security.core.userdetails.User
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
import java.sql.Timestamp
import java.time.Instant
import java.time.LocalDateTime
import java.time.temporal.ChronoUnit
import java.util.*
import java.util.Date
import javax.crypto.spec.SecretKeySpec

@Component
Expand Down Expand Up @@ -49,4 +47,9 @@ class JwtTokenProvider(
val (username) = subject.split(":")
return username
}

fun getAdminName(): String {
val authentication = SecurityContextHolder.getContext().authentication
return authentication.name
}
}

0 comments on commit 51d0430

Please sign in to comment.