260212_02_ENH: API Key를 통한 인증도 claims에 정보를 넣도록 수정

This commit is contained in:
2026-02-12 13:54:28 +09:00
parent 88e9845c1c
commit 5de2640c18
3 changed files with 16 additions and 8 deletions

View File

@@ -4,7 +4,7 @@ plugins {
} }
//버전 변경은 여기서 //버전 변경은 여기서
def commonVer = "beta.1.0.63" def commonVer = "beta.1.0.64"
group = 'com.kri.common' group = 'com.kri.common'
version = commonVer version = commonVer

View File

@@ -175,11 +175,11 @@ public class JwtService {
authorities.add(new SimpleGrantedAuthority(authority)); authorities.add(new SimpleGrantedAuthority(authority));
} }
return new UsernamePasswordAuthenticationToken( UsernamePasswordAuthenticationToken auth =
principal, new UsernamePasswordAuthenticationToken(principal, null, authorities);
null,
authorities auth.setDetails(dto); // 핵심: claims를 details에 보관
); return auth;
} }
/** /**

View File

@@ -39,8 +39,16 @@ public class RequestUserContextArgumentResolver implements HandlerMethodArgument
// 1) SecurityContext 에 이미 JwtUserClaimsDto 가 principal 로 들어있는 경우 // 1) SecurityContext 에 이미 JwtUserClaimsDto 가 principal 로 들어있는 경우
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth != null && auth.getPrincipal() instanceof JwtUserClaimsDto jwtDto) { if (auth != null) {
claims = jwtDto; Object principal = auth.getPrincipal();
if (principal instanceof JwtUserClaimsDto jwtDto) {
claims = jwtDto;
} else {
Object details = auth.getDetails();
if (details instanceof JwtUserClaimsDto jwtDto) {
claims = jwtDto;
}
}
} }
// 2) 현재 공통 JwtService 는 principal 을 userId(String) 로 쓰고 있으니까, // 2) 현재 공통 JwtService 는 principal 을 userId(String) 로 쓰고 있으니까,