251117_01_ENH : internal 고정 JWT관련 내용 제거
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
package com.kri.common.auth.jwt;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ConfigurationProperties(prefix = "kri.auth.jwt")
|
||||
public class JwtProperties {
|
||||
|
||||
@@ -28,35 +30,4 @@ public class JwtProperties {
|
||||
* (선택) Refresh Token 유효 시간(초 단위)
|
||||
*/
|
||||
private long refreshTokenValiditySeconds = 7 * 24 * 3600; // 기본 7일
|
||||
|
||||
// ======================================================
|
||||
// 내부 고정 토큰 관련 설정
|
||||
// ======================================================
|
||||
|
||||
/**
|
||||
* 내부 시스템 간 통신에 사용하는 "고정 토큰" 값
|
||||
* - 이 값과 동일한 토큰이 오면 JWT 파싱 없이 내부 계정으로 처리
|
||||
*/
|
||||
private String internalFixedToken;
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰 사용 시 DTO/Authentication 에 들어갈 사용자 ID
|
||||
* - T_USER.USER_ID 에 해당
|
||||
*/
|
||||
private String internalUserId = "INTERNAL_SYSTEM";
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰 사용 시 DTO/Authentication 에 들어갈 팀
|
||||
*/
|
||||
private String internalUserTeam = "SYSTEM";
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰 사용 시 DTO/Authentication 에 들어갈 이름
|
||||
*/
|
||||
private String internalUserName = "Internal System";
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰 사용 시 DTO/Authentication 에 들어갈 권한 코드
|
||||
*/
|
||||
private Integer internalUserRole = 1001;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,21 @@ public class JwtService {
|
||||
// 토큰 생성 (DTO 기반)
|
||||
// ======================================================
|
||||
|
||||
/**
|
||||
* JwtUserClaimsDto 기반 Access Token 생성
|
||||
* - subject = userId
|
||||
* - claims:
|
||||
* userId, userTeam, userName, role
|
||||
*/
|
||||
public String generateSystemToken(JwtUserClaimsDto userClaims) {
|
||||
Map<String, Object> claims = buildClaims(userClaims);
|
||||
return buildToken(
|
||||
claims,
|
||||
userClaims.getUserId(),
|
||||
properties.getAccessTokenValiditySeconds()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* JwtUserClaimsDto 기반 Access Token 생성
|
||||
* - subject = userId
|
||||
@@ -180,37 +195,4 @@ public class JwtService {
|
||||
JwtUserClaimsDto dto = toUserClaimsDto(token);
|
||||
return toAuthentication(dto);
|
||||
}
|
||||
|
||||
// ======================================================
|
||||
// 내부 고정 토큰 처리
|
||||
// ======================================================
|
||||
|
||||
/**
|
||||
* 이 토큰 문자열이 "내부 고정 토큰"인지 여부
|
||||
*/
|
||||
public boolean isInternalFixedToken(String rawToken) {
|
||||
String fixed = properties.getInternalFixedToken();
|
||||
return fixed != null && !fixed.isBlank() && fixed.equals(rawToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰용 DTO 생성
|
||||
* - JwtProperties 에서 내부 시스템 계정을 정의해두고 사용
|
||||
*/
|
||||
public JwtUserClaimsDto createInternalUserClaimsDto() {
|
||||
return JwtUserClaimsDto.builder()
|
||||
.userId(properties.getInternalUserId())
|
||||
.userTeam(properties.getInternalUserTeam())
|
||||
.userName(properties.getInternalUserName())
|
||||
.role(properties.getInternalUserRole())
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 내부 고정 토큰용 Authentication 생성
|
||||
*/
|
||||
public Authentication createInternalAuthentication() {
|
||||
JwtUserClaimsDto dto = createInternalUserClaimsDto();
|
||||
return toAuthentication(dto);
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,15 @@ import lombok.Value;
|
||||
@Builder
|
||||
public class JwtUserClaimsDto {
|
||||
|
||||
@Schema(description = "사용자 ID (T_USER.USER_ID)")
|
||||
@Schema(description = "사용자 ID")
|
||||
String userId;
|
||||
|
||||
@Schema(description = "팀 코드 또는 팀명 (T_USER.USER_TEAM)")
|
||||
@Schema(description = "팀 코드")
|
||||
String userTeam;
|
||||
|
||||
@Schema(description = "사용자 이름 (T_USER.USER_NM)")
|
||||
@Schema(description = "사용자 이름")
|
||||
String userName;
|
||||
|
||||
@Schema(description = "권한 코드 (T_USER.ROLL, INTEGER)")
|
||||
@Schema(description = "권한 코드")
|
||||
Integer role;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user