Skip to content

Commit 063592e

Browse files
authored
azidentity: Remove CAE support (Azure#20479)
1 parent d674a7b commit 063592e

10 files changed

+19
-21
lines changed

sdk/azidentity/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
### Features Added
66

77
### Breaking Changes
8+
> These changes affect only code written against a beta version such as v1.3.0-beta.4
9+
* Removed CAE support. It will return in the next beta release.
810

911
### Bugs Fixed
1012
* Fixed an issue in `DefaultAzureCredential` that could cause the managed identity endpoint check to fail in rare circumstances.

sdk/azidentity/azidentity.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ const (
4646

4747
var (
4848
// capability CP1 indicates the client application is capable of handling CAE claims challenges
49-
cp1 = []string{"CP1"}
50-
disableCP1 = strings.ToLower(os.Getenv("AZURE_IDENTITY_DISABLE_CP1")) == "true"
49+
cp1 = []string{"CP1"}
50+
// CP1 is disabled until CAE support is added back
51+
disableCP1 = true
5152
)
5253

5354
var getConfidentialClient = func(clientID, tenantID string, cred confidential.Credential, co *azcore.ClientOptions, additionalOpts ...confidential.Option) (confidentialClient, error) {

sdk/azidentity/azidentity_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ func TestAdditionallyAllowedTenants(t *testing.T) {
555555
}
556556

557557
func TestClaims(t *testing.T) {
558+
t.Skip("unskip this test after adding back CAE support")
558559
realCP1 := disableCP1
559560
t.Cleanup(func() { disableCP1 = realCP1 })
560561
claim := `"test":"pass"`
@@ -644,9 +645,10 @@ func TestClaims(t *testing.T) {
644645
if _, err = cred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{"A"}}); err != nil {
645646
t.Fatal(err)
646647
}
647-
if _, err = cred.GetToken(context.Background(), policy.TokenRequestOptions{Claims: fmt.Sprintf("{%s}", claim), Scopes: []string{"B"}}); err != nil {
648-
t.Fatal(err)
649-
}
648+
// TODO: uncomment after restoring TokenRequestOptions.Claims
649+
// if _, err = cred.GetToken(context.Background(), policy.TokenRequestOptions{Claims: fmt.Sprintf("{%s}", claim), Scopes: []string{"B"}}); err != nil {
650+
// t.Fatal(err)
651+
// }
650652
if reqs != 2 {
651653
t.Fatalf("expected %d token requests, got %d", 2, reqs)
652654
}

sdk/azidentity/client_assertion_credential.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ func (c *ClientAssertionCredential) GetToken(ctx context.Context, opts policy.To
6868
}
6969

7070
func (c *ClientAssertionCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
71-
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
71+
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
7272
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
7373
}
7474

7575
func (c *ClientAssertionCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
76-
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
76+
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
7777
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
7878
}
7979

sdk/azidentity/client_certificate_credential.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ func (c *ClientCertificateCredential) GetToken(ctx context.Context, opts policy.
7575
}
7676

7777
func (c *ClientCertificateCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
78-
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
78+
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
7979
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
8080
}
8181

8282
func (c *ClientCertificateCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
83-
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
83+
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
8484
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
8585
}
8686

sdk/azidentity/client_secret_credential.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ func (c *ClientSecretCredential) GetToken(ctx context.Context, opts policy.Token
5858
}
5959

6060
func (c *ClientSecretCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
61-
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
61+
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
6262
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
6363
}
6464

6565
func (c *ClientSecretCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
66-
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithClaims(opts.Claims), confidential.WithTenantID(opts.TenantID))
66+
ar, err := c.client.AcquireTokenByCredential(ctx, opts.Scopes, confidential.WithTenantID(opts.TenantID))
6767
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
6868
}
6969

sdk/azidentity/device_code_credential.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (c *DeviceCodeCredential) GetToken(ctx context.Context, opts policy.TokenRe
100100
}
101101

102102
func (c *DeviceCodeCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
103-
dc, err := c.client.AcquireTokenByDeviceCode(ctx, opts.Scopes, public.WithClaims(opts.Claims), public.WithTenantID(opts.TenantID))
103+
dc, err := c.client.AcquireTokenByDeviceCode(ctx, opts.Scopes, public.WithTenantID(opts.TenantID))
104104
if err != nil {
105105
return azcore.AccessToken{}, err
106106
}
@@ -122,7 +122,6 @@ func (c *DeviceCodeCredential) requestToken(ctx context.Context, opts policy.Tok
122122

123123
func (c *DeviceCodeCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
124124
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes,
125-
public.WithClaims(opts.Claims),
126125
public.WithSilentAccount(c.account),
127126
public.WithTenantID(opts.TenantID),
128127
)

sdk/azidentity/interactive_browser_credential.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ func (c *InteractiveBrowserCredential) GetToken(ctx context.Context, opts policy
8282

8383
func (c *InteractiveBrowserCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
8484
ar, err := c.client.AcquireTokenInteractive(ctx, opts.Scopes,
85-
public.WithClaims(opts.Claims),
8685
public.WithLoginHint(c.options.LoginHint),
8786
public.WithRedirectURI(c.options.RedirectURL),
8887
public.WithTenantID(opts.TenantID),
@@ -95,7 +94,6 @@ func (c *InteractiveBrowserCredential) requestToken(ctx context.Context, opts po
9594

9695
func (c *InteractiveBrowserCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
9796
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes,
98-
public.WithClaims(opts.Claims),
9997
public.WithSilentAccount(c.account),
10098
public.WithTenantID(opts.TenantID),
10199
)

sdk/azidentity/on_behalf_of_credential.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ func (o *OnBehalfOfCredential) GetToken(ctx context.Context, opts policy.TokenRe
8989
}
9090

9191
func (o *OnBehalfOfCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
92-
ar, err := o.client.AcquireTokenOnBehalfOf(ctx, o.assertion, opts.Scopes,
93-
confidential.WithClaims(opts.Claims),
94-
confidential.WithTenantID(opts.TenantID),
95-
)
92+
ar, err := o.client.AcquireTokenOnBehalfOf(ctx, o.assertion, opts.Scopes, confidential.WithTenantID(opts.TenantID))
9693
return azcore.AccessToken{Token: ar.AccessToken, ExpiresOn: ar.ExpiresOn.UTC()}, err
9794
}
9895

sdk/azidentity/username_password_credential.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (c *UsernamePasswordCredential) GetToken(ctx context.Context, opts policy.T
6060
}
6161

6262
func (c *UsernamePasswordCredential) requestToken(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
63-
ar, err := c.client.AcquireTokenByUsernamePassword(ctx, opts.Scopes, c.username, c.password, public.WithClaims(opts.Claims), public.WithTenantID(opts.TenantID))
63+
ar, err := c.client.AcquireTokenByUsernamePassword(ctx, opts.Scopes, c.username, c.password, public.WithTenantID(opts.TenantID))
6464
if err == nil {
6565
c.account = ar.Account
6666
}
@@ -69,7 +69,6 @@ func (c *UsernamePasswordCredential) requestToken(ctx context.Context, opts poli
6969

7070
func (c *UsernamePasswordCredential) silentAuth(ctx context.Context, opts policy.TokenRequestOptions) (azcore.AccessToken, error) {
7171
ar, err := c.client.AcquireTokenSilent(ctx, opts.Scopes,
72-
public.WithClaims(opts.Claims),
7372
public.WithSilentAccount(c.account),
7473
public.WithTenantID(opts.TenantID),
7574
)

0 commit comments

Comments
 (0)