251117_01_ENH : internal 고정 JWT관련 내용 제거
This commit is contained in:
16
README.md
16
README.md
@@ -4,7 +4,6 @@ Spring Boot 기반 사내 서비스에서 공통으로 사용하는 기능들을
|
||||
`example-service` 같은 개별 서비스는 이 라이브러리를 통해 다음과 같은 기능을 **일관된 방식으로 재사용**할 수 있습니다.
|
||||
|
||||
- JWT 기반 인증/인가 (`com.kri.common.auth.jwt`)
|
||||
- 내부 고정 토큰 처리
|
||||
- 외부 API Key 인증 (`com.kri.common.auth.apikey`)
|
||||
- 공통 Web 예외 처리 & 로깅 (`com.kri.common.web`)
|
||||
- Redis 큐 헬퍼 (`com.kri.common.redis`)
|
||||
@@ -83,7 +82,7 @@ dependencies {
|
||||
KriCommon 은 크게 5가지 축으로 나뉩니다.
|
||||
|
||||
1. **인증/인가**
|
||||
- JWT, 내부 고정 토큰, API Key를 모두 공통 DTO(`JwtUserClaimsDto`) 기반으로 정규화
|
||||
- JWT, API Key를 모두 공통 DTO(`JwtUserClaimsDto`) 기반으로 정규화
|
||||
2. **Web 공통 기능**
|
||||
- 예외 처리, traceId/MDC, AOP 기반 service/handler 로깅
|
||||
3. **Redis 큐 지원**
|
||||
@@ -150,11 +149,6 @@ common:
|
||||
| `kri.auth.jwt.issuer` | String | `"kri-it"` | 토큰 발급자(issuer) |
|
||||
| `kri.auth.jwt.access-token-validity-seconds` | long | `24 * 3600` | Access Token 유효 시간(초) |
|
||||
| `kri.auth.jwt.refresh-token-validity-seconds` | long | `7 * 24 * 3600` | Refresh Token 유효 시간(초) |
|
||||
| `kri.auth.jwt.internal-fixed-token` | String | `null` | 내부 고정 토큰 문자열 (null이면 미사용) |
|
||||
| `kri.auth.jwt.internal-user-id` | String | `"INTERNAL_SYSTEM"` | 내부 토큰 계정 userId |
|
||||
| `kri.auth.jwt.internal-user-team` | String | `"SYSTEM"` | 내부 토큰 계정 team |
|
||||
| `kri.auth.jwt.internal-user-name` | String | `"Internal System"` | 내부 토큰 계정 이름 |
|
||||
| `kri.auth.jwt.internal-user-role` | Integer | `999` | 내부 토큰 계정 role 코드 |
|
||||
|
||||
### 4.2. `kri.auth.apikey` 속성 요약
|
||||
|
||||
@@ -213,7 +207,6 @@ JwtService 는 다음과 같은 역할을 합니다.
|
||||
2. **Refresh Token 발급**
|
||||
3. **토큰 파싱 및 검증**
|
||||
4. **토큰 → JwtUserClaimsDto/Authentication 변환**
|
||||
5. **내부 고정 토큰 처리**
|
||||
|
||||
핵심 메서드 요약:
|
||||
|
||||
@@ -243,13 +236,6 @@ public class JwtService {
|
||||
|
||||
// 토큰 -> Authentication
|
||||
public Authentication toAuthentication(String token) throws JwtException;
|
||||
|
||||
// 내부 고정 토큰인지 확인
|
||||
public boolean isInternalFixedToken(String rawToken);
|
||||
|
||||
// 내부 고정 토큰용 DTO / Authentication 생성
|
||||
public JwtUserClaimsDto createInternalUserClaimsDto();
|
||||
public Authentication createInternalAuthentication();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -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