"use client";
import React from "react";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { AuthType } from "@/lib/api/externalRestApiConnection";
interface AuthenticationConfigProps {
authType: AuthType;
authConfig: any;
onAuthTypeChange: (type: AuthType) => void;
onAuthConfigChange: (config: any) => void;
}
export function AuthenticationConfig({
authType,
authConfig = {},
onAuthTypeChange,
onAuthConfigChange,
}: AuthenticationConfigProps) {
// 인증 설정 변경
const updateAuthConfig = (field: string, value: string) => {
onAuthConfigChange({
...authConfig,
[field]: value,
});
};
return (
{/* 인증 타입 선택 */}
{/* 인증 타입별 설정 필드 */}
{authType === "api-key" && (
API Key 설정
{/* 키 위치 */}
{/* 키 이름 */}
updateAuthConfig("keyName", e.target.value)}
placeholder="예: X-API-Key"
/>
{/* 키 값 */}
updateAuthConfig("keyValue", e.target.value)}
placeholder="API Key를 입력하세요"
/>
)}
{authType === "bearer" && (
Bearer Token 설정
{/* 토큰 */}
updateAuthConfig("token", e.target.value)}
placeholder="Bearer Token을 입력하세요"
/>
* Authorization 헤더에 "Bearer {token}" 형식으로 전송됩니다.
)}
{authType === "basic" && (
)}
{authType === "oauth2" && (
)}
{authType === "db-token" && (
)}
{authType === "wehago" && (
Wehago / Amaranth (아마란스) 설정
updateAuthConfig("callerName", e.target.value)}
placeholder="예: API_gcmsAmaranth40578"
/>
updateAuthConfig("accessToken", e.target.value)}
placeholder="Bearer 토큰으로 사용됩니다"
/>
updateAuthConfig("hashKey", e.target.value)}
placeholder="HMAC-SHA256 서명 키"
/>
updateAuthConfig("groupSeq", e.target.value)}
placeholder="예: gcmsAmaranth40578"
/>
* 매 요청마다 32자리 transaction-id, Unix timestamp, wehago-sign(HMAC-SHA256(accessToken+transactionId+timestamp+urlPath, hashKey) → Base64)을 자동 생성합니다.
* Wehago/RPS ERP API와 호환되는 인증 헤더(callerName, Authorization, transaction-id, timestamp, groupSeq, wehago-sign)가 자동 부착됩니다.
)}
{authType === "none" && (
인증이 필요하지 않은 공개 API입니다.
)}
);
}