OpenClawのSecretRef設定:認証情報を安全に管理する
APIキーやパスワードなどの機密情報を安全に管理するのは、開発者にとって常に大きな課題ですよね。設定ファイルに直接書き込むのは避けたいですし、どの値が外部のシークレット管理ツールで扱えるのかを正確に把握しておくことは、セキュアなシステムを構築する上で欠かせません。
この記事では、OpenClawにおける「SecretRef」の標準的な認証情報の対象範囲について解説します。
このドキュメントの目的は以下の通りです:
- 対象範囲内: OpenClawが発行や更新を行わない、ユーザーが提供する認証情報。
- 対象範囲外: 実行時に発行または更新される認証情報、OAuthのリフレッシュトークン、セッション関連のアーティファクト。
サポートされている認証情報
Section titled “サポートされている認証情報”openclaw.json の対象 (secrets configure + secrets apply + secrets audit)
Section titled “openclaw.json の対象 (secrets configure + secrets apply + secrets audit)”- `models.providers.*.apiKey`- `models.providers.*.headers.*`- `skills.entries.*.apiKey`- `agents.defaults.memorySearch.remote.apiKey`- `agents.list[].memorySearch.remote.apiKey`- `talk.apiKey`- `talk.providers.*.apiKey`- `messages.tts.providers.*.apiKey`- `tools.web.fetch.firecrawl.apiKey`- `plugins.entries.brave.config.webSearch.apiKey`- `plugins.entries.google.config.webSearch.apiKey`- `plugins.entries.xai.config.webSearch.apiKey`- `plugins.entries.moonshot.config.webSearch.apiKey`- `plugins.entries.perplexity.config.webSearch.apiKey`- `plugins.entries.firecrawl.config.webSearch.apiKey`- `plugins.entries.tavily.config.webSearch.apiKey`- `tools.web.search.apiKey`- `tools.web.x_search.apiKey`- `gateway.auth.password`- `gateway.auth.token`- `gateway.remote.token`- `gateway.remote.password`- `cron.webhookToken`- `channels.telegram.botToken`- `channels.telegram.webhookSecret`- `channels.telegram.accounts.*.botToken`- `channels.telegram.accounts.*.webhookSecret`- `channels.slack.botToken`- `channels.slack.appToken`- `channels.slack.userToken`- `channels.slack.signingSecret`- `channels.slack.accounts.*.botToken`- `channels.slack.accounts.*.appToken`- `channels.slack.accounts.*.userToken`- `channels.slack.accounts.*.signingSecret`- `channels.discord.token`- `channels.discord.pluralkit.token`- `channels.discord.voice.tts.providers.*.apiKey`- `channels.discord.accounts.*.token`- `channels.discord.accounts.*.pluralkit.token`- `channels.discord.accounts.*.voice.tts.providers.*.apiKey`- `channels.irc.password`- `channels.irc.nickserv.password`- `channels.irc.accounts.*.password`- `channels.irc.accounts.*.nickserv.password`- `channels.bluebubbles.password`- `channels.bluebubbles.accounts.*.password`- `channels.feishu.appSecret`- `channels.feishu.encryptKey`- `channels.feishu.verificationToken`- `channels.feishu.accounts.*.appSecret`- `channels.feishu.accounts.*.encryptKey`- `channels.feishu.accounts.*.verificationToken`- `channels.msteams.appPassword`- `channels.mattermost.botToken`- `channels.mattermost.accounts.*.botToken`- `channels.matrix.accessToken`- `channels.matrix.password`- `channels.matrix.accounts.*.accessToken`- `channels.matrix.accounts.*.password`- `channels.nextcloud-talk.botSecret`- `channels.nextcloud-talk.apiPassword`- `channels.nextcloud-talk.accounts.*.botSecret`- `channels.nextcloud-talk.accounts.*.apiPassword`- `channels.zalo.botToken`- `channels.zalo.webhookSecret`- `channels.zalo.accounts.*.botToken`- `channels.zalo.accounts.*.webhookSecret`- `channels.googlechat.serviceAccount` via sibling `serviceAccountRef` (compatibility exception)- `channels.googlechat.accounts.*.serviceAccount` via sibling `serviceAccountRef` (compatibility exception)auth-profiles.json の対象 (secrets configure + secrets apply + secrets audit)
Section titled “auth-profiles.json の対象 (secrets configure + secrets apply + secrets audit)”- `profiles.*.keyRef` (`type: "api_key"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)- `profiles.*.tokenRef` (`type: "token"`; unsupported when `auth.profiles.<id>.mode = "oauth"`)注意点:
- Auth-profileのプラン対象には
agentIdが必要です。 - プランのエントリは
profiles.*.keyまたはprofiles.*.tokenを対象とし、兄弟要素の参照(keyRef/tokenRef)を書き込みます。 - Auth-profileの参照は、実行時の解決および監査の対象に含まれます。
- OAuthポリシーのガード:
auth.profiles.<id>.mode = "oauth"が設定されている場合、そのプロファイルに対して SecretRef の入力を使用することはできません。このポリシーに違反した場合、起動・リロード時、またはAuth-profileの解決時に即座にエラーとなります。 - SecretRefで管理されるモデルプロバイダーの場合、生成された
agents/*/agent/models.jsonのエントリには、解決されたシークレットの値ではなく、非シークレットのマーカーが保持されます。 - マーカーの保持はソース優先です。OpenClawは、解決された実行時のシークレット値からではなく、アクティブなソース設定のスナップショット(解決前)からマーカーを書き込みます。
- Web検索について:
- 明示的なプロバイダーモード(
tools.web.search.providerが設定されている場合)では、選択されたプロバイダーのキーのみがアクティブになります。 - 自動モード(
tools.web.search.providerが未設定の場合)では、優先順位に従って最初に解決されたプロバイダーのキーのみがアクティブになります。 - 自動モードにおいて、選択されなかったプロバイダーの参照は、選択されるまで非アクティブとして扱われます。
- レガシーな
tools.web.search.*プロバイダーパスは互換性期間中も引き続き解決されますが、標準的な SecretRef の指定先はplugins.entries.<plugin>.config.webSearch.*となります。
- 明示的なプロバイダーモード(
サポートされていない認証情報
Section titled “サポートされていない認証情報”以下の認証情報は対象外となります:
- `commands.ownerDisplaySecret`- `hooks.token`- `hooks.gmail.pushToken`- `hooks.mappings[].sessionKey`- `auth-profiles.oauth.*`- `channels.discord.threadBindings.webhookToken`- `channels.discord.accounts.*.threadBindings.webhookToken`- `channels.whatsapp.creds.json`- `channels.whatsapp.accounts.*.creds.json`理由:
- これらの認証情報は、システムによって発行・更新されるもの、セッションを保持するもの、またはOAuthのように永続的なクラスであり、読み取り専用の外部 SecretRef 解決には適さないためです。
OpenClaw Expert
まだ解決しませんか?
このページで解決しない場合は、OpenClaw Expertに直接質問してください。