Skip to content

Commit 23d824a

Browse files
authored
Remove TrustedPublishing feature flag (#10631)
1 parent fc6395b commit 23d824a

11 files changed

Lines changed: 18 additions & 294 deletions

File tree

src/AccountDeleter/EmptyFeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,6 @@ public bool CanUseFederatedCredentials(User user)
333333
{
334334
throw new NotImplementedException();
335335
}
336-
337-
public bool IsTrustedPublishingEnabled(User user)
338-
{
339-
throw new NotImplementedException();
340-
}
341336

342337
public bool IsProfileLoadOptimizationEnabled()
343338
{

src/GitHubVulnerabilities2Db/Fakes/FakeFeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,11 +335,6 @@ public bool CanUseFederatedCredentials(User user)
335335
throw new NotImplementedException();
336336
}
337337

338-
public bool IsTrustedPublishingEnabled(User user)
339-
{
340-
throw new NotImplementedException();
341-
}
342-
343338
public bool IsProfileLoadOptimizationEnabled()
344339
{
345340
throw new NotImplementedException();

src/NuGetGallery.Services/Authentication/Federated/GitHubTokenPolicyValidator.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ public override FederatedCredentialPolicyValidationResult ValidatePolicy(Federat
7070
policyPropertyName: null);
7171
}
7272

73-
if (!_featureFlagService.IsTrustedPublishingEnabled(policy.CreatedBy))
74-
{
75-
return FederatedCredentialPolicyValidationResult.BadRequest(
76-
$"Trusted Publishing is not enabled for '{policy.CreatedBy.Username}'.",
77-
nameof(FederatedCredentialPolicy.CreatedBy));
78-
}
79-
8073
GitHubCriteria gitHubCriteria = GitHubCriteria.FromDatabaseJson(policy.Criteria);
8174
NormalizeRepositoryName(gitHubCriteria);
8275
NormalizeWorkflowFileName(gitHubCriteria);
@@ -184,11 +177,6 @@ public override async Task<FederatedCredentialPolicyResult> EvaluatePolicyAsync(
184177
return FederatedCredentialPolicyResult.NotApplicable;
185178
}
186179

187-
if (!_featureFlagService.IsTrustedPublishingEnabled(policy.CreatedBy))
188-
{
189-
return FederatedCredentialPolicyResult.Unauthorized($"Trusted publishing is not enabled for {policy.CreatedBy.Username}");
190-
}
191-
192180
var criteria = GitHubCriteria.FromDatabaseJson(policy.Criteria);
193181

194182
// Validate required GitHub criterias first

src/NuGetGallery.Services/Configuration/FeatureFlagService.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,6 @@ public bool CanUseFederatedCredentials(User user)
440440
return _client.IsEnabled(FederatedCredentialsFeatureName, user, defaultValue: false);
441441
}
442442

