Azure / Azure/azure-workload-identity

AADSTS700211 invalid_client

Open
#1,200 20 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Go
Stars
337
Forks
122
Avg merge
1h 7m
Merged PRs (30d)
3

Description

**Describe the bug**
I'm getting the error `AADSTS700211: WorkloadIdentityCredential: Microsoft Entra ID error '(invalid_client) AADSTS700211: No matching federated identity record found for presented assertion issuer 'https://oidc.prod-aks.azure.com/879-...-a6425/'. Please check your federated identity credential Subject, Audience and Issuer against the presented assertion. https://docs.microsoft.com/en-us/azure/active-directory/develop/workload-identity-federation Trace ID: REDACTED Correlation ID: REDACTED Timestamp: 2023-12-08 16:17:27Z'`

**Steps To Reproduce**

Deploy Workload Identity v1.2.0 inside an AKS cluster v1.27.7

Create an AAD Service Principal and a k8s service account using the azwi cli:
```bash
azwi serviceaccount create \
--service-account-name "saName" \
--skip-phases role-assignment \
--subscription-id "" \
--aad-application-name "" \
--service-account-issuer-url "https://oidc.prod-aks.azure.com/879-...-a6425/" \
--service-account-namespace
```

Create a pod associating the SA and with a label `azure.workload.identity/use: "true"`

Trying to authenticate and get a Key Vault secret using Python 3.10 with `DefaultAzureCredential()`, using `azure-identity==1.15.0` lib

**Expected behavior**

Get the secret value.

**Logs**

WorkloadIdentityCredential: Microsoft Entra ID error '(invalid_client) AADSTS700211: No matching federated identity record found for presented assertion issuer 'https://oidc.prod-aks.azure.com/879-...-6425/'. Please check your federated identity credential Subject, Audience and Issuer against the presented assertion. https://docs.microsoft.com/en-us/azure/active-directory/develop/workload-identity-federation Trace ID: REDACTED Correlation ID: REDACTED Timestamp: 2023-12-08 16:55:37Z'

**Environment**

- Kubernetes version (use `kubectl version`): AKS 1.27.7
- Cloud provider or hardware configuration: Azure Public Cloud
- OS (e.g: `cat /etc/os-release`): Ubuntu 20.04.6 LTS
- Kernel (e.g. `uname -a`): 5.15.0-1051-azure #59-Ubuntu SMP Wed Oct 11 18:49:16 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
- Install tools:
- Network plugin and version (if this is a network-related bug):
- Others:

**Additional context**

AAD Service Principal is created without problems:

```bash
Fri, 08 Dec 2023 13:11:16 -03 role-assignment workflow/runner.go:133 skipping phase
Fri, 08 Dec 2023 13:11:20 -03 aad-application create/aadapplication.go:71 created an AAD application {"name": "$AAD_NAME", "clientID": "d861-...-7de", "objectID": "4e11-...-8eec"}
Fri, 08 Dec 2023 13:11:20 -03 serviceaccount/create.go:175 --service-principal-name not specified, falling back to AAD application name {"warning": true}
Fri, 08 Dec 2023 13:11:21 -03 aad-application create/aadapplication.go:95 created service principal {"name": "$AAD_NAME", "clientID": "d861-..-7de", "objectID": "9e0-..-9512"}
Fri, 08 Dec 2023 13:11:22 -03 service-account create/serviceaccount.go:94 created kubernetes service account {"namespace": "$K8S_NAMESPACE", "name": "$K8S_SA_NAME"}
Fri, 08 Dec 2023 13:11:24 -03 federated-identity create/federatedidentitycredential.go:96 added federated credential {"objectID": "4e11-...-8eec", "subject": "system:serviceaccount:$K8S_NAMESPACE:$K8S_SA_NAME"}
```
```$ kubectl describe sa $K8S_SA_NAME
Name: REDACTED
Namespace: REDACTED
Labels:
Annotations: azure.workload.identity/client-id: d861-...-7de
azure.workload.identity/tenant-id: 73d-...-26f
Image pull secrets:
Mountable secrets:
Tokens:
Events:

```

OIDC: az aks show -n $AKS_NAME -g $AKS_RG --query "oidcIssuerProfile.issuerUrl" -otsv
`https://oidc.prod-aks.azure.com/879-...-a6425/`

On AAD App Registration I can see all the values populated correctly (issuer, namespace, service account name).

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the `azwi serviceaccount create` output and compare it with the issuer returned by `az aks show`, then trace authentication from Python's `DefaultAzureCredential()` using `azure-identity==1.15.0`. Done means the pod authenticates successfully and retrieves the requested Key Vault secret without the AADSTS700211 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, kubernetes, python
Domain
authentication, cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.