File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,18 @@ const (
20
20
MSIContextGateway MSIContext = "GATEWAY"
21
21
)
22
22
23
+ const EnvUseWorkloadIdentity = "ARO_RP_WORKLOAD_IDENTITY"
24
+
23
25
func (c * core ) NewMSITokenCredential () (azcore.TokenCredential , error ) {
24
26
if ! c .IsLocalDevelopmentMode () {
27
+ // If ARO_RP_WORKLOAD_IDENTITY is set, use a WorkloadIdentity credential
28
+ // for RP authentication to FPSP keyvault instead
29
+ useWorkloadIdentity := os .Getenv (EnvUseWorkloadIdentity )
30
+ if useWorkloadIdentity != "" {
31
+ options := c .Environment ().WorkloadIdentityCredentialOptions ()
32
+ return azidentity .NewWorkloadIdentityCredential (options )
33
+ }
34
+
25
35
options := c .Environment ().ManagedIdentityCredentialOptions ()
26
36
return azidentity .NewManagedIdentityCredential (options )
27
37
}
Original file line number Diff line number Diff line change @@ -149,6 +149,12 @@ func (e *AROEnvironment) ManagedIdentityCredentialOptions() *azidentity.ManagedI
149
149
}
150
150
}
151
151
152
+ func (e * AROEnvironment ) WorkloadIdentityCredentialOptions () * azidentity.WorkloadIdentityCredentialOptions {
153
+ return & azidentity.WorkloadIdentityCredentialOptions {
154
+ ClientOptions : e .AzureClientOptions (),
155
+ }
156
+ }
157
+
152
158
func (e * AROEnvironment ) AzureClientOptions () azcore.ClientOptions {
153
159
return azcore.ClientOptions {
154
160
Cloud : e .Cloud ,
You can’t perform that action at this time.
0 commit comments