"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" && (

Basic Auth 설정

{/* 사용자명 */}
updateAuthConfig("username", e.target.value)} placeholder="사용자명을 입력하세요" />
{/* 비밀번호 */}
updateAuthConfig("password", e.target.value)} placeholder="비밀번호를 입력하세요" />

* Authorization 헤더에 Base64 인코딩된 인증 정보가 전송됩니다.

)} {authType === "oauth2" && (

OAuth 2.0 설정

{/* Client ID */}
updateAuthConfig("clientId", e.target.value)} placeholder="Client ID를 입력하세요" />
{/* Client Secret */}
updateAuthConfig("clientSecret", e.target.value)} placeholder="Client Secret을 입력하세요" />
{/* Token URL */}
updateAuthConfig("tokenUrl", e.target.value)} placeholder="예: https://oauth.example.com/token" />

* OAuth 2.0 Client Credentials Grant 방식을 사용합니다.

)} {authType === "db-token" && (

DB 기반 토큰 설정

updateAuthConfig("dbTableName", e.target.value)} placeholder="예: auth_tokens" />
updateAuthConfig("dbValueColumn", e.target.value) } placeholder="예: access_token" />
updateAuthConfig("dbWhereColumn", e.target.value) } placeholder="예: service_name" />
updateAuthConfig("dbWhereValue", e.target.value) } placeholder="예: kakao" />
updateAuthConfig("dbHeaderName", e.target.value) } placeholder="기본값: Authorization" />
updateAuthConfig("dbHeaderTemplate", e.target.value) } placeholder='기본값: "Bearer {{value}}"' />

company_code는 현재 로그인한 사용자의 회사 코드로 자동 필터링됩니다.

)} {authType === "none" && (
인증이 필요하지 않은 공개 API입니다.
)}
); }