AzureAD / microsoft-authentication-library-for-go

The MSAL library for Go is part of the Microsoft identity platform for developers (formerly named Azure AD) v2.0. It enables you to acquire security tokens to call protected APIs. It uses industry standard OAuth2 and OpenID Connect.
MIT License
218 stars 87 forks source link

Support authnscheme in AcquireTokenByUsernamePassword flow #472

Closed rharpavat closed 4 months ago

rharpavat commented 5 months ago

What is the change?

Adds support for authnScheme in AcquireTokenByUsernamePassword flow.

Currently, automated testing for AzRBAC and PoP token flow relies on SPN login, which uses the msal confidential client. However, most customers will be using the interactive login flow which uses msal's public client. In order to enable better testing of the customer scenario, this change enables PoP token support for username/password flow so that automated testing can be conducted for the public client.

How was the change tested?

Vendored this commit on msal into my local branch of kubelogin. Was able to successfully build kubelogin and get a PoP token using ropc (username/password flow):

./kubelogin get-token -l ropc --client-id <clientid> --server-id <serverid> --tenant-id <msft-tenant-id> --username k8connectsa@microsoft.com --password <redacted> --pop-enabled --pop-claims "u=/subscriptions/91d1cf86-13c9-4318-b47a-e536e3533061/resourceGroups/rharpavat-test/providers/Microsoft.Kubernetes/connectedClusters/e2et1"

Outputted token is in correct format:

{
  "typ": "pop",
  "alg": "RS256",
  "kid": "<kid>"
}.{
  "at": "<redacted>",
  "ts": 1707327222,
  "u": "/subscriptions/91d1cf86-13c9-4318-b47a-e536e3533061/resourceGroups/rharpavat-test/providers/Microsoft.Kubernetes/connectedClusters/e2et1",
  "cnf": {
    "jwk": {
      "e": "AQAB",
      "kty": "RSA",
      "n": "<n>",
      "alg": "RS256",
      "kid": "<kid>"
    }
  },
  "nonce": "014adc9d8a974430b6f5200e6801026f"
}.[Signature]
sonarcloud[bot] commented 4 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

bgavrilMS commented 4 months ago

I'm working on fixing the build. Hope to get this in this week.