Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,20 @@ public class PullRequestController : Controller
private readonly IReviewManager _reviewManager;
private readonly IAPIRevisionsManager _apiRevisionsManager;
private readonly IConfiguration _configuration;
private readonly IOpenSourceRequestManager _openSourceManager;
private readonly TelemetryClient _telemetryClient;
private HashSet<string> _allowedListBotAccounts = new HashSet<string>();

string[] VALID_EXTENSIONS = new string[] { ".whl", ".api.json", ".nupkg", "-sources.jar", ".gosource" };

public PullRequestController(ICodeFileManager codeFileManager, IPullRequestManager pullRequestManager,
IAPIRevisionsManager apiRevisionsManager, IReviewManager reviewManager,
IConfiguration configuration, IOpenSourceRequestManager openSourceRequestManager, TelemetryClient telemetryClient)
IConfiguration configuration, TelemetryClient telemetryClient)
{
_codeFileManager = codeFileManager;
_pullRequestManager = pullRequestManager;
_reviewManager = reviewManager;
_apiRevisionsManager = apiRevisionsManager;
_configuration = configuration;
_openSourceManager = openSourceRequestManager;
_telemetryClient = telemetryClient;

var botAllowedList = _configuration["allowedList-bot-github-accounts"];
Expand Down Expand Up @@ -139,10 +137,6 @@ private async Task<string> DetectAPIChanges(string buildId,
}

pullRequestModel.Commits.Add(commitSha);
//Check if PR owner is part of Azure//Microsoft org in GitHub
await ManagerHelpers.AssertPullRequestCreatorPermission(prModel: pullRequestModel, allowedListBotAccounts: _allowedListBotAccounts,
openSourceManager: _openSourceManager, telemetryClient: _telemetryClient);


try
{
Expand Down
16 changes: 0 additions & 16 deletions src/dotnet/APIView/APIViewWeb/Helpers/ManagerHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@ public static void AssertAPIRevisionDeletion(APIRevisionListItemModel apiRevisio
}
}

public static async Task AssertPullRequestCreatorPermission(
PullRequestModel prModel, HashSet<string> allowedListBotAccounts, IOpenSourceRequestManager openSourceManager,
TelemetryClient telemetryClient)
{
// White list bot accounts to create API reviews from PR automatically
if (!allowedListBotAccounts.Contains(prModel.CreatedBy))
{
var isAuthorized = await openSourceManager.IsAuthorizedUser(prModel.CreatedBy);
if (!isAuthorized)
{
telemetryClient.TrackTrace($"API change detection permission failed for user {prModel.CreatedBy}. API review is only created if PR author is an internal user.");
throw new AuthorizationFailedException();
}
}
}

public static string ResolveReviewUrl(PullRequestModel pullRequest, string hostName)
{
var url = $"https://{hostName}/Assemblies/Review/{pullRequest.ReviewId}";
Expand Down

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions src/dotnet/APIView/APIViewWeb/Models/OpenSourceUserInfo.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/dotnet/APIView/APIViewWeb/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public void ConfigureServices(IServiceCollection services)
services.AddSingleton<ISamplesRevisionsManager, SamplesRevisionsManager>();
services.AddSingleton<ICodeFileManager, CodeFileManager>();
services.AddSingleton<IUserProfileManager, UserProfileManager>();
services.AddSingleton<IOpenSourceRequestManager, OpenSourceRequestManager>();
services.AddSingleton<IAICommentsManager, AICommentsManager>();
services.AddSingleton<UserPreferenceCache>();

Expand Down