Skip to content

Compiler: extend engine.auth for Anthropic Workload Identity Federation; gate ANTHROPIC_API_KEY validation when WIF configured #35561

Description

@benissimo

Problem

Two compiler-side gaps block end-to-end use of Anthropic Workload Identity Federation in gh-aw, even after the downstream firewall change (github/gh-aw-firewall#3974) is fixed:

  1. EngineAuthConfig only handles Azure. A workflow author can't express engine.auth.type: github-oidc, provider: anthropic, federation-rule-id: ..., organization-id: ..., service-account-id: ..., workspace-id: ... in frontmatter today — the compiler silently drops everything past type and audience.
  2. The validate_multi_secret.sh ANTHROPIC_API_KEY runtime step is emitted unconditionally for the Claude engine, so a fully WIF-configured workflow still fails the validation gate before the agent ever runs.

Evidence — EngineAuthConfig

pkg/workflow/engine.go:77:

type EngineAuthConfig struct {
    Type          string
    Audience      string
    AzureTenantID string
    AzureClientID string
    AzureScope    string
    AzureCloud    string
}

parseEngineAuthConfig (pkg/workflow/engine.go:602) and applyEngineAuthEnv (pkg/workflow/engine.go:628) only read/write Azure fields. No FederationRuleID, OrganizationID, ServiceAccountID, WorkspaceID.

The frontmatter schema mirrors this gap: pkg/parser/schemas/main_workflow_schema.json:10638 describes engine.auth purely in Azure-OIDC terms.

The downstream api-proxy (gh-aw-firewall #3974 once fixed) will expect AWF_AUTH_ANTHROPIC_FEDERATION_RULE_ID, AWF_AUTH_ANTHROPIC_ORGANIZATION_ID, AWF_AUTH_ANTHROPIC_SERVICE_ACCOUNT_ID, AWF_AUTH_ANTHROPIC_WORKSPACE_ID — but the compiler has no way to emit them.

Evidence — validate_multi_secret

pkg/workflow/claude_engine.go:55:

func (e *ClaudeEngine) GetRequiredSecretNames(workflowData *WorkflowData) []string {
    return append([]string{"ANTHROPIC_API_KEY"}, collectCommonMCPSecrets(workflowData)...)
}

pkg/workflow/claude_engine.go:61:

func (e *ClaudeEngine) GetSecretValidationStep(workflowData *WorkflowData) GitHubActionStep {
    return BuildDefaultSecretValidationStep(
        workflowData,
        []string{"ANTHROPIC_API_KEY"},
        "Claude Code",
        ...,
    )
}

Neither method checks workflowData.EngineConfig.Auth. So even if a workflow declares engine.auth.type: github-oidc, provider: anthropic, ... correctly, the compiled lock file still calls validate_multi_secret.sh ANTHROPIC_API_KEY 'Claude Code' ... at runtime — failing fast when the secret isn't set, before the api-proxy ever gets a chance to do the WIF exchange.

This was the first failure mode we hit when attempting a gh-aw + WIF workflow (RealPage/ai-internal-enablement PR #586 / run #26449417639).

Proposed changes

1. Extend EngineAuthConfig for Anthropic

type EngineAuthConfig struct {
    Type          string
    Audience      string
    Provider      string  // NEW — "azure" (default), "aws", "gcp", "anthropic"

    // Azure
    AzureTenantID string
    AzureClientID string
    AzureScope    string
    AzureCloud    string

    // AWS (in case the gh-aw-firewall AWS provider is also surfaced later)
    AWSRoleArn  string
    AWSRegion   string

    // Anthropic
    AnthropicFederationRuleID string
    AnthropicOrganizationID   string
    AnthropicServiceAccountID string
    AnthropicWorkspaceID      string
}

Update parseEngineAuthConfig to read these from authObj. Update applyEngineAuthEnv to emit AWF_AUTH_PROVIDER, AWF_AUTH_ANTHROPIC_* (matching the env-var names the api-proxy expects). Update the schema.

2. Skip / relax ANTHROPIC_API_KEY validation when WIF is configured

In ClaudeEngine.GetRequiredSecretNames and GetSecretValidationStep, branch on workflowData.EngineConfig.Auth:

  • If Auth.Type == "github-oidc" and Auth.Provider == "anthropic", don't emit the ANTHROPIC_API_KEY validation step. (The api-proxy validates the WIF chain at startup.)
  • Else: current behaviour.

Same logic for MCP_GATEWAY_API_KEY and any other secrets that should be ignored when WIF is the credential source.

3. Test coverage

Existing pkg/workflow/engine_config_test.go only covers Azure auth env mapping. Add a parallel test for the Anthropic case asserting:

  • All four AWF_AUTH_ANTHROPIC_* env vars land in config.Env
  • AWF_AUTH_PROVIDER is anthropic
  • The compiled lock file does not include a validate_multi_secret.sh ANTHROPIC_API_KEY step

Working example (when both this and #3974 land)

engine:
  id: claude
  auth:
    type: github-oidc
    provider: anthropic
    federation-rule-id: fdrl_xxxxxxxxxxxxxxxxxxxxxxxx
    organization-id: 00000000-0000-0000-0000-000000000000
    service-account-id: svac_xxxxxxxxxxxxxxxxxxxxxxxx
    # workspace-id: wrkspc_... # only when rule covers multiple workspaces

permissions:
  id-token: write
  contents: read

Reference working POC (plain-YAML, no gh-aw): https://gist.github.com/benissimo/340e7cfb5fdd102c5cd8d39cf91bcc32

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions