Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OIDC 3] Add flight for using federated credentials #10262

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/AccountDeleter/EmptyFeatureFlagService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using NuGet.Services.Entities;
Expand Down Expand Up @@ -323,5 +323,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
{
throw new NotImplementedException();
}

public bool CanUseFederatedCredentials(User user)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -324,5 +324,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
{
throw new NotImplementedException();
}

public bool CanUseFederatedCredentials(User user)
{
throw new NotImplementedException();
}
}
}
12 changes: 9 additions & 3 deletions src/NuGetGallery.Services/Configuration/FeatureFlagService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -63,6 +63,7 @@ public class FeatureFlagService : IFeatureFlagService
private const string FrameworkFilteringFeatureName = GalleryPrefix + "FrameworkFiltering";
private const string DisplayTfmBadgesFeatureName = GalleryPrefix + "DisplayTfmBadges";
private const string AdvancedFrameworkFilteringFeatureName = GalleryPrefix + "AdvancedFrameworkFiltering";
private const string FederatedCredentialsFeatureName = GalleryPrefix + "FederatedCredentials";

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

public bool IsManageDeprecationEnabled(User user, PackageRegistration registration)
{
Expand All @@ -144,7 +145,7 @@ public bool IsManageDeprecationEnabled(User user, IEnumerable<Package> allVersio
return false;
}

return allVersions.Count() < _manageDeprecationForManyVersionsThreshold
return allVersions.Count() < ManageDeprecationForManyVersionsThreshold
|| _client.IsEnabled(ManageDeprecationForManyVersionsFeatureName, user, defaultValue: true);
}

Expand Down Expand Up @@ -421,5 +422,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
{
return _client.IsEnabled(AdvancedFrameworkFilteringFeatureName, user, defaultValue: false);
}

public bool CanUseFederatedCredentials(User user)
{
return _client.IsEnabled(FederatedCredentialsFeatureName, user, defaultValue: false);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
Expand Down Expand Up @@ -342,5 +342,10 @@ public interface IFeatureFlagService
/// Whether or not to allow filtering by frameworks on NuGet.org search
/// </summary>
bool IsAdvancedFrameworkFilteringEnabled(User user);

/// <summary>
/// Whether or not the user specified in a package owner scope can use federated credentials.
/// </summary>
bool CanUseFederatedCredentials(User user);
}
}
8 changes: 7 additions & 1 deletion src/NuGetGallery/App_Data/Files/Content/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@
"SiteAdmins": false,
"Accounts": [],
"Domains": []
},
"NuGetGallery.FederatedCredentials": {
"All": true,
"SiteAdmins": false,
"Accounts": [],
"Domains": []
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

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

public bool IsAdvancedFrameworkFilteringEnabled(User user) => throw new NotImplementedException();

public bool CanUseFederatedCredentials(User user) => throw new NotImplementedException();
}
}