Skip to content

Commit 4d0508e

Browse files
committed
fix(provider): fallback for clientId, mark the one in credentials provider as deprecated
1 parent 919e15f commit 4d0508e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

providers.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import (
1414
type CredentialsProviderOptions struct {
1515
// ClientID is the client ID of the identity.
1616
// This is used to identify the identity when requesting a token.
17+
//
18+
// Deprecated: This field is not used and will be removed in a future version.
19+
// The ClientID should be part of the IdentityProvider options (e.g. ConfidentialIdentityProviderOptions, not the CredentialsProviderOptions)
20+
// There is a ClientID in the ConfidentialIdentityProviderOptions and ManagedIdentityProviderOptions.
1721
ClientID string
1822

1923
// TokenManagerOptions is the options for the token manager.
@@ -96,6 +100,12 @@ type ConfidentialCredentialsProviderOptions struct {
96100
// It uses client id and client credentials to authenticate with the identity provider.
97101
// The client credentials can be either a client secret or a client certificate.
98102
func NewConfidentialCredentialsProvider(options ConfidentialCredentialsProviderOptions) (auth.StreamingCredentialsProvider, error) {
103+
// If the client ID is not provided in the confidential identity provider options, use the one from the credentials provider options.
104+
// Those are duplicated and should be the same.
105+
if options.ConfidentialIdentityProviderOptions.ClientID == "" {
106+
options.ConfidentialIdentityProviderOptions.ClientID = options.CredentialsProviderOptions.ClientID
107+
}
108+
99109
// Create a new identity provider using the client ID and client credentials.
100110
idp, err := identity.NewConfidentialIdentityProvider(options.ConfidentialIdentityProviderOptions)
101111
if err != nil {

0 commit comments

Comments
 (0)