@@ -61,8 +61,11 @@ func main() {
61
61
62
62
// Create credentials provider
63
63
provider , err := entraid.NewManagedIdentityCredentialsProvider (entraid.ManagedIdentityCredentialsProviderOptions {
64
- CredentialsProviderOptions: entraid.CredentialsProviderOptions {
65
- ClientID: clientID,
64
+ CredentialsProviderOptions: entraid.CredentialsProviderOptions {},
65
+ ManagedIdentityProviderOptions: identity.ManagedIdentityProviderOptions {
66
+ UserAssignedObjectID: clientID,
67
+ ManagedIdentityType: identity.UserAssignedObjectID ,
68
+ Scopes: []string {identity.RedisScopeDefault },
66
69
},
67
70
})
68
71
if err != nil {
@@ -214,13 +217,11 @@ AZURE_CLIENT_SECRET=your-client-secret
214
217
### Available Configuration Options
215
218
216
219
#### 1. CredentialsProviderOptions
217
- Base options for all credential providers:
220
+ Base options for credential providers includes the options for the token manager :
218
221
``` go
219
222
type CredentialsProviderOptions struct {
220
- // Required: Client ID for authentication
221
- ClientID string
222
-
223
- // Optional: Token manager configuration
223
+ // TokenManagerOptions is the options for the token manager.
224
+ // This is used to configure the token manager when requesting a token.
224
225
TokenManagerOptions manager.TokenManagerOptions
225
226
}
226
227
```
@@ -275,7 +276,7 @@ type RetryOptions struct {
275
276
```
276
277
277
278
#### 4. ManagedIdentityProviderOptions
278
- Options for managed identity authentication :
279
+ Options for managed identity provider (user assigned or system assigned identity) :
279
280
``` go
280
281
type ManagedIdentityProviderOptions struct {
281
282
// Required: Type of managed identity
@@ -291,7 +292,7 @@ type ManagedIdentityProviderOptions struct {
291
292
```
292
293
293
294
#### 5. ConfidentialIdentityProviderOptions
294
- Options for confidential client authentication :
295
+ Options for confidential identity provider ( client secret or client sertificate) :
295
296
``` go
296
297
type ConfidentialIdentityProviderOptions struct {
297
298
// Required: Client ID for authentication
@@ -355,7 +356,6 @@ type DefaultAzureIdentityProviderOptions struct {
355
356
#### Basic Configuration
356
357
``` go
357
358
options := entraid.CredentialsProviderOptions {
358
- ClientID : os.Getenv (" AZURE_CLIENT_ID" ),
359
359
TokenManagerOptions : manager.TokenManagerOptions {
360
360
ExpirationRefreshRatio: 0.7 ,
361
361
LowerRefreshBounds: 10000 ,
@@ -366,7 +366,6 @@ options := entraid.CredentialsProviderOptions{
366
366
#### Advanced Configuration
367
367
``` go
368
368
options := entraid.CredentialsProviderOptions {
369
- ClientID : os.Getenv (" AZURE_CLIENT_ID" ),
370
369
TokenManagerOptions : manager.TokenManagerOptions {
371
370
ExpirationRefreshRatio: 0.7 ,
372
371
LowerRefreshBounds: 10000 ,
@@ -414,6 +413,7 @@ authority := identity.AuthorityConfiguration{
414
413
``` go
415
414
// Create provider for system assigned identity
416
415
provider , err := entraid.NewManagedIdentityCredentialsProvider (entraid.ManagedIdentityCredentialsProviderOptions {
416
+ CredentialsProviderOptions : entraid.CredentialsProviderOptions {},
417
417
ManagedIdentityProviderOptions : identity.ManagedIdentityProviderOptions {
418
418
ManagedIdentityType: identity.SystemAssignedIdentity ,
419
419
Scopes: []string {" https://redis.azure.com/.default" },
@@ -425,9 +425,7 @@ provider, err := entraid.NewManagedIdentityCredentialsProvider(entraid.ManagedId
425
425
``` go
426
426
// Create provider for user assigned identity
427
427
provider , err := entraid.NewManagedIdentityCredentialsProvider (entraid.ManagedIdentityCredentialsProviderOptions {
428
- CredentialsProviderOptions : entraid.CredentialsProviderOptions {
429
- ClientID: os.Getenv (" AZURE_CLIENT_ID" ),
430
- },
428
+ CredentialsProviderOptions : entraid.CredentialsProviderOptions {},
431
429
ManagedIdentityProviderOptions : identity.ManagedIdentityProviderOptions {
432
430
ManagedIdentityType: identity.UserAssignedObjectID ,
433
431
UserAssignedObjectID: os.Getenv (" AZURE_USER_ASSIGNED_MANAGED_ID" ),
@@ -617,8 +615,11 @@ This approach gives you the flexibility of custom authentication while benefitin
617
615
func TestManagedIdentityProvider (t *testing .T ) {
618
616
// Create test provider
619
617
provider , err := entraid.NewManagedIdentityCredentialsProvider (entraid.ManagedIdentityCredentialsProviderOptions {
620
- CredentialsProviderOptions: entraid.CredentialsProviderOptions {
621
- ClientID: " test-client-id" ,
618
+ CredentialsProviderOptions: entraid.CredentialsProviderOptions {},
619
+ ManagedIdentityProviderOptions: identity.ManagedIdentityProviderOptions {
620
+ UserAssignedObjectID: " test-managed-id" ,
621
+ ManagedIdentityType: identity.UserAssignedObjectID ,
622
+ Scopes: []string {identity.RedisScopeDefault },
622
623
},
623
624
})
624
625
if err != nil {
@@ -652,8 +653,11 @@ func TestManagedIdentityProvider(t *testing.T) {
652
653
func TestRedisConnection (t *testing .T ) {
653
654
// Create provider
654
655
provider , err := entraid.NewManagedIdentityCredentialsProvider (entraid.ManagedIdentityCredentialsProviderOptions {
655
- CredentialsProviderOptions: entraid.CredentialsProviderOptions {
656
- ClientID: os.Getenv (" AZURE_CLIENT_ID" ),
656
+ CredentialsProviderOptions: entraid.CredentialsProviderOptions {},
657
+ ManagedIdentityProviderOptions: identity.ManagedIdentityProviderOptions {
658
+ UserAssignedObjectID: os.Getenv (" AZURE_CLIENT_ID" ),
659
+ ManagedIdentityType: identity.UserAssignedObjectID ,
660
+ Scopes: []string {identity.RedisScopeDefault },
657
661
},
658
662
})
659
663
if err != nil {
0 commit comments