Skip to content

Azure AAD: no production-grade token endpoint override (blocks live e2e against mock) #413

Description

@moonming

Bug — same class as #390/#391

`crates/aisix-provider-azure-openai/src/aad_token_mint.rs:140-160` declares `token_endpoint_override: Option` BUT both the field and its setter `with_token_endpoint_override` are `#[cfg(test)]` only. Production builds always POST to the hardcoded:

```
https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
```

An operator deploying behind a corporate proxy, on Azure Government cloud (`login.microsoftonline.us`), Azure China (`login.partner.microsoftonline.cn`), or pointing at a mock for e2e cannot redirect AAD token minting.

Customer impact

  1. Azure Government / Azure China customers blocked — they use entirely different AAD endpoints (`.us` / `.cn` suffixes). The bridge hardcodes `.com`.
  2. AISIX-Cloud AAD live e2e blocked — `adapter-azure-live.spec.ts` currently only exercises the api-key path because mock-llm has no way to receive AAD client_credentials requests.

Compare to peers

Suggested fix

Add an optional `aad_token_endpoint` field to the AAD secret JSON:

```json
{
"tenant_id": "abc-123",
"client_id": "...",
"client_secret": "...",
"aad_token_endpoint": "https://login.microsoftonline.us/abc-123/oauth2/v2.0/token"
}
```

Default: derive from `tenant_id` against `login.microsoftonline.com` (current behavior).

Implementation:

  1. Add `pub aad_token_endpoint: Option` to `AadCredentials` struct
  2. In `resolve_token_endpoint`, prefer `creds.aad_token_endpoint` over the hardcoded URL
  3. Add scheme/userinfo/query/fragment defensive checks (mirror `api_base` validation pattern from fix(platform-adapters): honor ProviderKey.api_base in Vertex + Azure bridges (#390, #391) #392)
  4. Cap impact: when set, the URL is used verbatim; `tenant_id` is no longer interpolated (operator pasted the full path)

~30-50 LOC change + tests + docs note. Surface area: one new optional JSON field, fully backward compatible.

Blocks

Surfaced via

P1 #4 of #302 follow-up audit (AISIX-Cloud), discovered during scoping of mock-llm `/{tenant}/oauth2/v2.0/token` endpoint addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcross-repoRequires changes in DP + CP + Dashboard UI + e2epriority-normal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions