251121_01_ENH : 내부 서비스 JWT 생성 기능 제거 및 API-Key 적용
This commit is contained in:
@@ -37,7 +37,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.kri.common:starter:1.0.15"
|
implementation "com.kri.common:starter:1.0.21"
|
||||||
|
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||||
implementation 'org.springframework.boot:spring-boot-starter-security'
|
implementation 'org.springframework.boot:spring-boot-starter-security'
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.kri.intranet.extension.auth;
|
||||||
|
|
||||||
|
import com.kri.common.auth.jwt.JwtUserClaimsDto;
|
||||||
|
import com.kri.common.auth.apikey.ApiKeyUserClaimsProvider;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class IntranetExtensionApiKeyProvider implements ApiKeyUserClaimsProvider{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<JwtUserClaimsDto> findUserByApiKey(String apiKey){
|
||||||
|
//Todo: Redis 적용 할 것
|
||||||
|
return switch (apiKey) {
|
||||||
|
case "4B726963-436F6E74616374-53657276696365-402531213230" -> Optional.of(
|
||||||
|
JwtUserClaimsDto.builder()
|
||||||
|
.userId("ContactServer")
|
||||||
|
.userTeam("KRI-IT-TEAM")
|
||||||
|
.userName("ContactServer")
|
||||||
|
.userRole(1000)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
default -> Optional.empty();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
package com.kri.intranet.extension.controller;
|
|
||||||
|
|
||||||
import com.kri.common.auth.jwt.JwtService;
|
|
||||||
import com.kri.common.auth.jwt.JwtUserClaimsDto;
|
|
||||||
import com.kri.intranet.extension.dto.jwt.InternalJwtDto;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@Tag(name = "InternalJWT", description = "시간 제한 없는 내부 사용용 JWT 생성")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/v1/internal/jwt")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class InternalJwtController {
|
|
||||||
|
|
||||||
private final JwtService jwtService;
|
|
||||||
|
|
||||||
@Operation(
|
|
||||||
summary = "내부 서비스용 JWT",
|
|
||||||
description = "시간 제한 없는 내부 사용용 JWT 생성"
|
|
||||||
)
|
|
||||||
@PostMapping("generate")
|
|
||||||
public String generateInternalJwt(@RequestBody InternalJwtDto internalJwtDto) {
|
|
||||||
JwtUserClaimsDto internalClaims = JwtUserClaimsDto.builder()
|
|
||||||
.userId(internalJwtDto.getServiceId())
|
|
||||||
.userTeam("SYSTEM")
|
|
||||||
.userName(internalJwtDto.getServiceName())
|
|
||||||
.role(999) // 예: 내부 시스템용 권한코드
|
|
||||||
.build();
|
|
||||||
|
|
||||||
return jwtService.generateAccessToken(internalClaims);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user