# セキュリティ保護

体験を保護するためには、ドメインホワイトリストとAPIキーの2つのオプションがあります。

**ドメインホワイトリスト**

展開コードスニペットを他人が自分の公開ウェブサイトにホストすることを防ぐ、低レベルのセキュリティを提供します。ただし、悪意のあるユーザーが他の方法で有効なセッショントークンを要求する可能性は残っています。

**APIキー**

あなたの秘密キーを使用してセッショントークンを生成することを要求することで、最高レベルのセキュリティを提供します。この方法では、APIキーを秘密に保ちながらセッショントークンを生成するために独自のサービスを構築し、ホストする必要があります。

## ドメインホワイトリスト

デジタルヒューマンをウェブサイトに展開する前に、ドメインをホワイトリストに登録する必要があります。これを行うには、ウェブサイトに展開したいペルソナに移動し、「[ワークスペース一覧](https://dip.digitalhumans.ne.jp/groups/)」セクション内のワークスペース設定で「 `許可ドメイン`」フィールドに設置したいドメインを追加してください。

最大で9ドメインまで設定可能です。

![DIP(Digital Humans Identity Portal）上の設定](/files/ID9i2hO4XE7W21M08ZGj)

DIP(Digital Humans Identity Portal）上の設定

たとえば、コードスニペットを <https://your-domain.com/example/> のURLを持つWebページに挿入する場合、ドメイン [https://your-domain.com](https://your-domain.com/) をホワイトリストに登録しておく必要があります。URLの末尾にある「/」は不要です。

会話のセキュリティを確保するため、[https://your-domain.com](https://your-domain.com/) 以外のドメインでは、デジタルヒューマンとのセッションを開始することはできません。

なお、開発用途として例外的に [http://localhost:3000](http://localhost:3000/) や [http://127.0.0.1:8001](http://127.0.0.1:8001/) などのURLも登録が可能です。

### コンテンツセキュリティポリシー

コンテンツセキュリティポリシーをお持ちの場合は、`Referrer-Policy strict-origin-when-cross-origin` に設定する必要があります。これにより、貴社のウェブサイトがページリファラーをデジタルヒューマンのフレームに渡して検証が可能になります。

## APIキー

APIキーアプローチを安全に構築するには、セッショントークンを生成し、それをフロントエンドに返す独自のバックエンドサービスを構築する必要があります。

バックエンドサービスは公開インターネットにアクセスできないように保護するべきです。そうしないと、悪意のあるユーザーがあなたのサービスを使用してデジタルヒューマンのセッショントークンを取得する可能性があります。

セッショントークンを生成するために、以下の仕様を持つ公開APIを提供しています：

リクエスト: `POST`

URL: `/session-service/v1/create-session`

ボディ: `{ personaId: 'your-persona-id', apiKey: 'your-secret-api-key' }`

例：JavaScript

```jsx
const connectionUrl = 'http://api.uneeq.io';
const personaId = 'your-persona-id';
const apiKey = 'your-secret-api-key';
fetch(`${connectionUrl}/session-service/v1/create-session`, {
	method: 'POST',
	body: JSON.stringify({ personaId, apiKey }),
	headers: {
		'Content-Type': 'application/json'
	}
})
```

例：CURL

```bash
curl -X POST "http://api.uneeq.io/session-service/v1/create-session" \
     -H "Content-Type: application/json" \
     -d '{"personaId":"your-persona-id","apiKey":"your-secret-api-key"}'
```

{% hint style="warning" %}
APIキーをフロントエンドアプリケーションに含めたり、公開したりしないでください。
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalhumans.jp/dev/hosted-experience/hosted-experience-security.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
