@@ -17,24 +17,37 @@ namespace TeamCloud.Adapters;
1717
1818public abstract class AdapterWithIdentity : Adapter , IAdapterIdentity
1919{
20- private readonly IAzureService azure ;
20+ private readonly IAzureService azureService ;
2121 private readonly IGraphService graphService ;
2222 private readonly IOrganizationRepository organizationRepository ;
2323 private readonly IProjectRepository projectRepository ;
2424
2525#pragma warning disable CS0618 // Type or member is obsolete
2626
27- protected AdapterWithIdentity ( IAuthorizationSessionClient sessionClient ,
28- IAuthorizationTokenClient tokenClient ,
29- IDistributedLockManager distributedLockManager ,
30- IAzureService azure ,
31- IGraphService graphService ,
32- IOrganizationRepository organizationRepository ,
33- IDeploymentScopeRepository deploymentScopeRepository ,
34- IProjectRepository projectRepository ,
35- IUserRepository userRepository ) : base ( sessionClient , tokenClient , distributedLockManager , azure , graphService , organizationRepository , deploymentScopeRepository , projectRepository , userRepository )
27+ protected AdapterWithIdentity (
28+ IAdapterProvider adapterProvider ,
29+ IAuthorizationSessionClient sessionClient ,
30+ IAuthorizationTokenClient tokenClient ,
31+ IDistributedLockManager distributedLockManager ,
32+ IAzureService azureService ,
33+ IGraphService graphService ,
34+ IOrganizationRepository organizationRepository ,
35+ IDeploymentScopeRepository deploymentScopeRepository ,
36+ IProjectRepository projectRepository ,
37+ IUserRepository userRepository )
38+ : base (
39+ adapterProvider ,
40+ sessionClient ,
41+ tokenClient ,
42+ distributedLockManager ,
43+ azureService ,
44+ graphService ,
45+ organizationRepository ,
46+ deploymentScopeRepository ,
47+ projectRepository ,
48+ userRepository )
3649 {
37- this . azure = azure ?? throw new ArgumentNullException ( nameof ( azure ) ) ;
50+ this . azureService = azureService ?? throw new ArgumentNullException ( nameof ( azureService ) ) ;
3851 this . graphService = graphService ?? throw new ArgumentNullException ( nameof ( graphService ) ) ;
3952 this . organizationRepository = organizationRepository ?? throw new ArgumentNullException ( nameof ( organizationRepository ) ) ;
4053 this . projectRepository = projectRepository ?? throw new ArgumentNullException ( nameof ( projectRepository ) ) ;
@@ -65,7 +78,7 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Compone
6578 . CreateServicePrincipalAsync ( servicePrincipalName )
6679 . ConfigureAwait ( false ) ;
6780 }
68- else if ( servicePrincipal . ExpiresOn . GetValueOrDefault ( DateTime . MinValue ) < DateTime . UtcNow )
81+ else if ( servicePrincipal . ExpiresOn . GetValueOrDefault ( DateTime . MinValue . ToUniversalTime ( ) ) < DateTime . UtcNow )
6982 {
7083 // a service principal exists, but its secret is expired. lets refresh
7184 // the service principal (create a new secret) so we can move on
@@ -82,7 +95,7 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Compone
8295 . GetAsync ( component . Organization , component . ProjectId )
8396 . ConfigureAwait ( false ) ;
8497
85- var secretClient = await azure . KeyVaults
98+ var secretClient = await azureService . KeyVaults
8699 . GetSecretClientAsync ( project . SecretsVaultId , ensureIdentityAccess : true )
87100 . ConfigureAwait ( false ) ;
88101
@@ -96,7 +109,7 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Compone
96109 . GetAsync ( component . Organization , component . ProjectId )
97110 . ConfigureAwait ( false ) ;
98111
99- var secretClient = await azure . KeyVaults
112+ var secretClient = await azureService . KeyVaults
100113 . GetSecretClientAsync ( project . SecretsVaultId , ensureIdentityAccess : true )
101114 . ConfigureAwait ( false ) ;
102115
@@ -134,7 +147,7 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Deploym
134147 . CreateServicePrincipalAsync ( servicePrincipalName )
135148 . ConfigureAwait ( false ) ;
136149 }
137- else if ( servicePrincipal . ExpiresOn . GetValueOrDefault ( DateTime . MinValue ) < DateTime . UtcNow )
150+ else if ( servicePrincipal . ExpiresOn . GetValueOrDefault ( DateTime . MinValue . ToUniversalTime ( ) ) < DateTime . UtcNow )
138151 {
139152 // a service principal exists, but its secret is expired. lets refresh
140153 // the service principal (create a new secret) so we can move on
@@ -147,15 +160,15 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Deploym
147160
148161 if ( ! string . IsNullOrEmpty ( servicePrincipal . Password ) )
149162 {
150- var tenantId = await azure
163+ var tenantId = await azureService
151164 . GetTenantIdAsync ( )
152165 . ConfigureAwait ( false ) ;
153166
154167 var organization = await organizationRepository
155168 . GetAsync ( tenantId , deploymentScope . Organization )
156169 . ConfigureAwait ( false ) ;
157170
158- var secretClient = await azure . KeyVaults
171+ var secretClient = await azureService . KeyVaults
159172 . GetSecretClientAsync ( organization . SecretsVaultId , ensureIdentityAccess : true )
160173 . ConfigureAwait ( false ) ;
161174
@@ -165,15 +178,15 @@ public virtual async Task<AzureServicePrincipal> GetServiceIdentityAsync(Deploym
165178 }
166179 else if ( withPassword )
167180 {
168- var tenantId = await azure
181+ var tenantId = await azureService
169182 . GetTenantIdAsync ( )
170183 . ConfigureAwait ( false ) ;
171184
172185 var organization = await organizationRepository
173186 . GetAsync ( tenantId , deploymentScope . Organization )
174187 . ConfigureAwait ( false ) ;
175188
176- var secretClient = await azure . KeyVaults
189+ var secretClient = await azureService . KeyVaults
177190 . GetSecretClientAsync ( organization . SecretsVaultId , ensureIdentityAccess : true )
178191 . ConfigureAwait ( false ) ;
179192
0 commit comments