1
1
package entraid
2
2
3
3
import (
4
+ "crypto"
5
+ "crypto/x509"
6
+
4
7
"github.com/redis/go-redis/v9/auth"
5
8
)
6
9
@@ -9,6 +12,10 @@ type CredentialsProviderOptions struct {
9
12
// This is used to identify the identity when requesting a token.
10
13
ClientID string
11
14
15
+ // TenantID is the tenant ID of the service principal.
16
+ // This is used to identify the tenant when requesting a token.
17
+ TenantID string
18
+
12
19
// Scopes is a list of scopes that the identity has access to.
13
20
// This is used to specify the permissions that the identity has when requesting a token.
14
21
Scopes []string
@@ -23,42 +30,59 @@ type CredentialsProviderOptions struct {
23
30
OnRetryableError func (error ) error
24
31
}
25
32
26
- type SystemAssignedOptions struct {
27
- CredentialsProviderOptions
28
- }
29
-
30
- func NewSystemAssignedCredentialsProvider (options SystemAssignedOptions ) (auth.StreamingCredentialsProvider , error ) {
31
- return nil , ErrNotImplemented
32
- }
33
-
34
- type UserAssignedOptions struct {
35
- CredentialsProviderOptions
36
- }
33
+ const (
34
+ // SystemAssignedIdentity is the type of identity that is automatically managed by Azure.
35
+ SystemAssignedIdentity = "SystemAssigned"
36
+ // UserAssignedIdentity is the type of identity that is managed by the user.
37
+ UserAssignedIdentity = "UserAssigned"
37
38
38
- func NewUserAssignedCredentialsProvider (options UserAssignedOptions ) (auth.StreamingCredentialsProvider , error ) {
39
- return nil , ErrNotImplemented
40
- }
39
+ // ClientSecretCredentialType is the type of credentials that uses a client secret to authenticate.
40
+ ClientSecretCredentialType = "ClientSecret"
41
+ // ClientCertificateCredentialType is the type of credentials that uses a client certificate to authenticate.
42
+ ClientCertificateCredentialType = "ClientCertificate"
43
+ )
41
44
42
- type ClientCredentialsOptions struct {
45
+ type ManagedIdentityCredentialsProviderOptions struct {
43
46
CredentialsProviderOptions
47
+ ManagedIdentityType string
44
48
}
45
49
46
- func NewClientCredentialsCredentialsProvider (options ClientCredentialsOptions ) (auth.StreamingCredentialsProvider , error ) {
50
+ // NewManagedIdentityCredentialsProvider creates a new streaming credentials provider for managed identity.
51
+ // It uses the provided options to configure the provider.
52
+ // Use this when you want either a system assigned identity or a user assigned identity.
53
+ // The system assigned identity is automatically managed by Azure and does not require any additional configuration.
54
+ // The user assigned identity is a separate resource that can be managed independently.
55
+ func NewManagedIdentityCredentialsProvider (options ManagedIdentityCredentialsProviderOptions ) (* auth.StreamingCredentialsProvider , error ) {
47
56
return nil , ErrNotImplemented
48
57
}
49
58
50
- type DefaultAzureOptions struct {
59
+ type ServicePrincipalCredentialsProviderOptions struct {
51
60
CredentialsProviderOptions
52
- }
53
61
54
- func NewDefaultAzureCredentialsProvider (options DefaultAzureOptions ) (auth.StreamingCredentialsProvider , error ) {
55
- return nil , ErrNotImplemented
56
- }
57
-
58
- type AuthorizationCodeWithPKCEOptions struct {
59
- CredentialsProviderOptions
62
+ // ClientCredentialType is the type of credentials that are used to authenticate the service principal.
63
+ // This can be either ClientSecret or ClientCertificate.
64
+ // ClientSecret is used to authenticate the service principal when requesting a token.
65
+ // ClientCertificate is used to authenticate the service principal using a certificate.
66
+ ClientCredentialType string
67
+
68
+ // ClientSecret is the client secret of the service principal.
69
+ // This is used to authenticate the service principal when requesting a token.
70
+ ClientSecret string
71
+
72
+ // ClientCertificate is the client certificate of the service principal.
73
+ // This is used to authenticate the service principal when requesting a token.
74
+ ClientCertificate x509.Certificate
75
+ // ClientCertificatePrivateKey is the private key of the client certificate.
76
+ // This is used to authenticate the service principal when requesting a token.
77
+ ClientCertificatePrivateKey crypto.PrivateKey
60
78
}
61
79
62
- func NewAuthorizationCodeWithPKCECredentialsProvider (options AuthorizationCodeWithPKCEOptions ) (auth.StreamingCredentialsProvider , error ) {
80
+ // NewServicePrincipalCredentialsProvider creates a new streaming credentials provider for service principal.
81
+ // It uses the provided options to configure the provider.
82
+ // Use this when you want to use a service principal to authenticate with Azure.
83
+ // The service principal is a security identity that is used to authenticate with Azure.
84
+ // It is typically used in scenarios where a user cannot be present to authenticate interactively.
85
+ // The service principal is created in Azure Active Directory and is used to authenticate with Azure resources.
86
+ func NewServicePrincipalCredentialsProvider (options ServicePrincipalCredentialsProviderOptions ) (* auth.StreamingCredentialsProvider , error ) {
63
87
return nil , ErrNotImplemented
64
88
}
0 commit comments