1- // Copyright (c) .NET Foundation. All rights reserved.
1+ // Copyright (c) .NET Foundation. All rights reserved.
22// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33
44using System ;
1414using NuGet . Services . Configuration ;
1515using NuGet . Services . KeyVault ;
1616using NuGetGallery . Configuration . SecretReader ;
17+ using NuGetGallery . Services . Authentication ;
1718
1819namespace NuGetGallery . Configuration
1920{
@@ -23,6 +24,7 @@ public class ConfigurationService : IGalleryConfigurationService, IConfiguration
2324 protected const string FeaturePrefix = "Feature." ;
2425 protected const string ServiceBusPrefix = "AzureServiceBus." ;
2526 protected const string PackageDeletePrefix = "PackageDelete." ;
27+ protected const string FederatedCredentialPrefix = "FederatedCredential." ;
2628
2729 private readonly Lazy < string > _httpSiteRootThunk ;
2830 private readonly Lazy < string > _httpsSiteRootThunk ;
@@ -31,6 +33,7 @@ public class ConfigurationService : IGalleryConfigurationService, IConfiguration
3133 private readonly Lazy < FeatureConfiguration > _lazyFeatureConfiguration ;
3234 private readonly Lazy < IServiceBusConfiguration > _lazyServiceBusConfiguration ;
3335 private readonly Lazy < IPackageDeleteConfiguration > _lazyPackageDeleteConfiguration ;
36+ private readonly Lazy < FederatedCredentialConfiguration > _lazyFederatedCredentialConfiguration ;
3437
3538 private static readonly HashSet < string > NotInjectedSettingNames = new HashSet < string > ( StringComparer . OrdinalIgnoreCase ) {
3639 SettingPrefix + "SqlServer" ,
@@ -66,6 +69,7 @@ public ConfigurationService()
6669 _lazyFeatureConfiguration = new Lazy < FeatureConfiguration > ( ( ) => ResolveFeatures ( ) . Result ) ;
6770 _lazyServiceBusConfiguration = new Lazy < IServiceBusConfiguration > ( ( ) => ResolveServiceBus ( ) . Result ) ;
6871 _lazyPackageDeleteConfiguration = new Lazy < IPackageDeleteConfiguration > ( ( ) => ResolvePackageDelete ( ) . Result ) ;
72+ _lazyFederatedCredentialConfiguration = new Lazy < FederatedCredentialConfiguration > ( ( ) => ResolveFederatedCredential ( ) . Result ) ;
6973 }
7074
7175 public static IEnumerable < PropertyDescriptor > GetConfigProperties < T > ( T instance )
@@ -81,6 +85,8 @@ public static IEnumerable<PropertyDescriptor> GetConfigProperties<T>(T instance)
8185
8286 public IPackageDeleteConfiguration PackageDelete => _lazyPackageDeleteConfiguration . Value ;
8387
88+ public FederatedCredentialConfiguration FederatedCredential => _lazyFederatedCredentialConfiguration . Value ;
89+
8490 /// <summary>
8591 /// Gets the site root using the specified protocol
8692 /// </summary>
@@ -206,6 +212,11 @@ private async Task<IPackageDeleteConfiguration> ResolvePackageDelete()
206212 return await ResolveConfigObject ( new PackageDeleteConfiguration ( ) , PackageDeletePrefix ) ;
207213 }
208214
215+ private async Task < FederatedCredentialConfiguration > ResolveFederatedCredential ( )
216+ {
217+ return await ResolveConfigObject ( new FederatedCredentialConfiguration ( ) , FederatedCredentialPrefix ) ;
218+ }
219+
209220 protected virtual string GetAppSetting ( string settingName )
210221 {
211222 return WebConfigurationManager . AppSettings [ settingName ] ;
@@ -273,4 +284,4 @@ private void CheckValidSiteRoot(string siteRoot)
273284 }
274285 }
275286 }
276- }
287+ }
0 commit comments