암호화된 APIKey 요구 사항

이제 ' ibm-appconfiguration-js-client-sdk ' 및 ' ibm-appconfiguration-react-client-sdk '는 보안을 강화하기 위해 일반 텍스트 API키 대신 암호화된 클라이언트 SDK API키를 제공하도록 사용자에게 요구합니다. 이렇게 하면 브라우저를 통해 웹 페이지를 검사할 때 APIKey가 노출되는 것을 방지할 수 있습니다.

최대한의 보안을 제공하기 위해 암호화 과정에서 무작위 논스를 사용합니다. 따라서 APIKey를 암호화할 때마다 암호화된 값은 달라지지만 인증 중에 암호를 해독할 때 기본 일반 텍스트는 동일하게 유지됩니다.

암호화된 클라이언트 SDK APIKey 생성 및 사용 단계

  1. 일반 API키를 받습니다:
    • IBM Cloud 대시보드에서 App Configuration 인스턴스의 서비스 자격 증명 섹션으로 이동합니다.
    • ' Client SDK 역할 API키를 생성하고 서비스 자격 증명에서 apikey를 복사합니다.
  2. API키를 암호화합니다:
    • 다음 API 엔드포인트를 사용하여 일반 APIKey를 암호화하세요

      POST /apprapp/feature/v1/instances/<guid>/encrypt
      

      예: https://eu-gb.apprapp.cloud.ibm.com/apprapp/feature/v1/instances/720f9034-c990-4305-96d6-4f65ffacef2c/encrypt

    • 요청 본문에는 다음과 같이 일반 APIKey를 포함하세요:

      {
        "client_sdk_apikey": "your_plain_apikey"
      }
      
    • 응답에는 AES-256 암호화된 APIKey가 포함됩니다.

  3. 코드 업데이트하기:

자바스크립트 SDK: 초기화 코드를 업데이트합니다:

  • 애플리케이션에서 일반 APIKey를 사용하는 것을 암호화된 APIKey로 교체하세요. 다음은 암호화된 APIKey를 사용하여 SDK를 초기화하는 방법에 대한 업데이트된 예제입니다:
const region = AppConfiguration.REGION_US_SOUTH; // 지역 지정
const guid = '<guid>'; // 서비스 자격 증명의 인스턴스 ID
const apikey = '<encrypted_apikey>'; // 암호화된 APIKey 사용

        const collectionId = 'airlines-webapp'; // Your collection ID
        const environmentId = 'dev'; // Your environment ID

        const appConfigClient = AppConfiguration.getInstance();

        async function initialiseAppConfig() {
            appConfigClient.init(region, guid, apikey); // Initialize with encrypted APIKey
            await appConfigClient.setContext(collectionId, environmentId);
        }

        try {
            await initialiseAppConfig();
            console.log("App configuration SDK initialized successfully");
        } catch (e) {
            console.error("Failed to initialize app configuration SDK", e);
        }
        ```

**React SDK:**
AppConfigProvider 코드를 업데이트합니다:
- 애플리케이션에서 일반 APIKey를 사용하는 것을 암호화된 APIKey로 교체하세요. 다음은 암호화된 APIKey를 사용하여 SDK를 초기화하는 방법에 대한 업데이트된 예제입니다:
```js
'ibm-appconfiguration-react-client-sdk'에서 { withAppConfigProvider } 가져옵니다;

        (async () => {
        const AppConfigProvider = await withAppConfigProvider({
            region: 'us-south', // Specify your region
            guid: '<guid>', // Instance ID from Service Credentials
            apikey: '<encrypted_apikey>', // Use the encrypted APIKey
            collectionId: 'airlines-webapp', // Your collection ID
            environmentId: 'dev' // Your environment ID
        })

        ReactDOM.render(
            <AppConfigProvider>
                <YourApp />
            </AppConfigProvider>,
            document.getElementById('root')
        );
        })();
        ```

## 기존 사용자: 업데이트 필요 {: #ac-existing-users-update}

이미 일반 APIKey를 사용하고 있다면, 이전 단계에 따라 암호화된 APIKey를 생성하고 사용하도록 애플리케이션을 업데이트하십시오.

<!-- v2.4.8 : caits-prod-app-clouddocs_cloud-docs-app-configuration_20250808T171821-4_en_ko -->