Skip to content

Commit 935a0a5

Browse files
authored
[OIDC] Add flight for using federated credentials (#10262)
1 parent f9a22db commit 935a0a5

6 files changed

Lines changed: 37 additions & 8 deletions

File tree

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
using NuGet.Services.Entities;
@@ -323,5 +323,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
323323
{
324324
throw new NotImplementedException();
325325
}
326+
327+
public bool CanUseFederatedCredentials(User user)
328+
{
329+
throw new NotImplementedException();
330+
}
326331
}
327332
}

src/GitHubVulnerabilities2Db/Fakes/FakeFeatureFlagService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
using System;
@@ -324,5 +324,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
324324
{
325325
throw new NotImplementedException();
326326
}
327+
328+
public bool CanUseFederatedCredentials(User user)
329+
{
330+
throw new NotImplementedException();
331+
}
327332
}
328333
}

src/NuGetGallery.Services/Configuration/FeatureFlagService.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
using System;
@@ -63,6 +63,7 @@ public class FeatureFlagService : IFeatureFlagService
6363
private const string FrameworkFilteringFeatureName = GalleryPrefix + "FrameworkFiltering";
6464
private const string DisplayTfmBadgesFeatureName = GalleryPrefix + "DisplayTfmBadges";
6565
private const string AdvancedFrameworkFilteringFeatureName = GalleryPrefix + "AdvancedFrameworkFiltering";
66+
private const string FederatedCredentialsFeatureName = GalleryPrefix + "FederatedCredentials";
6667

6768
private const string ODataV1GetAllNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllNonHijacked";
6869
private const string ODataV1GetAllCountNonHijackedFeatureName = GalleryPrefix + "ODataV1GetAllCountNonHijacked";
@@ -120,7 +121,7 @@ public bool IsPackagesAtomFeedEnabled()
120121
/// <summary>
121122
/// The number of versions a package needs to have before it should be flighted using <see cref="ManageDeprecationForManyVersionsFeatureName"/> instead of <see cref="ManageDeprecationFeatureName"/>.
122123
/// </summary>
123-
private const int _manageDeprecationForManyVersionsThreshold = 500;
124+
private const int ManageDeprecationForManyVersionsThreshold = 500;
124125

125126
public bool IsManageDeprecationEnabled(User user, PackageRegistration registration)
126127
{
@@ -144,7 +145,7 @@ public bool IsManageDeprecationEnabled(User user, IEnumerable<Package> allVersio
144145
return false;
145146
}
146147

147-
return allVersions.Count() < _manageDeprecationForManyVersionsThreshold
148+
return allVersions.Count() < ManageDeprecationForManyVersionsThreshold
148149
|| _client.IsEnabled(ManageDeprecationForManyVersionsFeatureName, user, defaultValue: true);
149150
}
150151

@@ -421,5 +422,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
421422
{
422423
return _client.IsEnabled(AdvancedFrameworkFilteringFeatureName, user, defaultValue: false);
423424
}
425+
426+
public bool CanUseFederatedCredentials(User user)
427+
{
428+
return _client.IsEnabled(FederatedCredentialsFeatureName, user, defaultValue: false);
429+
}
424430
}
425431
}

src/NuGetGallery.Services/Configuration/IFeatureFlagService.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
using System.Collections.Generic;
@@ -342,5 +342,10 @@ public interface IFeatureFlagService
342342
/// Whether or not to allow filtering by frameworks on NuGet.org search
343343
/// </summary>
344344
bool IsAdvancedFrameworkFilteringEnabled(User user);
345+
346+
/// <summary>
347+
/// Whether or not the user specified in a package owner scope can use federated credentials.
348+
/// </summary>
349+
bool CanUseFederatedCredentials(User user);
345350
}
346351
}

src/NuGetGallery/App_Data/Files/Content/flags.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
"SiteAdmins": false,
146146
"Accounts": [],
147147
"Domains": []
148+
},
149+
"NuGetGallery.FederatedCredentials": {
150+
"All": true,
151+
"SiteAdmins": false,
152+
"Accounts": [],
153+
"Domains": []
148154
}
149155
}
150-
}
156+
}

src/VerifyMicrosoftPackage/Fakes/FakeFeatureFlagService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

44
using System;
@@ -135,5 +135,7 @@ public class FakeFeatureFlagService : IFeatureFlagService
135135
public bool IsDisplayTfmBadgesEnabled(User user) => throw new NotImplementedException();
136136

137137
public bool IsAdvancedFrameworkFilteringEnabled(User user) => throw new NotImplementedException();
138+
139+
public bool CanUseFederatedCredentials(User user) => throw new NotImplementedException();
138140
}
139141
}

0 commit comments

Comments
 (0)