443-
public bool IsTrustedPublishingEnabled(User user)
444-
{
445-
return _client.IsEnabled(TrustedPublishingFeatureName, user, defaultValue: false);
446-
}
447-
448443
public bool IsProfileLoadOptimizationEnabled()
449444
{
450445
return _client.IsEnabled(ProfileLoadOptimization, defaultValue: true);

src/NuGetGallery.Services/Configuration/IFeatureFlagService.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,6 @@ public interface IFeatureFlagService
356356
/// </summary>
357357
bool CanUseFederatedCredentials(User user);
358358

359-
/// <summary>
360-
/// Whether or not the user can access trusted publishing functionality, e.g. GitHub Actions workflows.
361-
/// When enabled, this controls both the ability to create Trusted Publishing policies and the ability
362-
/// to exchange external tokens for NuGet API keys during package operations.
363-
/// </summary>
364-
bool IsTrustedPublishingEnabled(User user);
365-
366359
/// <summary>
367360
/// Whether or not the first iteration of the profile load optimization is enabled.
368361
/// </summary>

src/NuGetGallery/Controllers/UsersController.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,11 +1039,6 @@ public virtual ActionResult PasswordChanged()
10391039
public virtual ActionResult TrustedPublishing()
10401040
{
10411041
User currentUser = GetCurrentUser();
1042-
if (!_featureFlagService.IsTrustedPublishingEnabled(currentUser))
1043-
{
1044-
return new HttpStatusCodeResult(HttpStatusCode.NotFound);
1045-
}
1046-
10471042
var userPolicies = _federatedCredentialService.GetPoliciesCreatedByUser(currentUser.Key);
10481043

10491044
// Show newest policies on the top.
@@ -1208,11 +1203,6 @@ private string ViewToPolicyCriteria(string criteria)
12081203
public virtual async Task<ActionResult> RemoveTrustedPublisherPolicy(int? federatedCredentialKey)
12091204
{
12101205
User currentUser = GetCurrentUser();
1211-
if (!_featureFlagService.IsTrustedPublishingEnabled(currentUser))
1212-
{
1213-
Response.StatusCode = (int)HttpStatusCode.BadRequest;
1214-
return Json(Strings.DefaultUserSafeExceptionMessage);
1215-
}
12161206

12171207
var result = GetFederatedCredentialPolicy(federatedCredentialKey);
12181208
if (result.policy == null)

src/NuGetGallery/Views/Shared/Gallery/Header.cshtml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
&& Config.Current.DeprecateNuGetPasswordLogins
77
&& User.HasPasswordLogin();
88
var rawErrorMessage = TempData.ContainsKey("RawErrorMessage") ? TempData["RawErrorMessage"].ToString() : null;
9-
var featureFlagService = DependencyResolver.Current.GetService<IFeatureFlagService>();
10-
ViewBag.IsTrustedPublishingEnabled = featureFlagService != null && featureFlagService.IsTrustedPublishingEnabled(CurrentUser);
119
}
1210

1311
<div id="cookie-banner"></div>
@@ -143,10 +141,7 @@
143141
</a>
144142
</li>
145143

146-
@if (ViewBag.IsTrustedPublishingEnabled)
147-
{
148-
<li role="presentation"><a href="@Url.ManageMyTrustedPublishing()" role="menuitem">Trusted Publishing</a></li>
149-
}
144+
<li role="presentation"><a href="@Url.ManageMyTrustedPublishing()" role="menuitem">Trusted Publishing</a></li>
150145
<li role="presentation"><a href="@Url.ManageMyApiKeys()" role="menuitem">API Keys</a></li>
151146

152147
<li class="divider"></li>

src/NuGetGallery/Views/Users/ApiKeys.cshtml

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
@{
55
ViewBag.Title = "API Keys";
66
ViewBag.MdPageColumns = GalleryConstants.ColumnsFormMd;
7-
var featureFlagService = DependencyResolver.Current.GetService<IFeatureFlagService>();
8-
ViewBag.IsTrustedPublishingEnabled = featureFlagService != null && featureFlagService.IsTrustedPublishingEnabled(CurrentUser);
97
}
108

119
<section role="main" class="container main-container page-api-keys">
@@ -14,16 +12,13 @@
1412
<div class="@ViewHelpers.GetColumnClasses(ViewBag)">
1513
@ViewHelpers.BreadcrumbWithProfile(Url, CurrentUser, true, @<text>API keys</text>)
1614

17-
@if (ViewBag.IsTrustedPublishingEnabled)
18-
{
19-
@ViewHelpers.Alert(
15+
@ViewHelpers.Alert(
2016
@<text>
2117
<strong>Looking for a more secure and streamlined way to publish packages?</strong>
2218
If you're using GitHub Actions, we recommend switching to
2319
<a href="@Url.ManageMyTrustedPublishing()">Trusted Publishing</a> since it eliminates the need to manage API keys.
2420
</text>,
25-
"info", icon: null)
26-
}
21+
"info", icon: null)
2722

2823
<p>
2924
An API key is a token that can identify you to @(Config.Current.Brand). The
@@ -33,10 +28,10 @@
3328
@if (!CurrentUser.Confirmed)
3429
{
3530
@ViewHelpers.AlertWarning(
36-
@<text>
37-
To get an API Key you will need to
38-
<a href="@Url.ConfirmationRequired()">confirm your account</a>.
39-
</text>)
31+
@<text>
32+
To get an API Key you will need to
33+
<a href="@Url.ConfirmationRequired()">confirm your account</a>.
34+
</text>)
4035
}
4136
else
4237
{
@@ -49,21 +44,21 @@
4944
@ViewHelpers.Section(this,
5045
"create",
5146
"Create",
52-
@<text>
53-
<div class="upsert-api-key">
54-
<div class="panel-body" data-bind="template: { name: 'upsert-api-key', data: NewApiKey }"></div>
55-
</div>
56-
</text>,
57-
expanded: false,
58-
expandedIcon: "Subtraction",
59-
collapsedIcon: "Add")
47+
@<text>
48+
<div class="upsert-api-key">
49+
<div class="panel-body" data-bind="template: { name: 'upsert-api-key', data: NewApiKey }"></div>
50+
</div>
51+
</text>,
52+
expanded: false,
53+
expandedIcon: "Subtraction",
54+
collapsedIcon: "Add")
6055

6156
@ViewHelpers.Section(this,
6257
"manage",
6358
"Manage",
64-
@<text>
65-
<div data-bind="template: 'manage-api-keys'"></div>
66-
</text>)
59+
@<text>
60+
<div data-bind="template: 'manage-api-keys'"></div>
61+
</text>)
6762
}
6863
</div>
6964
</div>

src/VerifyMicrosoftPackage/Fakes/FakeFeatureFlagService.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ public class FakeFeatureFlagService : IFeatureFlagService
140140

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

143-
public bool IsTrustedPublishingEnabled(User user) => throw new NotImplementedException();
144-
145143
public bool IsProfileLoadOptimizationEnabled() => throw new NotImplementedException();
146144

147145
public bool IsProfileLoadOptimizationV2Enabled() => throw new NotImplementedException();

0 commit comments

Comments
 (0)