openclaw - 💡(How to fix) Fix Enhancement: Allow vault/exec secret references in auth.profiles apiKey [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#50125Fetched 2026-04-08 00:58:56
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
0
Timeline (top)
commented ×1labeled ×1

Allow vault/exec secret references (e.g. OpenBao, HashiCorp Vault) to be used as the apiKey source in auth.profiles, the same way they are already supported in tools, channels, gateway, skills, and messages.

Root Cause

Allow vault/exec secret references (e.g. OpenBao, HashiCorp Vault) to be used as the apiKey source in auth.profiles, the same way they are already supported in tools, channels, gateway, skills, and messages.

Code Example

"auth": {
  "profiles": {
    "anthropic:default": {
      "provider": "anthropic",
      "mode": "api_key",
      "apiKey": {
        "source": "exec",
        "provider": "openbao",
        "id": "secret/moneypenny/anthropic"
      }
    },
    "google:default": {
      "provider": "google",
      "mode": "api_key",
      "apiKey": {
        "source": "exec",
        "provider": "openbao",
        "id": "secret/moneypenny/google"
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Summary

Allow vault/exec secret references (e.g. OpenBao, HashiCorp Vault) to be used as the apiKey source in auth.profiles, the same way they are already supported in tools, channels, gateway, skills, and messages.

Problem to solve

When mode: "api_key" is set in auth.profiles, openclaw hard-codes a lookup to file:filemain:/anthropic/apiKey (and equivalent for other providers). This means:

  1. The config schema rejects vault reference objects in auth.profiles.<provider>.apiKey with Unrecognized key: "apiKey"
  2. If filemain is not configured, startup fails: SecretProviderResolutionError: Secret provider "filemain" is not configured (ref: file:filemain:/anthropic/apiKey)

Users who have fully migrated to an exec-based vault provider (OpenBao, Vault, etc.) are forced to keep a separate plaintext JSON file just for provider API keys, even though every other secret in the system is vault-sourced. This defeats the purpose of centralized secrets management and creates a confusing inconsistency with no documentation warning.

Proposed solution

Extend the auth.profiles config schema so that apiKey accepts a secret reference object, consistent with how all other secret fields work:

"auth": {
  "profiles": {
    "anthropic:default": {
      "provider": "anthropic",
      "mode": "api_key",
      "apiKey": {
        "source": "exec",
        "provider": "openbao",
        "id": "secret/moneypenny/anthropic"
      }
    },
    "google:default": {
      "provider": "google",
      "mode": "api_key",
      "apiKey": {
        "source": "exec",
        "provider": "openbao",
        "id": "secret/moneypenny/google"
      }
    }
  }
}

The secret resolution path already exists — it just needs to be permitted in the auth profile schema. The filemain fallback should remain for backwards compatibility but should not be the only option.

Alternatives considered

No response

Impact

Affected: Any user deploying openclaw with a vault-based secrets provider (OpenBao, HashiCorp Vault) who wants to eliminate plaintext credential files — especially production and multi-agent deployments.

Severity: Blocks full vault migration — forces a plaintext fallback file regardless of vault configuration.

Frequency: Every startup, every deployment, every new agent added to the instance.

Consequence: Users must maintain a separate auth-keys.json file containing plaintext AI provider API keys. This file sits outside the vault, creating an inconsistent security posture and additional operational overhead. As more agents and AI providers are added to an openclaw instance, the number of keys that must be managed outside the vault grows.

Evidence/examples

No response

Additional information

No response

extent analysis

Fix Plan

To fix this issue, we need to update the auth.profiles config schema to accept a secret reference object for the apiKey field. Here are the steps:

  • Update the auth.profiles schema to include the apiKey field with a type that allows a secret reference object.
  • Add a check to handle the new schema and resolve the secret reference using the existing secret resolution path.

Code Changes

// Update the auth.profiles schema
const authProfilesSchema = {
  type: 'object',
  properties: {
    profiles: {
      type: 'object',
      additionalProperties: {
        type: 'object',
        properties: {
          provider: { type: 'string' },
          mode: { type: 'string' },
          apiKey: {
            oneOf: [
              { type: 'string' }, // existing plaintext apiKey
              {
                type: 'object',
                properties: {
                  source: { type: 'string' },
                  provider: { type: 'string' },
                  id: { type: 'string' },
                },
                required: ['source', 'provider', 'id'],
              }, // new secret reference object
            ],
          },
        },
        required: ['provider', 'mode', 'apiKey'],
      },
    },
  },
};

// Update the auth profile resolver to handle the new schema
function resolveAuthProfileApiKey(profile) {
  if (typeof profile.apiKey === 'string') {
    // existing plaintext apiKey handling
    return profile.apiKey;
  } else if (typeof profile.apiKey === 'object' && profile.apiKey.source === 'exec') {
    // new secret reference object handling
    const secretId = profile.apiKey.id;
    const secretProvider = profile.apiKey.provider;
    // use the existing secret resolution path to resolve the secret
    return resolveSecret(secretId, secretProvider);
  } else {
    throw new Error(`Invalid apiKey type: ${typeof profile.apiKey}`);
  }
}

Verification

To verify that the fix worked, you can test the following scenarios:

  • Create an auth.profiles config with a plaintext apiKey and verify that it works as expected.
  • Create an auth.profiles config with a secret reference object apiKey and verify that it resolves the secret correctly.
  • Test that the filemain fallback still works for backwards compatibility.

Extra Tips

  • Make sure to update the documentation to reflect the new schema and handling of secret reference objects for apiKey.
  • Consider adding additional validation and error handling for the new schema to ensure that invalid configurations are properly handled.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING